cec: added a callback that is called when libCEC's configuration changed.
[deb_libcec.git] / src / cec-config-gui / CecConfigGUI.cs
index b8c2b54fa68ca7031ef3b410c72639a63f9e732c..e41c292be80901d16658a6f00ad4189a54cb2bc3 100644 (file)
@@ -35,7 +35,7 @@ namespace CecConfigGui
       CecAdapter[] adapters = Lib.FindAdapters(string.Empty);
       if (adapters.Length == 0 || !Lib.Open(adapters[0].ComPort, 10000))
       {
-        MessageBox.Show("Could not connect to any CEC adapter. Please check your configuration.", "Pulse-Eight USB-CEC Adapter", MessageBoxButtons.OK);
+        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();
       }
 
@@ -222,18 +222,14 @@ namespace CecConfigGui
       this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("(Samsung) Return", (new CecSharp.CecKeypress() { Keycode = 0x91 }), string.Empty));
     }
 
-    public int ReceiveCommand(CecCommand command)
+    public int ConfigurationChanged(LibCECConfiguration config)
     {
-      bool bGetNewPhysicalAddress = false;
-      if (command.Opcode == CecOpcode.ReportPhysicalAddress)
-        bGetNewPhysicalAddress = true;
+      SetControlText(this.tbPhysicalAddress, String.Format("{0,4:X}", config.PhysicalAddress));
+      return 1;
+    }
 
-      if (bGetNewPhysicalAddress)
-      {
-        LibCECConfiguration config = new LibCECConfiguration();
-        Lib.GetCurrentConfiguration(config);
-        SetControlText(this.tbPhysicalAddress, String.Format("{0,4:X}", config.PhysicalAddress));
-      }
+    public int ReceiveCommand(CecCommand command)
+    {
       return 1;
     }
 
@@ -884,6 +880,11 @@ namespace CecConfigGui
       return Gui.ReceiveLogMessage(message);
     }
 
+    public override int ConfigurationChanged(LibCECConfiguration config)
+    {
+      return Gui.ConfigurationChanged(config);
+    }
+
     private CecConfigGUI Gui;
   }
 }