X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=inline;f=src%2Fcec-config-gui%2FCecConfigGUI.cs;h=8fb066f2e9349915ad260c15d55306ea78792218;hb=c8a49e16408664a12197f6a2626a9a22802a355b;hp=94ce2ad5a016212f4897d41c74c4c4457fc13d2e;hpb=ee7748a3ead9a4810bf123f745077b6885ba0eb6;p=deb_libcec.git
diff --git a/src/cec-config-gui/CecConfigGUI.cs b/src/cec-config-gui/CecConfigGUI.cs
index 94ce2ad..8fb066f 100644
--- a/src/cec-config-gui/CecConfigGUI.cs
+++ b/src/cec-config-gui/CecConfigGUI.cs
@@ -321,6 +321,12 @@ namespace CecConfigGui
}
SetControlVisible(pProgress, false);
break;
+ case UpdateEventType.ExitApplication:
+ ActiveProcess = null;
+ SetControlsEnabled(false);
+ SetControlVisible(pProgress, false);
+ Application.Exit();
+ break;
}
}
@@ -545,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
+ {
+ fs = (FileStream)dialog.OpenFile();
+ }
+ catch (Exception ex)
{
- 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)
+ error = ex.Message;
+ }
+ if (fs == null)
{
- 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);
- }
+ 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)