cec-config-gui: added an update button on the device info window
authorLars Op den Kamp <lars@opdenkamp.eu>
Wed, 15 Feb 2012 21:19:55 +0000 (22:19 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Wed, 15 Feb 2012 21:40:48 +0000 (22:40 +0100)
src/cec-config-gui/CecConfigGUI.Designer.cs
src/cec-config-gui/CecConfigGUI.cs
src/cec-config-gui/DeviceInformation.Designer.cs
src/cec-config-gui/DeviceInformation.cs
src/cec-config-gui/actions/ConnectToDevice.cs
src/cec-config-gui/actions/RescanDevices.cs [new file with mode: 0644]
src/cec-config-gui/actions/ShowDeviceInfo.cs
src/cec-config-gui/actions/UpdateConfiguration.cs [new file with mode: 0644]
src/cec-config-gui/actions/UpdateDeviceInfo.cs [new file with mode: 0644]
src/cec-config-gui/actions/UpdateEvent.cs
src/cec-config-gui/cec-config-gui.csproj

index 2489cf25b2e584b8f8112b0c1d1ffe46914c1197..2c0f909e2ef9c573a5a31497dafa7bf74c88d63e 100644 (file)
@@ -63,6 +63,7 @@
       this.playerButtonDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
       this.cecButtonConfigBindingSource = new System.Windows.Forms.BindingSource(this.components);
       this.tbTestCommands = new System.Windows.Forms.TabPage();
+      this.bRescanDevices = new System.Windows.Forms.Button();
       this.bMute = new System.Windows.Forms.Button();
       this.bVolDown = new System.Windows.Forms.Button();
       this.bVolUp = new System.Windows.Forms.Button();
       // 
       // cbPowerOffDevices
       // 
+      this.cbPowerOffDevices.Enabled = false;
       this.cbPowerOffDevices.FormattingEnabled = true;
       this.cbPowerOffDevices.Items.AddRange(new object[] {
             "0: TV",
       // 
       // cbWakeDevices
       // 
+      this.cbWakeDevices.Enabled = false;
       this.cbWakeDevices.FormattingEnabled = true;
       this.cbWakeDevices.Items.AddRange(new object[] {
             "0: TV",
       this.cbDeviceType.TabIndex = 14;
       this.cbDeviceType.Text = "Recorder";
       this.helpDeviceType.SetToolTip(this.cbDeviceType, "Set this to \'Player\' when your TV is having problems with \'Recorder\'");
+      this.cbDeviceType.SelectedIndexChanged += new System.EventHandler(this.cbDeviceType_SelectedIndexChanged);
       // 
       // bClose
       // 
       // 
       // tbTestCommands
       // 
+      this.tbTestCommands.Controls.Add(this.bRescanDevices);
       this.tbTestCommands.Controls.Add(this.bMute);
       this.tbTestCommands.Controls.Add(this.bVolDown);
       this.tbTestCommands.Controls.Add(this.bVolUp);
       this.tbTestCommands.Text = "CEC tester";
       this.tbTestCommands.UseVisualStyleBackColor = true;
       // 
+      // bRescanDevices
+      // 
+      this.bRescanDevices.Enabled = false;
+      this.bRescanDevices.Location = new System.Drawing.Point(424, 65);
+      this.bRescanDevices.Name = "bRescanDevices";
+      this.bRescanDevices.Size = new System.Drawing.Size(150, 23);
+      this.bRescanDevices.TabIndex = 9;
+      this.bRescanDevices.Text = "Re-scan devices";
+      this.bRescanDevices.UseVisualStyleBackColor = true;
+      this.bRescanDevices.Click += new System.EventHandler(this.bRescanDevices_Click);
+      // 
       // bMute
       // 
       this.bMute.Enabled = false;
       // 
       // bActivateSource
       // 
+      this.bActivateSource.Enabled = false;
       this.bActivateSource.Location = new System.Drawing.Point(8, 65);
       this.bActivateSource.Name = "bActivateSource";
       this.bActivateSource.Size = new System.Drawing.Size(150, 23);
       // 
       // bScan
       // 
+      this.bScan.Enabled = false;
       this.bScan.Location = new System.Drawing.Point(8, 94);
       this.bScan.Name = "bScan";
       this.bScan.Size = new System.Drawing.Size(150, 23);
       // 
       // bStandby
       // 
+      this.bStandby.Enabled = false;
       this.bStandby.Location = new System.Drawing.Point(8, 36);
       this.bStandby.Name = "bStandby";
       this.bStandby.Size = new System.Drawing.Size(150, 23);
       // 
       // bSendImageViewOn
       // 
+      this.bSendImageViewOn.Enabled = false;
       this.bSendImageViewOn.Location = new System.Drawing.Point(8, 7);
       this.bSendImageViewOn.Name = "bSendImageViewOn";
       this.bSendImageViewOn.Size = new System.Drawing.Size(150, 23);
       this.cbCommandDestination.FormattingEnabled = true;
       this.cbCommandDestination.Items.AddRange(new object[] {
             "0: TV",
-            "1: Recorder 1",
-            "2: Recorder 2",
-            "3: Tuner 1",
-            "4: Playback 1",
-            "5: Audio system",
-            "6: Tuner 2",
-            "7: Tuner 3",
-            "8: Playback 2",
-            "9: Recorder 3",
-            "A: Tuner 4",
-            "B: Playback 3",
-            "C: Reserved 1",
-            "D: Reserved 2",
-            "E: Free use",
             "F: Broadcast"});
       this.cbCommandDestination.Location = new System.Drawing.Point(437, 30);
       this.cbCommandDestination.Name = "cbCommandDestination";
     private System.Windows.Forms.CheckBox cbVendorOverride;
     private System.Windows.Forms.ComboBox cbVendorId;
     private System.Windows.Forms.Button bReloadConfig;
+    private System.Windows.Forms.Button bRescanDevices;
   }
 }
\ No newline at end of file
index b2b6c557038bd60a531073155863e55370363e2a..2bafae814b45e2867bf1240781791f29f0afdca3 100644 (file)
@@ -305,9 +305,17 @@ namespace CecConfigGui
           ConfigurationChanged(updateEvent.ConfigValue);
           SuppressUpdates = false;
           break;
+        case UpdateEventType.PollDevices:
+          CheckActiveDevices();
+          break;
         case UpdateEventType.ProcessCompleted:
           ActiveProcess = null;
           SetControlsEnabled(true);
+          if (UpdatingInfoPanel != null)
+          {
+            UpdatingInfoPanel.SetControlEnabled(UpdatingInfoPanel.bUpdate, true);
+            UpdatingInfoPanel = null;
+          }
           break;
       }
     }
@@ -317,7 +325,7 @@ namespace CecConfigGui
       SetControlEnabled(cbPortNumber, val);
       SetControlEnabled(cbConnectedDevice, cbConnectedDevice.Items.Count > 1 ? val : false);
       SetControlEnabled(tbPhysicalAddress, val);
-      SetControlEnabled(cbDeviceType, false); // TODO not implemented yet
+      SetControlEnabled(cbDeviceType, val);
       SetControlEnabled(cbUseTVMenuLanguage, val);
       SetControlEnabled(cbActivateSource, val);
       SetControlEnabled(cbPowerOffScreensaver, val);
@@ -329,6 +337,7 @@ namespace CecConfigGui
       SetControlEnabled(bClose, val);
       SetControlEnabled(bSaveConfig, val);
       SetControlEnabled(bReloadConfig, val);
+      SetControlEnabled(bRescanDevices, val);
 
       SetControlEnabled(bSendImageViewOn, val);
       SetControlEnabled(bStandby, val);
@@ -372,6 +381,19 @@ namespace CecConfigGui
       ConfigurationChanged(Config);
     }
 
+    public void UpdateInfoPanel(DeviceInformation panel)
+    {
+      if (!SuppressUpdates && ActiveProcess == null)
+      {
+        SetControlsEnabled(false);
+        UpdatingInfoPanel = panel;
+        panel.SetControlEnabled(panel.bUpdate, false);
+        ActiveProcess = new UpdateDeviceInfo(this, ref Lib, panel);
+        ActiveProcess.EventHandler += new EventHandler<UpdateEvent>(ProcessEventHandler);
+        (new Thread(new ThreadStart(ActiveProcess.Run))).Start();
+      }
+    }
+
     public void SetPhysicalAddress(ushort physicalAddress)
     {
       if (!SuppressUpdates && ActiveProcess == null)
@@ -385,6 +407,17 @@ namespace CecConfigGui
       }
     }
 
+    public void UpdateConfigurationAsync()
+    {
+      if (!SuppressUpdates && ActiveProcess == null)
+      {
+        SetControlsEnabled(false);
+        ActiveProcess = new UpdateConfiguration(ref Lib, Config);
+        ActiveProcess.EventHandler += new EventHandler<UpdateEvent>(ProcessEventHandler);
+        (new Thread(new ThreadStart(ActiveProcess.Run))).Start();
+      }
+    }
+
     public void SendImageViewOn(CecLogicalAddress address)
     {
       if (!SuppressUpdates && ActiveProcess == null)
@@ -529,6 +562,7 @@ namespace CecConfigGui
               output.AppendLine("<setting id=\"port\" value=\"\" />");
 
               // only supported by 1.5.0+ clients
+              output.AppendLine("<!-- the following lines are only supported by v1.5.0+ clients -->");
               output.AppendLine("<setting id=\"physical_address\" value=\"" + string.Format("{0,4:X}", Config.PhysicalAddress) + "\" />");
               output.AppendLine("<setting id=\"device_type\" value=\"" + (int)Config.DeviceTypes.Types[0] + "\" />");
               output.AppendLine("<setting id=\"tv_vendor\" value=\"" + string.Format("{0,6:X}", (int)Config.TvVendor) + "\" />");
@@ -621,6 +655,20 @@ namespace CecConfigGui
         Config.TvVendor = CecVendorId.Unknown;
       }
     }
+
+    private void cbDeviceType_SelectedIndexChanged(object sender, EventArgs e)
+    {
+      CecDeviceType type = SelectedDeviceType;
+      if (type != Config.DeviceTypes.Types[0])
+      {
+        Config.DeviceTypes.Types[0] = type;
+        if (!DeviceChangeWarningDisplayed)
+        {
+          DeviceChangeWarningDisplayed = true;
+          MessageBox.Show("You have changed the device type. Save the configuration, and restart the application to use the new setting.", "Pulse-Eight USB-CEC Adapter", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+        }
+      }
+    }
     #endregion
 
     #region Key configuration tab
@@ -668,6 +716,40 @@ namespace CecConfigGui
     #endregion
 
     #region CEC Tester tab
+    public void CheckActiveDevices()
+    {
+      CecLogicalAddresses activeDevices = Lib.GetActiveDevices();
+      List<string> deviceList = new List<string>();
+      foreach (CecLogicalAddress activeDevice in activeDevices.Addresses)
+      {
+        if (activeDevice != CecLogicalAddress.Unregistered)
+          deviceList.Add(string.Format("{0,1:X} : {1}", (int)activeDevice, Lib.ToString(activeDevice)));
+      }
+      deviceList.Add(string.Format("{0,1:X} : {1}", (int)CecLogicalAddress.Broadcast, Lib.ToString(CecLogicalAddress.Broadcast)));
+
+      SetActiveDevices(deviceList.ToArray());
+    }
+
+    delegate void SetActiveDevicesCallback(string[] activeDevices);
+    private void SetActiveDevices(string[] activeDevices)
+    {
+      if (this.cbCommandDestination.InvokeRequired)
+      {
+        SetActiveDevicesCallback d = new SetActiveDevicesCallback(SetActiveDevices);
+        try
+        {
+          this.Invoke(d, new object[] { activeDevices });
+        }
+        catch (Exception) { }
+      }
+      else
+      {
+        this.cbCommandDestination.Items.Clear();
+        foreach (string item in activeDevices)
+          this.cbCommandDestination.Items.Add(item);
+      }
+    }
+
     delegate CecLogicalAddress GetTargetDeviceCallback();
     private CecLogicalAddress GetTargetDevice()
     {
@@ -748,6 +830,8 @@ namespace CecConfigGui
       this.bVolUp.Enabled = enableVolumeButtons;
       this.bVolDown.Enabled = enableVolumeButtons;
       this.bMute.Enabled = enableVolumeButtons;
+      this.bActivateSource.Enabled = (GetTargetDevice() != CecLogicalAddress.Broadcast);
+      this.bScan.Enabled = (GetTargetDevice() != CecLogicalAddress.Broadcast);
     }
 
     private void bVolUp_Click(object sender, EventArgs e)
@@ -770,6 +854,17 @@ namespace CecConfigGui
       Lib.MuteAudio(true);
       SetControlsEnabled(true);
     }
+
+    private void bRescanDevices_Click(object sender, EventArgs e)
+    {
+      if (!SuppressUpdates && ActiveProcess == null)
+      {
+        SetControlsEnabled(false);
+        ActiveProcess = new RescanDevices();
+        ActiveProcess.EventHandler += new EventHandler<UpdateEvent>(ProcessEventHandler);
+        (new Thread(new ThreadStart(ActiveProcess.Run))).Start();
+      }
+    }
     #endregion
 
     #region Log tab
@@ -835,7 +930,8 @@ namespace CecConfigGui
 
     private void bClearLog_Click(object sender, EventArgs e)
     {
-      tbLog.Text = string.Empty;
+      Log = string.Empty;
+      UpdateLog();
     }
 
     private void bSaveLog_Click(object sender, EventArgs e)
@@ -859,7 +955,7 @@ namespace CecConfigGui
         else
         {
           StreamWriter writer = new StreamWriter(fs);
-          writer.Write(tbLog.Text);
+          writer.Write(Log);
           writer.Close();
           fs.Close();
           fs.Dispose();
@@ -971,6 +1067,21 @@ namespace CecConfigGui
         return (cbConnectedDevice.Text.Equals(AVRVendorString)) ? CecLogicalAddress.AudioSystem : CecLogicalAddress.Tv;
       }
     }
+    public CecDeviceType SelectedDeviceType
+    {
+      get
+      {
+        switch (cbDeviceType.Text.ToLower())
+        {
+          case "player":
+            return CecDeviceType.PlaybackDevice;
+          case "tuner":
+            return CecDeviceType.Tuner;
+          default:
+            return CecDeviceType.RecordingDevice;
+        }
+      }
+    }
     public int SelectedPortNumber
     {
       get
@@ -988,6 +1099,8 @@ namespace CecConfigGui
     private bool SuppressUpdates = true;
     private ConfigTab SelectedTab = ConfigTab.Configuration;
     private string Log = string.Empty;
+    private DeviceInformation UpdatingInfoPanel = null;
+    private bool DeviceChangeWarningDisplayed = false;
     #endregion
   }
 
index 4a16c7debc96aecae2676a4613085c0e43a90865..c2ea74fe50378e57cd07009dcf88d8156f76acd9 100644 (file)
@@ -50,6 +50,7 @@
       this.lDevice = new System.Windows.Forms.Label();
       this.lInactiveSource = new System.Windows.Forms.LinkLabel();
       this.lPowerStatus = new System.Windows.Forms.LinkLabel();
+      this.bUpdate = new System.Windows.Forms.Button();
       this.SuspendLayout();
       // 
       // label1
       this.lPowerStatus.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
       this.lPowerStatus.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lStandby_LinkClicked);
       // 
+      // bUpdate
+      // 
+      this.bUpdate.Location = new System.Drawing.Point(102, 207);
+      this.bUpdate.Name = "bUpdate";
+      this.bUpdate.Size = new System.Drawing.Size(75, 23);
+      this.bUpdate.TabIndex = 31;
+      this.bUpdate.Text = "Refresh";
+      this.bUpdate.UseVisualStyleBackColor = true;
+      this.bUpdate.Click += new System.EventHandler(this.button1_Click);
+      // 
       // DeviceInformation
       // 
       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
       this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-      this.ClientSize = new System.Drawing.Size(284, 218);
+      this.ClientSize = new System.Drawing.Size(284, 239);
+      this.Controls.Add(this.bUpdate);
       this.Controls.Add(this.lPowerStatus);
       this.Controls.Add(this.lInactiveSource);
       this.Controls.Add(this.lDevice);
     private System.Windows.Forms.Label lDevice;
     private System.Windows.Forms.LinkLabel lInactiveSource;
     private System.Windows.Forms.LinkLabel lPowerStatus;
+    public System.Windows.Forms.Button bUpdate;
   }
 }
\ No newline at end of file
index 2900ab31e164187611e9db19fb4495fb7fb0f5a8..0743e9ed655905b6784b1c7b7da93b6b875f08e1 100644 (file)
@@ -21,17 +21,22 @@ namespace CecConfigGui
       InitializeComponent();
       this.lDevice.Text = lib.ToString(address);
       this.lLogicalAddress.Text = String.Format("{0,1:X}", (int)address);
-      this.lPhysicalAddress.Text = String.Format("{0,4:X}", physicalAddress);
-      this.lDevicePresent.Text = devicePresent ? "yes" : "no";
-      this.lActiveSource.Visible = isActiveSource;
-      this.lInactiveSource.Visible = !isActiveSource;
-      this.lVendor.Text = vendor != CecVendorId.Unknown ? lib.ToString(vendor) : "unknown";
-      this.lCecVersion.Text = lib.ToString(version);
-      this.lPowerStatus.Text = lib.ToString(power);
-      bool isPoweredOn = (power == CecPowerStatus.On || power == CecPowerStatus.InTransitionStandbyToOn);
-      this.lOsdName.Text = osdName;
-      this.lMenuLanguage.Text = menuLanguage;
-      this.Text = "Device: " + osdName;
+      Update(devicePresent, vendor, isActiveSource, physicalAddress, version, power, osdName, menuLanguage);
+    }
+
+    public void Update(bool devicePresent, CecVendorId vendor, bool isActiveSource, ushort physicalAddress,
+      CecVersion version, CecPowerStatus power, string osdName, string menuLanguage)
+    {
+      SetControlText(lPhysicalAddress, String.Format("{0,4:X}", physicalAddress));
+      SetControlText(lDevicePresent, devicePresent ? "yes" : "no");
+      SetControlVisible(lActiveSource, isActiveSource);
+      SetControlVisible(lInactiveSource, !isActiveSource);
+      SetControlText(lVendor, vendor != CecVendorId.Unknown ? Lib.ToString(vendor) : "unknown");
+      SetControlText(lCecVersion, Lib.ToString(version));
+      SetControlText(lPowerStatus, Lib.ToString(power));
+      SetControlText(lOsdName, osdName);
+      SetControlText(lMenuLanguage, menuLanguage);
+      SetControlText(this, "Device: " + osdName);
     }
 
     private void lInactiveSource_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
@@ -54,7 +59,17 @@ namespace CecConfigGui
         Gui.SendStandby(Address);
     }
 
-    private CecLogicalAddress Address;
+
+    private void button1_Click(object sender, EventArgs e)
+    {
+      Gui.UpdateInfoPanel(this);
+    }
+
+    public CecLogicalAddress Address
+    {
+      private set;
+      get;
+    }
     private CecConfigGUI Gui;
     private LibCecSharp Lib;
   }
index a1e1ef6a9bbc59f05b5ece7d0dcd5febb18f604b..43d786eccf1df168f9751e447f539c0583e98882 100644 (file)
@@ -25,14 +25,14 @@ namespace CecConfigGui.actions
       }
 
       SendEvent(UpdateEventType.StatusText, "Detecting TV vendor...");
-      SendEvent(UpdateEventType.ProgressBar, 25);
+      SendEvent(UpdateEventType.ProgressBar, 20);
       SendEvent(UpdateEventType.TVVendorId, (int)Lib.GetDeviceVendorId(CecLogicalAddress.Tv));
 
       SendEvent(UpdateEventType.StatusText, "Detecting menu language...");
-      SendEvent(UpdateEventType.ProgressBar, 40);
+      SendEvent(UpdateEventType.ProgressBar, 30);
       SendEvent(UpdateEventType.MenuLanguage, Lib.GetDeviceMenuLanguage(CecLogicalAddress.Tv));
 
-      SendEvent(UpdateEventType.ProgressBar, 50);
+      SendEvent(UpdateEventType.ProgressBar, 40);
       SendEvent(UpdateEventType.StatusText, "Detecting AVR devices...");
 
       bool hasAVRDevice = Lib.IsActiveDevice(CecLogicalAddress.AudioSystem);
@@ -40,24 +40,28 @@ namespace CecConfigGui.actions
 
       if (hasAVRDevice)
       {
-        SendEvent(UpdateEventType.ProgressBar, 75);
+        SendEvent(UpdateEventType.ProgressBar, 50);
         SendEvent(UpdateEventType.StatusText, "Detecting AVR vendor...");
         SendEvent(UpdateEventType.AVRVendorId, (int)Lib.GetDeviceVendorId(CecLogicalAddress.AudioSystem));
       }
 
       if (!Lib.GetDevicePowerStatus(CecLogicalAddress.Tv).Equals(CecPowerStatus.On))
       {
-        SendEvent(UpdateEventType.ProgressBar, 80);
+        SendEvent(UpdateEventType.ProgressBar, 60);
         SendEvent(UpdateEventType.StatusText, "Activating the source...");
         Lib.SetActiveSource(CecDeviceType.Reserved);
       }
 
-      SendEvent(UpdateEventType.ProgressBar, 90);
+      SendEvent(UpdateEventType.ProgressBar, 70);
       SendEvent(UpdateEventType.StatusText, "Reading device configuration...");
 
       Lib.GetCurrentConfiguration(Config);
       SendEvent(Config);
 
+      SendEvent(UpdateEventType.ProgressBar, 80);
+      SendEvent(UpdateEventType.StatusText, "Polling active devices");
+      SendEvent(UpdateEventType.PollDevices);
+
       SendEvent(UpdateEventType.ProgressBar, 100);
       SendEvent(UpdateEventType.StatusText, "Ready.");
     }
diff --git a/src/cec-config-gui/actions/RescanDevices.cs b/src/cec-config-gui/actions/RescanDevices.cs
new file mode 100644 (file)
index 0000000..0e110a8
--- /dev/null
@@ -0,0 +1,18 @@
+using CecSharp;
+using System.Windows.Forms;
+
+namespace CecConfigGui.actions
+{
+  class RescanDevices : UpdateProcess
+  {
+    public override void Process()
+    {
+      SendEvent(UpdateEventType.ProgressBar, 10);
+      SendEvent(UpdateEventType.StatusText, "Polling active devices");
+      SendEvent(UpdateEventType.PollDevices);
+
+      SendEvent(UpdateEventType.ProgressBar, 100);
+      SendEvent(UpdateEventType.StatusText, "Ready.");
+    }
+  }
+}
index df8b4d144799e533b198e95c65ebc470af54d1f0..628d4a9829a44d24faa3b4dcff8804b83976650e 100644 (file)
@@ -14,6 +14,14 @@ namespace CecConfigGui.actions
       Address = address;
     }
 
+    public virtual void ShowDialog(CecConfigGUI gui, CecLogicalAddress address, ref LibCecSharp lib,
+      bool devicePresent, CecVendorId vendor, bool isActiveSource, ushort physicalAddress,
+      CecVersion version, CecPowerStatus power, string osdName, string menuLanguage)
+    {
+      DeviceInformation di = new DeviceInformation(Gui, Address, ref Lib, devicePresent, vendor, isActiveSource, physicalAddress, version, power, osdName, menuLanguage);
+      Gui.DisplayDialog(di, false);
+    }
+
     public override void Process()
     {
       CecVendorId vendor = CecVendorId.Unknown;
@@ -63,8 +71,7 @@ namespace CecConfigGui.actions
       SendEvent(UpdateEventType.ProgressBar, 90);
       SendEvent(UpdateEventType.ProcessCompleted, true);
 
-      DeviceInformation di = new DeviceInformation(Gui, Address, ref Lib, devicePresent, vendor, isActiveSource, physicalAddress, version, power, osdName, menuLanguage);
-      Gui.DisplayDialog(di, false);
+      ShowDialog(Gui, Address, ref Lib, devicePresent, vendor, isActiveSource, physicalAddress, version, power, osdName, menuLanguage);
 
       SendEvent(UpdateEventType.StatusText, "Ready.");
       SendEvent(UpdateEventType.ProgressBar, 100);
diff --git a/src/cec-config-gui/actions/UpdateConfiguration.cs b/src/cec-config-gui/actions/UpdateConfiguration.cs
new file mode 100644 (file)
index 0000000..af41205
--- /dev/null
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using CecSharp;
+
+namespace CecConfigGui.actions
+{
+  class UpdateConfiguration : UpdateProcess
+  {
+    public UpdateConfiguration(ref LibCecSharp lib, LibCECConfiguration config)
+    {
+      Lib = lib;
+      Config = config;
+    }
+
+    public override void Process()
+    {
+      SendEvent(UpdateEventType.ProgressBar, 10);
+      SendEvent(UpdateEventType.StatusText, "Setting the new configuration");
+
+      Lib.SetConfiguration(Config);
+
+      SendEvent(UpdateEventType.ProgressBar, 100);
+      SendEvent(UpdateEventType.StatusText, "Ready.");
+    }
+
+    private LibCecSharp Lib;
+    private LibCECConfiguration Config;
+  }
+}
diff --git a/src/cec-config-gui/actions/UpdateDeviceInfo.cs b/src/cec-config-gui/actions/UpdateDeviceInfo.cs
new file mode 100644 (file)
index 0000000..3cbde24
--- /dev/null
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using CecSharp;
+
+namespace CecConfigGui.actions
+{
+  class UpdateDeviceInfo : ShowDeviceInfo
+  {
+    public UpdateDeviceInfo(CecConfigGUI gui, ref LibCecSharp lib, DeviceInformation dialog) :
+      base(gui, ref lib, dialog.Address)
+    {
+      Dialog = dialog;
+    }
+
+    public override void ShowDialog(CecConfigGUI gui, CecLogicalAddress address, ref LibCecSharp lib,
+      bool devicePresent, CecVendorId vendor, bool isActiveSource, ushort physicalAddress,
+      CecVersion version, CecPowerStatus power, string osdName, string menuLanguage)
+    {
+      Dialog.Update(devicePresent, vendor, isActiveSource, physicalAddress, version, power, osdName, menuLanguage);
+    }
+
+    private DeviceInformation Dialog;
+  }
+}
index 6d19757121fe4d0abc522a3aebfb6512d0271151..dae21bfc438439d024a819805821bfeedb626f8b 100644 (file)
@@ -18,11 +18,17 @@ namespace CecConfigGui
     HasAVRDevice,
     AVRVendorId,
     Configuration,
-    MenuLanguage
+    MenuLanguage,
+    PollDevices
   }
 
   public class UpdateEvent : EventArgs
   {
+    public UpdateEvent(UpdateEventType type)
+    {
+      Type = type;
+    }
+
     public UpdateEvent(UpdateEventType type, bool value)
     {
       Type = type;
@@ -60,6 +66,13 @@ namespace CecConfigGui
     {
     }
 
+    public void SendEvent(UpdateEventType type)
+    {
+      EventHandler<UpdateEvent> temp = EventHandler;
+      if (temp != null)
+        temp(this, new UpdateEvent(type));
+    }
+
     public void SendEvent(UpdateEventType type, bool value)
     {
       EventHandler<UpdateEvent> temp = EventHandler;
index 3594a16bd7c37cc27c138d5cff02f3f49638293c..44221441047481452312c02fe96a91a0eb5c0819 100644 (file)
     <Reference Include="System.Xml" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="actions\UpdateConfiguration.cs" />
     <Compile Include="actions\ConnectToDevice.cs" />
+    <Compile Include="actions\RescanDevices.cs" />
     <Compile Include="actions\SendActivateSource.cs" />
     <Compile Include="actions\SendImageViewOn.cs" />
     <Compile Include="actions\SendStandby.cs" />
     <Compile Include="actions\ShowDeviceInfo.cs" />
     <Compile Include="actions\UpdateConnectedDevice.cs" />
+    <Compile Include="actions\UpdateDeviceInfo.cs" />
     <Compile Include="actions\UpdatePhysicalAddress.cs" />
     <Compile Include="AsyncForm.cs">
       <SubType>Form</SubType>