X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcec-config-gui%2FCecConfigGUI.cs;h=8fb066f2e9349915ad260c15d55306ea78792218;hb=7068f331f39c119c8d5ef11860e080f12841f2ce;hp=adc02e86e022648c8d1db34d961c2b8f1afcdee1;hpb=e23f490fdd949351aefebfdbfa981047357e4ac4;p=deb_libcec.git
diff --git a/src/cec-config-gui/CecConfigGUI.cs b/src/cec-config-gui/CecConfigGUI.cs
index adc02e8..8fb066f 100644
--- a/src/cec-config-gui/CecConfigGUI.cs
+++ b/src/cec-config-gui/CecConfigGUI.cs
@@ -551,100 +551,93 @@ namespace CecConfigGui
Config.WakeDevices = WakeDevices;
Config.PowerOffDevices = PowerOffDevices;
- if (!Lib.CanPersistConfiguration())
+ /* save settings in the eeprom */
+ Lib.PersistConfiguration(Config);
+
+ /* and in xml */
+ if (ActiveProcess == null)
{
- if (ActiveProcess == null)
- {
- SetControlsEnabled(false);
- string xbmcDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\XBMC\userdata\peripheral_data";
- string defaultDir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
+ SetControlsEnabled(false);
+ string xbmcDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\XBMC\userdata\peripheral_data";
+ string defaultDir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
- SaveFileDialog dialog = new SaveFileDialog()
+ SaveFileDialog dialog = new SaveFileDialog()
+ {
+ Title = "Where do you want to store the settings?",
+ InitialDirectory = Directory.Exists(xbmcDir) ? xbmcDir : defaultDir,
+ FileName = "usb_2548_1001.xml",
+ Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*",
+ FilterIndex = 1
+ };
+
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ FileStream fs = null;
+ string error = string.Empty;
+ try
{
- Title = "Where do you want to store the settings?",
- InitialDirectory = Directory.Exists(xbmcDir) ? xbmcDir : defaultDir,
- FileName = "usb_2548_1001.xml",
- Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*",
- FilterIndex = 1
- };
-
- if (dialog.ShowDialog() == DialogResult.OK)
+ fs = (FileStream)dialog.OpenFile();
+ }
+ catch (Exception ex)
{
- FileStream fs = null;
- string error = string.Empty;
- try
- {
- fs = (FileStream)dialog.OpenFile();
- }
- catch (Exception ex)
- {
- error = ex.Message;
- }
- if (fs == null)
- {
- MessageBox.Show("Cannot open '" + dialog.FileName + "' for writing" + (error.Length > 0 ? ": " + error : string.Empty ), "Pulse-Eight USB-CEC Adapter", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- else
- {
- StreamWriter writer = new StreamWriter(fs);
- StringBuilder output = new StringBuilder();
- output.AppendLine("");
- output.AppendLine("");
- output.AppendLine("");
- output.AppendLine("");
- output.AppendLine("");
- output.AppendLine("");
- output.AppendLine("");
- output.AppendLine("");
- output.AppendLine("");
- output.AppendLine("");
-
- // only supported by 1.5.0+ clients
- output.AppendLine("");
- output.AppendLine("");
- output.AppendLine("");
- output.AppendLine("");
- output.AppendLine("");
-
- output.Append("");
-
- output.Append("");
-
- // only supported by 1.5.1+ clients
- output.AppendLine("");
- output.AppendLine("");
-
- output.AppendLine("");
- writer.Write(output.ToString());
- writer.Close();
- fs.Close();
- fs.Dispose();
- MessageBox.Show("Settings are stored.", "Pulse-Eight USB-CEC Adapter", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
+ error = ex.Message;
+ }
+ if (fs == null)
+ {
+ MessageBox.Show("Cannot open '" + dialog.FileName + "' for writing" + (error.Length > 0 ? ": " + error : string.Empty ), "Pulse-Eight USB-CEC Adapter", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ else
+ {
+ StreamWriter writer = new StreamWriter(fs);
+ StringBuilder output = new StringBuilder();
+ output.AppendLine("");
+ output.AppendLine("");
+ output.AppendLine("");
+ output.AppendLine("");
+ output.AppendLine("");
+ output.AppendLine("");
+ output.AppendLine("");
+ output.AppendLine("");
+ output.AppendLine("");
+ output.AppendLine("");
+
+ // only supported by 1.5.0+ clients
+ output.AppendLine("");
+ output.AppendLine("");
+ output.AppendLine("");
+ output.AppendLine("");
+ output.AppendLine("");
+
+ output.Append("");
+
+ output.Append("");
+
+ // only supported by 1.5.1+ clients
+ output.AppendLine("");
+ output.AppendLine("");
+
+ output.AppendLine("");
+ writer.Write(output.ToString());
+ writer.Close();
+ fs.Close();
+ fs.Dispose();
+ MessageBox.Show("Settings are stored.", "Pulse-Eight USB-CEC Adapter", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
- SetControlsEnabled(true);
}
+ SetControlsEnabled(true);
}
- else
- {
- if (!Lib.PersistConfiguration(Config))
- MessageBox.Show("Could not persist the new settings.", "Pulse-Eight USB-CEC Adapter", MessageBoxButtons.OK, MessageBoxIcon.Error);
- else
- MessageBox.Show("Settings are stored.", "Pulse-Eight USB-CEC Adapter", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- SetControlsEnabled(true);
}
private void bReloadConfig_Click(object sender, EventArgs e)