cec-config-gui: ask the user whether he wants to try to reconnect when the connection...
authorLars Op den Kamp <lars@opdenkamp.eu>
Sun, 19 Feb 2012 01:16:05 +0000 (02:16 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Sun, 19 Feb 2012 01:26:16 +0000 (02:26 +0100)
src/cec-config-gui/actions/ConnectToDevice.cs

index 128223f94ec01a919b8f11f37b295bc1f300ef8b..fedc31398e700c7721b9bb89f7f91ec77f51424a 100644 (file)
@@ -18,10 +18,20 @@ namespace CecConfigGui.actions
 
       //TODO read the com port setting from the configuration
       CecAdapter[] adapters = Lib.FindAdapters(string.Empty);
-      if (adapters.Length == 0 || !Lib.Open(adapters[0].ComPort, 10000))
+      if (adapters.Length == 0)
       {
-        MessageBox.Show("Could not connect to any CEC adapter. Please check your configuration and try again.", "Pulse-Eight USB-CEC Adapter", MessageBoxButtons.OK);
-        Application.Exit();
+        DialogResult result = MessageBox.Show("Could not detect to any CEC adapter. Please check your configuration. Do you want to try again?", "Pulse-Eight USB-CEC Adapter", MessageBoxButtons.YesNo);
+        if (result == DialogResult.No)
+          Application.Exit();
+        else
+          adapters = Lib.FindAdapters(string.Empty);
+      }
+
+      while (!Lib.Open(adapters[0].ComPort, 10000))
+      {
+        DialogResult result = MessageBox.Show("Could not connect to any CEC adapter. Please check your configuration. Do you want to try again?", "Pulse-Eight USB-CEC Adapter", MessageBoxButtons.YesNo);
+        if (result == DialogResult.No)
+          Application.Exit();
       }
 
       SendEvent(UpdateEventType.ProgressBar, 20);