cec-config-gui: added the new parameters. cleanup round.
authorLars Op den Kamp <lars@opdenkamp.eu>
Wed, 15 Feb 2012 15:02:26 +0000 (16:02 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Wed, 15 Feb 2012 15:02:26 +0000 (16:02 +0100)
src/cec-config-gui/AsyncForm.cs [new file with mode: 0644]
src/cec-config-gui/CecConfigGUI.Designer.cs
src/cec-config-gui/CecConfigGUI.cs
src/cec-config-gui/CecConfigGUI.resx
src/cec-config-gui/DeviceInformation.cs
src/cec-config-gui/cec-config-gui.csproj

diff --git a/src/cec-config-gui/AsyncForm.cs b/src/cec-config-gui/AsyncForm.cs
new file mode 100644 (file)
index 0000000..4584d75
--- /dev/null
@@ -0,0 +1,118 @@
+using System;
+using System.Windows.Forms;
+
+namespace CecConfigGui
+{
+  public class AsyncForm : Form
+  {
+    delegate void SetControlEnabledCallback(Control control, bool val);
+    public void SetControlEnabled(Control control, bool val)
+    {
+      if (control.InvokeRequired)
+      {
+        SetControlEnabledCallback d = new SetControlEnabledCallback(SetControlEnabled);
+        try
+        {
+          this.Invoke(d, new object[] { control, val });
+        }
+        catch (Exception) { }
+      }
+      else
+      {
+        control.Enabled = val;
+      }
+    }
+
+    delegate void SetControlTextCallback(Control control, string val);
+    public void SetControlText(Control control, string val)
+    {
+      if (control.InvokeRequired)
+      {
+        SetControlTextCallback d = new SetControlTextCallback(SetControlText);
+        try
+        {
+          this.Invoke(d, new object[] { control, val });
+        }
+        catch (Exception) { }
+      }
+      else
+      {
+        control.Text = val;
+      }
+    }
+
+    delegate void SetCheckboxCheckedCallback(CheckBox control, bool val);
+    public void SetCheckboxChecked(CheckBox control, bool val)
+    {
+      if (control.InvokeRequired)
+      {
+        SetCheckboxCheckedCallback d = new SetCheckboxCheckedCallback(SetCheckboxChecked);
+        try
+        {
+          this.Invoke(d, new object[] { control, val });
+        }
+        catch (Exception) { }
+      }
+      else
+      {
+        control.Checked = val;
+      }
+    }
+
+    delegate void SetProgressValueCallback(ProgressBar control, int val);
+    public void SetProgressValue(ProgressBar control, int val)
+    {
+      if (control.InvokeRequired)
+      {
+        SetProgressValueCallback d = new SetProgressValueCallback(SetProgressValue);
+        try
+        {
+          this.Invoke(d, new object[] { control, val });
+        }
+        catch (Exception) { }
+      }
+      else
+      {
+        control.Value = val;
+      }
+    }
+
+    delegate void SetComboBoxItemsCallback(ComboBox control, string selectedText, object[] val);
+    public void SetComboBoxItems(ComboBox control, string selectedText, object[] val)
+    {
+      if (control.InvokeRequired)
+      {
+        SetComboBoxItemsCallback d = new SetComboBoxItemsCallback(SetComboBoxItems);
+        try
+        {
+          this.Invoke(d, new object[] { control, selectedText, val });
+        }
+        catch (Exception) { }
+      }
+      else
+      {
+        control.Items.Clear();
+        control.Items.AddRange(val);
+        control.Text = selectedText;
+      }
+    }
+
+    delegate void SetControlVisibleCallback(Control control, bool val);
+    public void SetControlVisible(Control control, bool val)
+    {
+      if (control.InvokeRequired)
+      {
+        SetControlVisibleCallback d = new SetControlVisibleCallback(SetControlVisible);
+        try
+        {
+          this.Invoke(d, new object[] { control, val });
+        }
+        catch (Exception) { }
+      }
+      else
+      {
+        control.Visible = val;
+      }
+    }
+  }
+}
index 7225d42261c4ed72279fbdc928694dff9054bc31..c3d45e1470d969370356227c28827e66eb7ec758 100644 (file)
       this.components = new System.ComponentModel.Container();
       this.tabControl1 = new System.Windows.Forms.TabControl();
       this.Configuration = new System.Windows.Forms.TabPage();
+      this.lPowerOff = new System.Windows.Forms.Label();
+      this.cbPowerOffDevices = new System.Windows.Forms.CheckedListBox();
+      this.lWakeDevices = new System.Windows.Forms.Label();
+      this.cbWakeDevices = new System.Windows.Forms.CheckedListBox();
       this.cbPowerOffOnStandby = new System.Windows.Forms.CheckBox();
       this.cbPowerOffScreensaver = new System.Windows.Forms.CheckBox();
-      this.cbPowerOffShutdown = new System.Windows.Forms.CheckBox();
-      this.cbPowerOnStartup = new System.Windows.Forms.CheckBox();
+      this.cbActivateSource = new System.Windows.Forms.CheckBox();
       this.cbUseTVMenuLanguage = new System.Windows.Forms.CheckBox();
       this.lPlayerConfig = new System.Windows.Forms.Label();
       this.lAdapterConfig = new System.Windows.Forms.Label();
       this.lConnectedDevice = new System.Windows.Forms.Label();
       this.lPortNumber = new System.Windows.Forms.Label();
       this.tbButtons = new System.Windows.Forms.TabPage();
+      this.label1 = new System.Windows.Forms.Label();
       this.dgButtons = new System.Windows.Forms.DataGridView();
       this.CecButtonName = new System.Windows.Forms.DataGridViewTextBoxColumn();
+      this.playerButtonDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
+      this.cecButtonConfigBindingSource = new System.Windows.Forms.BindingSource(this.components);
       this.tbTestCommands = new System.Windows.Forms.TabPage();
       this.bMute = new System.Windows.Forms.Button();
       this.bVolDown = new System.Windows.Forms.Button();
       this.helpConnectedHDMIDevice = new System.Windows.Forms.ToolTip(this.components);
       this.helpPhysicalAddress = new System.Windows.Forms.ToolTip(this.components);
       this.helpDeviceType = new System.Windows.Forms.ToolTip(this.components);
-      this.label1 = new System.Windows.Forms.Label();
-      this.cbWakeDevices = new System.Windows.Forms.CheckedListBox();
-      this.lWakeDevices = new System.Windows.Forms.Label();
-      this.playerButtonDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
-      this.cecButtonConfigBindingSource = new System.Windows.Forms.BindingSource(this.components);
+      this.cbVendorId = new System.Windows.Forms.ComboBox();
+      this.cbVendorOverride = new System.Windows.Forms.CheckBox();
       this.tabControl1.SuspendLayout();
       this.Configuration.SuspendLayout();
       this.tbButtons.SuspendLayout();
       ((System.ComponentModel.ISupportInitialize)(this.dgButtons)).BeginInit();
+      ((System.ComponentModel.ISupportInitialize)(this.cecButtonConfigBindingSource)).BeginInit();
       this.tbTestCommands.SuspendLayout();
       this.LogOutput.SuspendLayout();
-      ((System.ComponentModel.ISupportInitialize)(this.cecButtonConfigBindingSource)).BeginInit();
       this.SuspendLayout();
       // 
       // tabControl1
       // 
       // Configuration
       // 
+      this.Configuration.Controls.Add(this.cbVendorOverride);
+      this.Configuration.Controls.Add(this.cbVendorId);
+      this.Configuration.Controls.Add(this.lPowerOff);
+      this.Configuration.Controls.Add(this.cbPowerOffDevices);
       this.Configuration.Controls.Add(this.lWakeDevices);
       this.Configuration.Controls.Add(this.cbWakeDevices);
       this.Configuration.Controls.Add(this.cbPowerOffOnStandby);
       this.Configuration.Controls.Add(this.cbPowerOffScreensaver);
-      this.Configuration.Controls.Add(this.cbPowerOffShutdown);
-      this.Configuration.Controls.Add(this.cbPowerOnStartup);
+      this.Configuration.Controls.Add(this.cbActivateSource);
       this.Configuration.Controls.Add(this.cbUseTVMenuLanguage);
       this.Configuration.Controls.Add(this.lPlayerConfig);
       this.Configuration.Controls.Add(this.lAdapterConfig);
       this.Configuration.Text = "Configuration";
       this.Configuration.UseVisualStyleBackColor = true;
       // 
+      // lPowerOff
+      // 
+      this.lPowerOff.AutoSize = true;
+      this.lPowerOff.Location = new System.Drawing.Point(465, 203);
+      this.lPowerOff.Name = "lPowerOff";
+      this.lPowerOff.Size = new System.Drawing.Size(124, 13);
+      this.lPowerOff.TabIndex = 26;
+      this.lPowerOff.Text = "Power off when stopping";
+      // 
+      // cbPowerOffDevices
+      // 
+      this.cbPowerOffDevices.FormattingEnabled = true;
+      this.cbPowerOffDevices.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.cbPowerOffDevices.Location = new System.Drawing.Point(467, 220);
+      this.cbPowerOffDevices.Name = "cbPowerOffDevices";
+      this.cbPowerOffDevices.Size = new System.Drawing.Size(118, 94);
+      this.cbPowerOffDevices.TabIndex = 25;
+      // 
+      // lWakeDevices
+      // 
+      this.lWakeDevices.AutoSize = true;
+      this.lWakeDevices.Location = new System.Drawing.Point(345, 203);
+      this.lWakeDevices.Name = "lWakeDevices";
+      this.lWakeDevices.Size = new System.Drawing.Size(102, 13);
+      this.lWakeDevices.TabIndex = 24;
+      this.lWakeDevices.Text = "Wake when starting";
+      // 
+      // cbWakeDevices
+      // 
+      this.cbWakeDevices.FormattingEnabled = true;
+      this.cbWakeDevices.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.cbWakeDevices.Location = new System.Drawing.Point(337, 220);
+      this.cbWakeDevices.Name = "cbWakeDevices";
+      this.cbWakeDevices.Size = new System.Drawing.Size(118, 94);
+      this.cbWakeDevices.TabIndex = 23;
+      // 
       // cbPowerOffOnStandby
       // 
       this.cbPowerOffOnStandby.AutoSize = true;
       this.cbPowerOffScreensaver.Text = "Put devices in standby mode when activating screensaver";
       this.cbPowerOffScreensaver.UseVisualStyleBackColor = true;
       // 
-      // cbPowerOffShutdown
+      // cbActivateSource
       // 
-      this.cbPowerOffShutdown.AutoSize = true;
-      this.cbPowerOffShutdown.Enabled = false;
-      this.cbPowerOffShutdown.Location = new System.Drawing.Point(10, 249);
-      this.cbPowerOffShutdown.Name = "cbPowerOffShutdown";
-      this.cbPowerOffShutdown.Size = new System.Drawing.Size(317, 17);
-      this.cbPowerOffShutdown.TabIndex = 20;
-      this.cbPowerOffShutdown.Text = "Power off devices when stopping the media player application";
-      this.cbPowerOffShutdown.UseVisualStyleBackColor = true;
-      // 
-      // cbPowerOnStartup
-      // 
-      this.cbPowerOnStartup.AutoSize = true;
-      this.cbPowerOnStartup.Enabled = false;
-      this.cbPowerOnStartup.Location = new System.Drawing.Point(10, 225);
-      this.cbPowerOnStartup.Name = "cbPowerOnStartup";
-      this.cbPowerOnStartup.Size = new System.Drawing.Size(306, 17);
-      this.cbPowerOnStartup.TabIndex = 19;
-      this.cbPowerOnStartup.Text = "Power on the TV when starting the media player application";
-      this.cbPowerOnStartup.UseVisualStyleBackColor = true;
+      this.cbActivateSource.AutoSize = true;
+      this.cbActivateSource.Enabled = false;
+      this.cbActivateSource.Location = new System.Drawing.Point(10, 249);
+      this.cbActivateSource.Name = "cbActivateSource";
+      this.cbActivateSource.Size = new System.Drawing.Size(284, 17);
+      this.cbActivateSource.TabIndex = 19;
+      this.cbActivateSource.Text = "Make the media player the active source when starting";
+      this.cbActivateSource.UseVisualStyleBackColor = true;
       // 
       // cbUseTVMenuLanguage
       // 
       this.cbUseTVMenuLanguage.AutoSize = true;
       this.cbUseTVMenuLanguage.Enabled = false;
-      this.cbUseTVMenuLanguage.Location = new System.Drawing.Point(10, 201);
+      this.cbUseTVMenuLanguage.Location = new System.Drawing.Point(10, 225);
       this.cbUseTVMenuLanguage.Name = "cbUseTVMenuLanguage";
       this.cbUseTVMenuLanguage.Size = new System.Drawing.Size(168, 17);
       this.cbUseTVMenuLanguage.TabIndex = 18;
       // 
       this.lPlayerConfig.AutoSize = true;
       this.lPlayerConfig.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
-      this.lPlayerConfig.Location = new System.Drawing.Point(6, 165);
+      this.lPlayerConfig.Location = new System.Drawing.Point(6, 188);
       this.lPlayerConfig.Name = "lPlayerConfig";
       this.lPlayerConfig.Size = new System.Drawing.Size(198, 24);
       this.lPlayerConfig.TabIndex = 16;
       this.tbButtons.Text = "Button Configuration";
       this.tbButtons.UseVisualStyleBackColor = true;
       // 
+      // label1
+      // 
+      this.label1.AutoSize = true;
+      this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+      this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(64)))), ((int)(((byte)(0)))));
+      this.label1.Location = new System.Drawing.Point(118, 252);
+      this.label1.Name = "label1";
+      this.label1.Size = new System.Drawing.Size(354, 31);
+      this.label1.TabIndex = 1;
+      this.label1.Text = "NOT IMPLEMENTED YET";
+      // 
       // dgButtons
       // 
       this.dgButtons.AllowUserToAddRows = false;
       this.CecButtonName.ReadOnly = true;
       this.CecButtonName.Width = 260;
       // 
+      // playerButtonDataGridViewTextBoxColumn
+      // 
+      this.playerButtonDataGridViewTextBoxColumn.DataPropertyName = "PlayerButton";
+      this.playerButtonDataGridViewTextBoxColumn.FillWeight = 260F;
+      this.playerButtonDataGridViewTextBoxColumn.HeaderText = "Mapped to";
+      this.playerButtonDataGridViewTextBoxColumn.Name = "playerButtonDataGridViewTextBoxColumn";
+      this.playerButtonDataGridViewTextBoxColumn.Width = 260;
+      // 
+      // cecButtonConfigBindingSource
+      // 
+      this.cecButtonConfigBindingSource.DataSource = typeof(CecConfigGui.CecButtonConfig);
+      // 
       // tbTestCommands
       // 
       this.tbTestCommands.Controls.Add(this.bMute);
       this.lStatus.TabIndex = 2;
       this.lStatus.Text = "Initialising...";
       // 
-      // label1
-      // 
-      this.label1.AutoSize = true;
-      this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(0)));
-      this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(64)))), ((int)(((byte)(0)))));
-      this.label1.Location = new System.Drawing.Point(118, 252);
-      this.label1.Name = "label1";
-      this.label1.Size = new System.Drawing.Size(354, 31);
-      this.label1.TabIndex = 1;
-      this.label1.Text = "NOT IMPLEMENTED YET";
-      // 
-      // cbWakeDevices
-      // 
-      this.cbWakeDevices.FormattingEnabled = true;
-      this.cbWakeDevices.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.cbWakeDevices.Location = new System.Drawing.Point(333, 218);
-      this.cbWakeDevices.Name = "cbWakeDevices";
-      this.cbWakeDevices.Size = new System.Drawing.Size(118, 94);
-      this.cbWakeDevices.TabIndex = 23;
-      // 
-      // lWakeDevices
-      // 
-      this.lWakeDevices.AutoSize = true;
-      this.lWakeDevices.Location = new System.Drawing.Point(339, 201);
-      this.lWakeDevices.Name = "lWakeDevices";
-      this.lWakeDevices.Size = new System.Drawing.Size(102, 13);
-      this.lWakeDevices.TabIndex = 24;
-      this.lWakeDevices.Text = "Wake when starting";
-      // 
-      // playerButtonDataGridViewTextBoxColumn
-      // 
-      this.playerButtonDataGridViewTextBoxColumn.DataPropertyName = "PlayerButton";
-      this.playerButtonDataGridViewTextBoxColumn.FillWeight = 260F;
-      this.playerButtonDataGridViewTextBoxColumn.HeaderText = "Mapped to";
-      this.playerButtonDataGridViewTextBoxColumn.Name = "playerButtonDataGridViewTextBoxColumn";
-      this.playerButtonDataGridViewTextBoxColumn.Width = 260;
-      // 
-      // cecButtonConfigBindingSource
-      // 
-      this.cecButtonConfigBindingSource.DataSource = typeof(CecConfigGui.CecButtonConfig);
+      // cbVendorId
+      // 
+      this.cbVendorId.Enabled = false;
+      this.cbVendorId.FormattingEnabled = true;
+      this.cbVendorId.Items.AddRange(new object[] {
+            "- autodetect -",
+            "LG",
+            "Onkyo",
+            "Panasonic",
+            "Philips",
+            "Pioneer",
+            "Samsung",
+            "Sony",
+            "Yamaha"});
+      this.cbVendorId.Location = new System.Drawing.Point(174, 153);
+      this.cbVendorId.Name = "cbVendorId";
+      this.cbVendorId.Size = new System.Drawing.Size(121, 21);
+      this.cbVendorId.TabIndex = 28;
+      this.cbVendorId.Text = "- autodetect -";
+      this.helpDeviceType.SetToolTip(this.cbVendorId, "Only set this value when autodetection isn\'t working");
+      // 
+      // cbVendorOverride
+      // 
+      this.cbVendorOverride.AutoSize = true;
+      this.cbVendorOverride.Location = new System.Drawing.Point(10, 156);
+      this.cbVendorOverride.Name = "cbVendorOverride";
+      this.cbVendorOverride.Size = new System.Drawing.Size(130, 17);
+      this.cbVendorOverride.TabIndex = 29;
+      this.cbVendorOverride.Text = "Override TV vendor id";
+      this.cbVendorOverride.UseVisualStyleBackColor = true;
       // 
       // CecConfigGUI
       // 
       this.tbButtons.ResumeLayout(false);
       this.tbButtons.PerformLayout();
       ((System.ComponentModel.ISupportInitialize)(this.dgButtons)).EndInit();
+      ((System.ComponentModel.ISupportInitialize)(this.cecButtonConfigBindingSource)).EndInit();
       this.tbTestCommands.ResumeLayout(false);
       this.tbTestCommands.PerformLayout();
       this.LogOutput.ResumeLayout(false);
       this.LogOutput.PerformLayout();
-      ((System.ComponentModel.ISupportInitialize)(this.cecButtonConfigBindingSource)).EndInit();
       this.ResumeLayout(false);
       this.PerformLayout();
 
     private System.Windows.Forms.Label lAdapterConfig;
     private System.Windows.Forms.CheckBox cbPowerOffOnStandby;
     private System.Windows.Forms.CheckBox cbPowerOffScreensaver;
-    private System.Windows.Forms.CheckBox cbPowerOffShutdown;
-    private System.Windows.Forms.CheckBox cbPowerOnStartup;
+    private System.Windows.Forms.CheckBox cbActivateSource;
     private System.Windows.Forms.CheckBox cbUseTVMenuLanguage;
     private System.Windows.Forms.Label lPlayerConfig;
     private System.Windows.Forms.ToolTip helpPortNumber;
     private System.Windows.Forms.Label label1;
     private System.Windows.Forms.Label lWakeDevices;
     private System.Windows.Forms.CheckedListBox cbWakeDevices;
+    private System.Windows.Forms.Label lPowerOff;
+    private System.Windows.Forms.CheckedListBox cbPowerOffDevices;
+    private System.Windows.Forms.CheckBox cbVendorOverride;
+    private System.Windows.Forms.ComboBox cbVendorId;
   }
 }
\ No newline at end of file
index e41c292be80901d16658a6f00ad4189a54cb2bc3..b1731cfa2c8dfdcae7bb92ece32b03fab0c9a482 100644 (file)
@@ -14,7 +14,7 @@ using System.Xml;
 
 namespace CecConfigGui
 {
-  public partial class CecConfigGUI : Form
+  public partial class CecConfigGUI : AsyncForm
   {
     public CecConfigGUI()
     {
@@ -91,6 +91,27 @@ namespace CecConfigGui
                         config.BaseDevice = (CecLogicalAddress)iDevice;
                     }
                     break;
+                  case "cec_power_on_startup":
+                    if (value.Equals("1") || value.ToLower().Equals("true") || value.ToLower().Equals("yes"))
+                    {
+                      config.ActivateSource = true;
+                      config.WakeDevices.Set(CecLogicalAddress.Tv);
+                    }
+                    break;
+                  case "cec_power_off_shutdown":
+                    if (value.Equals("1") || value.ToLower().Equals("true") || value.ToLower().Equals("yes"))
+                      config.PowerOffDevices.Set(CecLogicalAddress.Broadcast);
+                    break;
+                  case "cec_standby_screensaver":
+                    config.PowerOffScreensaver = value.Equals("1") || value.ToLower().Equals("true") || value.ToLower().Equals("yes");
+                    break;
+                  case "standby_pc_on_tv_standby":
+                    config.PowerOffOnStandby = value.Equals("1") || value.ToLower().Equals("true") || value.ToLower().Equals("yes");
+                    break;
+                  case "use_tv_menu_language":
+                    config.UseTVMenuLanguage = value.Equals("1") || value.ToLower().Equals("true") || value.ToLower().Equals("yes");
+                    break;
+                  // 1.5.0+ settings
                   case "physical_address":
                     {
                       ushort physicalAddress = 0;
@@ -105,20 +126,36 @@ namespace CecConfigGui
                         config.DeviceTypes.Types[0] = (CecDeviceType)iType;
                     }
                     break;
-                  case "cec_power_on_startup":
-                    config.PowerOnStartup = value.Equals("1") || value.ToLower().Equals("true") || value.ToLower().Equals("yes");
-                    break;
-                  case "cec_power_off_shutdown":
-                    config.PowerOffShutdown = value.Equals("1") || value.ToLower().Equals("true") || value.ToLower().Equals("yes");
-                    break;
-                  case "cec_standby_screensaver":
-                    config.PowerOffScreensaver = value.Equals("1") || value.ToLower().Equals("true") || value.ToLower().Equals("yes");
+                  case "tv_vendor":
+                    {
+                      UInt64 iVendor;
+                      if (UInt64.TryParse(value, out iVendor))
+                        config.TvVendor = (CecVendorId)iVendor;
+                    }
                     break;
-                  case "standby_pc_on_tv_standby":
-                    config.PowerOffOnStandby = value.Equals("1") || value.ToLower().Equals("true") || value.ToLower().Equals("yes");
+                  case "wake_devices":
+                    {
+                      config.WakeDevices.Clear();
+                      string[] split = value.Split(new char[] { ' ' });
+                      foreach (string dev in split)
+                      {
+                        byte iLogicalAddress;
+                        if (byte.TryParse(dev, out iLogicalAddress))
+                          config.WakeDevices.Set((CecLogicalAddress)iLogicalAddress);
+                      }
+                    }
                     break;
-                  case "use_tv_menu_language":
-                    config.UseTVMenuLanguage = value.Equals("1") || value.ToLower().Equals("true") || value.ToLower().Equals("yes");
+                  case "standby_devices":
+                    {
+                      config.PowerOffDevices.Clear();
+                      string[] split = value.Split(new char[] { ' ' });
+                      foreach (string dev in split)
+                      {
+                        byte iLogicalAddress;
+                        if (byte.TryParse(dev, out iLogicalAddress))
+                          config.PowerOffDevices.Set((CecLogicalAddress)iLogicalAddress);
+                      }
+                    }
                     break;
                   case "enabled":
                     break;
@@ -222,130 +259,113 @@ namespace CecConfigGui
       this.cecButtonConfigBindingSource.Add(new CecButtonConfigItem("(Samsung) Return", (new CecSharp.CecKeypress() { Keycode = 0x91 }), string.Empty));
     }
 
-    public int ConfigurationChanged(LibCECConfiguration config)
-    {
-      SetControlText(this.tbPhysicalAddress, String.Format("{0,4:X}", config.PhysicalAddress));
-      return 1;
-    }
-
-    public int ReceiveCommand(CecCommand command)
-    {
-      return 1;
-    }
-
-    public int ReceiveKeypress(CecKeypress key)
-    {
-      SelectKeypressRow(key);
-      return 1;
-    }
-
-    delegate void SelectKeypressRowCallback(CecKeypress key);
-    private void SelectKeypressRow(CecKeypress key)
+    private void ProcessEventHandler(object src, UpdateEvent updateEvent)
     {
-      if (dgButtons.InvokeRequired)
-      {
-        SelectKeypressRowCallback d = new SelectKeypressRowCallback(SelectKeypressRow);
-        try
-        {
-          this.Invoke(d, new object[] { key });
-        }
-        catch (Exception) { }
-      }
-      else
+      switch (updateEvent.Type)
       {
-        int rowIndex = -1;
-        foreach (DataGridViewRow row in dgButtons.Rows)
-        {
-          CecButtonConfigItem item = row.DataBoundItem as CecButtonConfigItem;
-          if (item != null && item.Key.Keycode == key.Keycode)
-          {
-            rowIndex = row.Index;
-            row.Selected = true;
-            item.Enabled = true;
-          }
-          else
+        case UpdateEventType.StatusText:
+          SetControlText(lStatus, updateEvent.StringValue);
+          break;
+        case UpdateEventType.PhysicalAddress:
+          Config.PhysicalAddress = (ushort)updateEvent.IntValue;
+          SetControlText(tbPhysicalAddress, string.Format("{0,4:X}", updateEvent.IntValue));
+          break;
+        case UpdateEventType.ProgressBar:
+          SetProgressValue(pProgress, updateEvent.IntValue);
+          break;
+        case UpdateEventType.TVVendorId:
+          TVVendor = (CecVendorId)updateEvent.IntValue;
+          UpdateSelectedDevice();
+          break;
+        case UpdateEventType.BaseDevicePhysicalAddress:
+          SetControlText(lConnectedPhysicalAddress, string.Format("Address: {0,4:X}", updateEvent.IntValue));
+          break;
+        case UpdateEventType.BaseDevice:
+          Config.BaseDevice = (CecLogicalAddress)updateEvent.IntValue;
+          break;
+        case UpdateEventType.HDMIPort:
+          Config.HDMIPort = (byte)updateEvent.IntValue;
+          break;
+        case UpdateEventType.MenuLanguage:
+          SetControlText(cbUseTVMenuLanguage, "Use the TV's language setting" + (updateEvent.StringValue.Length > 0 ? " (" + updateEvent.StringValue + ")" : ""));
+          break;
+        case UpdateEventType.HasAVRDevice:
+          if (HasAVRDevice != updateEvent.BoolValue)
           {
-            row.Selected = false;
+            HasAVRDevice = updateEvent.BoolValue;
+            UpdateSelectedDevice();
           }
-        }
-        if (rowIndex > -1)
-          dgButtons.FirstDisplayedScrollingRowIndex = rowIndex;
+          break;
+        case UpdateEventType.AVRVendorId:
+          AVRVendor = (CecVendorId)updateEvent.IntValue;
+          UpdateSelectedDevice();
+          break;
+        case UpdateEventType.Configuration:
+          SuppressUpdates = true;
+          ConfigurationChanged(updateEvent.ConfigValue);
+          SuppressUpdates = false;
+          break;
+        case UpdateEventType.ProcessCompleted:
+          ActiveProcess = null;
+          SetControlsEnabled(true);
+          break;
       }
     }
 
-    delegate void AddLogMessageCallback(CecLogMessage message);
-    private void AddLogMessage(CecLogMessage message)
+    public void SetPhysicalAddress(ushort physicalAddress)
     {
-      if (tbLog.InvokeRequired)
+      if (!SuppressUpdates && ActiveProcess == null)
       {
-        AddLogMessageCallback d = new AddLogMessageCallback(AddLogMessage);
-        try
-        {
-          this.Invoke(d, new object[] { message });
-        }
-        catch (Exception) { }
+        SetControlsEnabled(false);
+        SetControlText(cbPortNumber, string.Empty);
+        SetControlText(cbConnectedDevice, string.Empty);
+        ActiveProcess = new UpdatePhysicalAddress(ref Lib, physicalAddress);
+        ActiveProcess.EventHandler += new EventHandler<UpdateEvent>(ProcessEventHandler);
+        (new Thread(new ThreadStart(ActiveProcess.Run))).Start();
       }
-      else
-      {
-        string strLevel = "";
-        bool display = false;
-        switch (message.Level)
-        {
-          case CecLogLevel.Error:
-            strLevel = "ERROR:   ";
-            display = cbLogError.Checked;
-            break;
-          case CecLogLevel.Warning:
-            strLevel = "WARNING: ";
-            display = cbLogWarning.Checked;
-            break;
-          case CecLogLevel.Notice:
-            strLevel = "NOTICE:  ";
-            display = cbLogNotice.Checked;
-            break;
-          case CecLogLevel.Traffic:
-            strLevel = "TRAFFIC: ";
-            display = cbLogTraffic.Checked;
-            break;
-          case CecLogLevel.Debug:
-            strLevel = "DEBUG:   ";
-            display = cbLogDebug.Checked;
-            break;
-          default:
-            break;
-        }
+    }
 
-        if (display)
-        {
-          string strLog = string.Format("{0} {1,16} {2}", strLevel, message.Time, message.Message) + System.Environment.NewLine;
-          tbLog.Text += strLog;
-          tbLog.Select(tbLog.Text.Length, 0);
-          tbLog.ScrollToCaret();
-        }
+    public void SendImageViewOn(CecLogicalAddress address)
+    {
+      if (!SuppressUpdates && ActiveProcess == null)
+      {
+        SetControlsEnabled(false);
+        ActiveProcess = new SendImageViewOn(ref Lib, address);
+        ActiveProcess.EventHandler += new EventHandler<UpdateEvent>(ProcessEventHandler);
+        (new Thread(new ThreadStart(ActiveProcess.Run))).Start();
       }
     }
 
-    public int ReceiveLogMessage(CecLogMessage message)
+    public void ActivateSource(CecLogicalAddress address)
     {
-      AddLogMessage(message);
-      return 1;
+      if (!SuppressUpdates && ActiveProcess == null)
+      {
+        SetControlsEnabled(false);
+        ActiveProcess = new SendActivateSource(ref Lib, address);
+        ActiveProcess.EventHandler += new EventHandler<UpdateEvent>(ProcessEventHandler);
+        (new Thread(new ThreadStart(ActiveProcess.Run))).Start();
+      }
     }
 
-    delegate void SetControlEnabledCallback(Control control, bool val);
-    private void SetControlEnabled(Control control, bool val)
+    public void SendStandby(CecLogicalAddress address)
     {
-      if (control.InvokeRequired)
+      if (!SuppressUpdates && ActiveProcess == null)
       {
-        SetControlEnabledCallback d = new SetControlEnabledCallback(SetControlEnabled);
-        try
-        {
-          this.Invoke(d, new object[] { control, val });
-        }
-        catch (Exception) { }
+        SetControlsEnabled(false);
+        ActiveProcess = new SendStandby(ref Lib, address);
+        ActiveProcess.EventHandler += new EventHandler<UpdateEvent>(ProcessEventHandler);
+        (new Thread(new ThreadStart(ActiveProcess.Run))).Start();
       }
-      else
+    }
+
+    public void ShowDeviceInfo(CecLogicalAddress address)
+    {
+      if (!SuppressUpdates && ActiveProcess == null)
       {
-        control.Enabled = val;
+        SetControlsEnabled(false);
+        ActiveProcess = new ShowDeviceInfo(this, ref Lib, address);
+        ActiveProcess.EventHandler += new EventHandler<UpdateEvent>(ProcessEventHandler);
+        (new Thread(new ThreadStart(ActiveProcess.Run))).Start();
       }
     }
 
@@ -356,11 +376,13 @@ namespace CecConfigGui
       SetControlEnabled(tbPhysicalAddress, val);
       SetControlEnabled(cbDeviceType, false); // TODO not implemented yet
       SetControlEnabled(cbUseTVMenuLanguage, val);
-      SetControlEnabled(cbPowerOnStartup, val);
-      SetControlEnabled(cbPowerOffShutdown, val);
+      SetControlEnabled(cbActivateSource, val);
       SetControlEnabled(cbPowerOffScreensaver, val);
       SetControlEnabled(cbPowerOffOnStandby, val);
       SetControlEnabled(cbWakeDevices, false); // TODO not implemented yet
+      SetControlEnabled(cbPowerOffDevices, false); // TODO not implemented yet
+      SetControlEnabled(cbVendorOverride, false); // TODO not implemented yet
+      SetControlEnabled(cbVendorId, false); // TODO not implemented yet
       SetControlEnabled(bClose, val);
       SetControlEnabled(bSave, val);
 
@@ -375,196 +397,40 @@ namespace CecConfigGui
       SetControlEnabled(bMute, enableVolumeButtons);
     }
 
-    delegate void SetControlTextCallback(Control control, string val);
-    private void SetControlText(Control control, string val)
+    #region Configuration tab
+    private void tbPhysicalAddress_TextChanged(object sender, EventArgs e)
     {
-      if (control.InvokeRequired)
-      {
-        SetControlTextCallback d = new SetControlTextCallback(SetControlText);
-        try
-        {
-          this.Invoke(d, new object[] { control, val });
-        }
-        catch (Exception) { }
-      }
-      else
-      {
-        control.Text = val;
-      }
+      if (tbPhysicalAddress.Text.Length != 4)
+        return;
+      ushort physicalAddress = 0;
+      if (!ushort.TryParse(tbPhysicalAddress.Text, NumberStyles.AllowHexSpecifier, null, out physicalAddress))
+        return;
+
+      SetPhysicalAddress(physicalAddress);
     }
 
-    delegate void SetCheckboxCheckedCallback(CheckBox control, bool val);
-    private void SetCheckboxChecked(CheckBox control, bool val)
+    private void UpdateSelectedDevice()
     {
-      if (control.InvokeRequired)
-      {
-        SetCheckboxCheckedCallback d = new SetCheckboxCheckedCallback(SetCheckboxChecked);
-        try
-        {
-          this.Invoke(d, new object[] { control, val });
-        }
-        catch (Exception) { }
-      }
+      if (HasAVRDevice)
+        SetComboBoxItems(this.cbConnectedDevice, Config.BaseDevice == CecLogicalAddress.AudioSystem ? AVRVendorString : TVVendorString, new object[] { TVVendorString, AVRVendorString });
       else
-      {
-        control.Checked = val;
-      }
+        SetComboBoxItems(this.cbConnectedDevice, TVVendorString, new object[] { TVVendorString });
     }
 
-    delegate void SetProgressValueCallback(ProgressBar control, int val);
-    private void SetProgressValue(ProgressBar control, int val)
+    public void SetConnectedDevice(CecLogicalAddress address, int portnumber)
     {
-      if (control.InvokeRequired)
-      {
-        SetProgressValueCallback d = new SetProgressValueCallback(SetProgressValue);
-        try
-        {
-          this.Invoke(d, new object[] { control, val });
-        }
-        catch (Exception) { }
-      }
-      else
+      if (!SuppressUpdates && ActiveProcess == null)
       {
-        control.Value = val;
+        SetControlsEnabled(false);
+        ActiveProcess = new UpdateConnectedDevice(ref Lib, address, portnumber);
+        ActiveProcess.EventHandler += new EventHandler<UpdateEvent>(ProcessEventHandler);
+        (new Thread(new ThreadStart(ActiveProcess.Run))).Start();
       }
     }
 
-    delegate void SetComboBoxItemsCallback(ComboBox control, string selectedText, object[] val);
-    private void SetComboBoxItems(ComboBox control, string selectedText, object[] val)
+    private void connectedDevice_SelectedIndexChanged(object sender, EventArgs e)
     {
-      if (control.InvokeRequired)
-      {
-        SetComboBoxItemsCallback d = new SetComboBoxItemsCallback(SetComboBoxItems);
-        try
-        {
-          this.Invoke(d, new object[] { control, selectedText, val });
-        }
-        catch (Exception) { }
-      }
-      else
-      {
-        control.Items.Clear();
-        control.Items.AddRange(val);
-        control.Text = selectedText;
-      }
-    }
-
-    private void ProcessEventHandler(object src, UpdateEvent updateEvent)
-    {
-      switch (updateEvent.Type)
-      {
-        case UpdateEventType.StatusText:
-          SetControlText(lStatus, updateEvent.StringValue);
-          break;
-        case UpdateEventType.PhysicalAddress:
-          Config.PhysicalAddress = (ushort)updateEvent.IntValue;
-          SetControlText(tbPhysicalAddress, string.Format("{0,4:X}", updateEvent.IntValue));
-          break;
-        case UpdateEventType.ProgressBar:
-          SetProgressValue(pProgress, updateEvent.IntValue);
-          break;
-        case UpdateEventType.TVVendorId:
-          TVVendor = (CecVendorId)updateEvent.IntValue;
-          UpdateSelectedDevice();
-          break;
-        case UpdateEventType.BaseDevicePhysicalAddress:
-          SetControlText(lConnectedPhysicalAddress, string.Format("Address: {0,4:X}", updateEvent.IntValue));
-          break;
-        case UpdateEventType.BaseDevice:
-          Config.BaseDevice = (CecLogicalAddress)updateEvent.IntValue;
-          break;
-        case UpdateEventType.HDMIPort:
-          Config.HDMIPort = (byte)updateEvent.IntValue;
-          break;
-        case UpdateEventType.MenuLanguage:
-          SetControlText(cbUseTVMenuLanguage, "Use the TV's language setting" + (updateEvent.StringValue.Length > 0 ? " (" + updateEvent.StringValue + ")" : ""));
-          break;
-        case UpdateEventType.HasAVRDevice:
-          if (HasAVRDevice != updateEvent.BoolValue)
-          {
-            HasAVRDevice = updateEvent.BoolValue;
-            UpdateSelectedDevice();
-          }
-          break;
-        case UpdateEventType.AVRVendorId:
-          AVRVendor = (CecVendorId)updateEvent.IntValue;
-          UpdateSelectedDevice();
-          break;
-        case UpdateEventType.Configuration:
-          Config = updateEvent.ConfigValue;
-          SetControlText(tbPhysicalAddress, string.Format("{0,4:X}", Config.PhysicalAddress));
-          SetControlText(cbConnectedDevice, Config.BaseDevice == CecLogicalAddress.AudioSystem ? AVRVendorString : TVVendorString);
-          SetControlText(cbPortNumber, Config.HDMIPort.ToString());
-          SetCheckboxChecked(cbUseTVMenuLanguage, Config.UseTVMenuLanguage);
-          SetCheckboxChecked(cbPowerOnStartup, Config.PowerOnStartup);
-          SetCheckboxChecked(cbPowerOffShutdown, Config.PowerOffShutdown);
-          SetCheckboxChecked(cbPowerOffScreensaver, Config.PowerOffScreensaver);
-          SetCheckboxChecked(cbPowerOffOnStandby, Config.PowerOffOnStandby);
-          UpdateSelectedDevice();
-          break;
-        case UpdateEventType.ProcessCompleted:
-          ActiveProcess = null;
-          SetControlsEnabled(true);
-          break;
-      }
-    }
-
-    private void UpdateSelectedDevice()
-    {
-      if (HasAVRDevice)
-        SetComboBoxItems(this.cbConnectedDevice, Config.BaseDevice == CecLogicalAddress.AudioSystem ? AVRVendorString : TVVendorString, new object[] { TVVendorString, AVRVendorString });
-      else
-        SetComboBoxItems(this.cbConnectedDevice, TVVendorString, new object[] { TVVendorString });
-    }
-
-    public string TVVendorString
-    {
-      get
-      {
-        return TVVendor != CecVendorId.Unknown ?
-          "Television (" + Lib.ToString(TVVendor) + ")" :
-          "Television";
-      }
-    }
-
-    public string AVRVendorString
-    {
-      get
-      {
-        return AVRVendor != CecVendorId.Unknown ?
-          "AVR (" + Lib.ToString(AVRVendor) + ")" :
-          "AVR";
-      }
-    }
-
-    protected bool HasAVRDevice;
-    protected CecVendorId TVVendor = CecVendorId.Unknown;
-    protected CecVendorId AVRVendor = CecVendorId.Unknown;
-    protected CecLogicalAddress SelectedConnectedDevice = CecLogicalAddress.Unknown;
-
-    protected LibCECConfiguration Config;
-    protected LibCecSharp Lib;
-    private CecCallbackWrapper Callbacks;
-    private UpdateProcess ActiveProcess = null;
-
-    public void SetConnectedDevice(CecLogicalAddress address, int portnumber)
-    {
-      if (ActiveProcess == null)
-      {
-        SetControlsEnabled(false);
-        ActiveProcess = new UpdateConnectedDevice(ref Lib, address, portnumber);
-        ActiveProcess.EventHandler += new EventHandler<UpdateEvent>(ProcessEventHandler);
-        (new Thread(new ThreadStart(ActiveProcess.Run))).Start();
-      }
-    }
-
-    private void connectedDevice_SelectedIndexChanged(object sender, EventArgs e)
-    {
-      SelectedConnectedDevice = (this.cbConnectedDevice.Text.Equals(AVRVendorString)) ? CecLogicalAddress.AudioSystem : CecLogicalAddress.Tv;
-      int iPortNumber = 0;
-      if (!int.TryParse(cbPortNumber.Text, out iPortNumber))
-        iPortNumber = 1;
-      SetConnectedDevice(SelectedConnectedDevice, iPortNumber);
+      SetConnectedDevice(SelectedConnectedDevice, SelectedPortNumber);
     }
 
     private void bCancel_Click(object sender, EventArgs e)
@@ -577,8 +443,7 @@ namespace CecConfigGui
       SetControlsEnabled(false);
 
       Config.UseTVMenuLanguage = cbUseTVMenuLanguage.Checked;
-      Config.PowerOnStartup = cbPowerOnStartup.Checked;
-      Config.PowerOffShutdown = cbPowerOffShutdown.Checked;
+      Config.ActivateSource = cbActivateSource.Checked;
       Config.PowerOffScreensaver = cbPowerOffScreensaver.Checked;
       Config.PowerOffOnStandby = cbPowerOffOnStandby.Checked;
 
@@ -613,15 +478,31 @@ namespace CecConfigGui
               output.AppendLine("<settings>");
               output.AppendLine("<setting id=\"cec_hdmi_port\" value=\"" + Config.HDMIPort + "\" />");
               output.AppendLine("<setting id=\"connected_device\" value=\"" + (Config.BaseDevice == CecLogicalAddress.AudioSystem ? 5 : 1) + "\" />");
-              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=\"cec_power_on_startup\" value=\"" + (Config.PowerOnStartup ? 1 : 0) + "\" />");
-              output.AppendLine("<setting id=\"cec_power_off_shutdown\" value=\"" + (Config.PowerOffShutdown ? 1 : 0) + "\" />");
+              output.AppendLine("<setting id=\"cec_power_on_startup\" value=\"" + (Config.ActivateSource ? 1 : 0) + "\" />");
+              output.AppendLine("<setting id=\"cec_power_off_shutdown\" value=\"" + (Config.PowerOffDevices.IsSet(CecLogicalAddress.Broadcast) ? 1 : 0) + "\" />");
               output.AppendLine("<setting id=\"cec_standby_screensaver\" value=\"" + (Config.PowerOffScreensaver ? 1 : 0) + "\" />");
               output.AppendLine("<setting id=\"standby_pc_on_tv_standby\" value=\"" + (Config.PowerOffOnStandby ? 1 : 0) + "\" />");
               output.AppendLine("<setting id=\"use_tv_menu_language\" value=\"" + (Config.UseTVMenuLanguage ? 1 : 0) + "\" />");
               output.AppendLine("<setting id=\"enabled\" value=\"1\" />");
               output.AppendLine("<setting id=\"port\" value=\"\" />");
+
+              // only supported by 1.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) + "\" />");
+
+              output.Append("<setting id=\"wake_devices\" value=\"");
+              foreach (CecLogicalAddress addr in Config.WakeDevices.Addresses)
+                if (addr != CecLogicalAddress.Unregistered)
+                  output.Append(" " + addr);
+              output.AppendLine("\" />");
+
+              output.Append("<setting id=\"standby_devices\" value=\"");
+              foreach (CecLogicalAddress addr in Config.PowerOffDevices.Addresses)
+                if (addr != CecLogicalAddress.Unregistered)
+                  output.Append(" " + addr);
+              output.AppendLine("\" />");
+
               output.AppendLine("</settings>");
               writer.Write(output.ToString());
               writer.Close();
@@ -642,63 +523,40 @@ namespace CecConfigGui
       }
       SetControlsEnabled(true);
     }
+    #endregion
 
-    public void SetPhysicalAddress(ushort physicalAddress)
-    {
-      if (ActiveProcess == null)
-      {
-        SetControlsEnabled(false);
-        SetControlText(cbPortNumber, string.Empty);
-        SetControlText(cbConnectedDevice, string.Empty);
-        ActiveProcess = new UpdatePhysicalAddress(ref Lib, physicalAddress);
-        ActiveProcess.EventHandler += new EventHandler<UpdateEvent>(ProcessEventHandler);
-        (new Thread(new ThreadStart(ActiveProcess.Run))).Start();
-      }
-    }
-
-    private void tbPhysicalAddress_TextChanged(object sender, EventArgs e)
-    {
-      if (tbPhysicalAddress.Text.Length != 4)
-        return;
-      ushort physicalAddress = 0;
-      if (!ushort.TryParse(tbPhysicalAddress.Text, NumberStyles.AllowHexSpecifier, null, out physicalAddress))
-        return;
-
-      SetPhysicalAddress(physicalAddress);
-    }
-
-    private void bClearLog_Click(object sender, EventArgs e)
-    {
-      tbLog.Text = string.Empty;
-    }
-
-    private void bSaveLog_Click(object sender, EventArgs e)
+    #region Key configuration tab
+    delegate void SelectKeypressRowCallback(CecKeypress key);
+    private void SelectKeypressRow(CecKeypress key)
     {
-      SaveFileDialog dialog = new SaveFileDialog()
-      {
-        Title = "Where do you want to store the log file?",
-        InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
-        FileName = "cec-log.txt",
-        Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*",
-        FilterIndex = 1
-      };
-
-      if (dialog.ShowDialog() == DialogResult.OK)
+      if (dgButtons.InvokeRequired)
       {
-        FileStream fs = (FileStream)dialog.OpenFile();
-        if (fs == null)
+        SelectKeypressRowCallback d = new SelectKeypressRowCallback(SelectKeypressRow);
+        try
         {
-          MessageBox.Show("Cannot open '" + dialog.FileName + "' for writing", "Pulse-Eight USB-CEC Adapter", MessageBoxButtons.OK, MessageBoxIcon.Error);
+          this.Invoke(d, new object[] { key });
         }
-        else
+        catch (Exception) { }
+      }
+      else
+      {
+        int rowIndex = -1;
+        foreach (DataGridViewRow row in dgButtons.Rows)
         {
-          StreamWriter writer = new StreamWriter(fs);
-          writer.Write(tbLog.Text);
-          writer.Close();
-          fs.Close();
-          fs.Dispose();
-          MessageBox.Show("The log file was stored as '" + dialog.FileName + "'.", "Pulse-Eight USB-CEC Adapter", MessageBoxButtons.OK, MessageBoxIcon.Information);
+          CecButtonConfigItem item = row.DataBoundItem as CecButtonConfigItem;
+          if (item != null && item.Key.Keycode == key.Keycode)
+          {
+            rowIndex = row.Index;
+            row.Selected = true;
+            item.Enabled = true;
+          }
+          else
+          {
+            row.Selected = false;
+          }
         }
+        if (rowIndex > -1)
+          dgButtons.FirstDisplayedScrollingRowIndex = rowIndex;
       }
     }
 
@@ -709,7 +567,9 @@ namespace CecConfigGui
       if (data == null || !data.Enabled)
         e.CellStyle.ForeColor = Color.Gray;
     }
+    #endregion
 
+    #region CEC Tester tab
     delegate CecLogicalAddress GetTargetDeviceCallback();
     private CecLogicalAddress GetTargetDevice()
     {
@@ -764,65 +624,21 @@ namespace CecConfigGui
       }
     }
 
-    public void SendImageViewOn(CecLogicalAddress address)
-    {
-      if (ActiveProcess == null)
-      {
-        SetControlsEnabled(false);
-        ActiveProcess = new SendImageViewOn(ref Lib, address);
-        ActiveProcess.EventHandler += new EventHandler<UpdateEvent>(ProcessEventHandler);
-        (new Thread(new ThreadStart(ActiveProcess.Run))).Start();
-      }
-    }
-
     private void bSendImageViewOn_Click(object sender, EventArgs e)
     {
       SendImageViewOn(GetTargetDevice());
     }
 
-    public void SendStandby(CecLogicalAddress address)
-    {
-      if (ActiveProcess == null)
-      {
-        SetControlsEnabled(false);
-        ActiveProcess = new SendStandby(ref Lib, address);
-        ActiveProcess.EventHandler += new EventHandler<UpdateEvent>(ProcessEventHandler);
-        (new Thread(new ThreadStart(ActiveProcess.Run))).Start();
-      }
-    }
-
     private void bStandby_Click(object sender, EventArgs e)
     {
       SendStandby(GetTargetDevice());
     }
 
-    public void ShowDeviceInfo(CecLogicalAddress address)
-    {
-      if (ActiveProcess == null)
-      {
-        SetControlsEnabled(false);
-        ActiveProcess = new ShowDeviceInfo(this, ref Lib, address);
-        ActiveProcess.EventHandler += new EventHandler<UpdateEvent>(ProcessEventHandler);
-        (new Thread(new ThreadStart(ActiveProcess.Run))).Start();
-      }
-    }
-
     private void bScan_Click(object sender, EventArgs e)
     {
       ShowDeviceInfo(GetTargetDevice());
     }
 
-    public void ActivateSource(CecLogicalAddress address)
-    {
-      if (ActiveProcess == null)
-      {
-        SetControlsEnabled(false);
-        ActiveProcess = new SendActivateSource(ref Lib, address);
-        ActiveProcess.EventHandler += new EventHandler<UpdateEvent>(ProcessEventHandler);
-        (new Thread(new ThreadStart(ActiveProcess.Run))).Start();
-      }
-    }
-
     private void bActivateSource_Click(object sender, EventArgs e)
     {
       ActivateSource(GetTargetDevice());
@@ -856,8 +672,194 @@ namespace CecConfigGui
       Lib.MuteAudio(true);
       SetControlsEnabled(true);
     }
+    #endregion
+
+    #region Log tab
+    delegate void AddLogMessageCallback(CecLogMessage message);
+    private void AddLogMessage(CecLogMessage message)
+    {
+      if (tbLog.InvokeRequired)
+      {
+        AddLogMessageCallback d = new AddLogMessageCallback(AddLogMessage);
+        try
+        {
+          this.Invoke(d, new object[] { message });
+        }
+        catch (Exception) { }
+      }
+      else
+      {
+        string strLevel = "";
+        bool display = false;
+        switch (message.Level)
+        {
+          case CecLogLevel.Error:
+            strLevel = "ERROR:   ";
+            display = cbLogError.Checked;
+            break;
+          case CecLogLevel.Warning:
+            strLevel = "WARNING: ";
+            display = cbLogWarning.Checked;
+            break;
+          case CecLogLevel.Notice:
+            strLevel = "NOTICE:  ";
+            display = cbLogNotice.Checked;
+            break;
+          case CecLogLevel.Traffic:
+            strLevel = "TRAFFIC: ";
+            display = cbLogTraffic.Checked;
+            break;
+          case CecLogLevel.Debug:
+            strLevel = "DEBUG:   ";
+            display = cbLogDebug.Checked;
+            break;
+          default:
+            break;
+        }
+
+        if (display)
+        {
+          string strLog = string.Format("{0} {1,16} {2}", strLevel, message.Time, message.Message) + System.Environment.NewLine;
+          tbLog.Text += strLog;
+          tbLog.Select(tbLog.Text.Length, 0);
+          tbLog.ScrollToCaret();
+        }
+      }
+    }
+
+    private void bClearLog_Click(object sender, EventArgs e)
+    {
+      tbLog.Text = string.Empty;
+    }
+
+    private void bSaveLog_Click(object sender, EventArgs e)
+    {
+      SaveFileDialog dialog = new SaveFileDialog()
+      {
+        Title = "Where do you want to store the log file?",
+        InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments),
+        FileName = "cec-log.txt",
+        Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*",
+        FilterIndex = 1
+      };
+
+      if (dialog.ShowDialog() == DialogResult.OK)
+      {
+        FileStream fs = (FileStream)dialog.OpenFile();
+        if (fs == null)
+        {
+          MessageBox.Show("Cannot open '" + dialog.FileName + "' for writing", "Pulse-Eight USB-CEC Adapter", MessageBoxButtons.OK, MessageBoxIcon.Error);
+        }
+        else
+        {
+          StreamWriter writer = new StreamWriter(fs);
+          writer.Write(tbLog.Text);
+          writer.Close();
+          fs.Close();
+          fs.Dispose();
+          MessageBox.Show("The log file was stored as '" + dialog.FileName + "'.", "Pulse-Eight USB-CEC Adapter", MessageBoxButtons.OK, MessageBoxIcon.Information);
+        }
+      }
+    }
+    #endregion
+
+    #region LibCecSharp callbacks
+    public int ConfigurationChanged(LibCECConfiguration config)
+    {
+      Config = config;
+      SetControlText(tbPhysicalAddress, string.Format("{0,4:X}", Config.PhysicalAddress));
+      SetControlText(cbConnectedDevice, Config.BaseDevice == CecLogicalAddress.AudioSystem ? AVRVendorString : TVVendorString);
+      SetControlText(cbPortNumber, Config.HDMIPort.ToString());
+      SetCheckboxChecked(cbUseTVMenuLanguage, Config.UseTVMenuLanguage);
+      SetCheckboxChecked(cbActivateSource, Config.ActivateSource);
+      SetCheckboxChecked(cbPowerOffScreensaver, Config.PowerOffScreensaver);
+      SetCheckboxChecked(cbPowerOffOnStandby, Config.PowerOffOnStandby);
+      UpdateSelectedDevice();
+      return 1;
+    }
+
+    public int ReceiveCommand(CecCommand command)
+    {
+      return 1;
+    }
+
+    public int ReceiveKeypress(CecKeypress key)
+    {
+      SelectKeypressRow(key);
+      return 1;
+    }
+
+    public int ReceiveLogMessage(CecLogMessage message)
+    {
+      AddLogMessage(message);
+      return 1;
+    }
+    #endregion
+
+    #region Class members
+    public bool HasAVRDevice { get; private set; }
+    #region TV Vendor
+    private CecVendorId _tvVendor = CecVendorId.Unknown;
+    public CecVendorId TVVendor
+    {
+      get { return _tvVendor;}
+      private set { _tvVendor = value; }
+    }
+    public string TVVendorString
+    {
+      get
+      {
+        return TVVendor != CecVendorId.Unknown ?
+          "Television (" + Lib.ToString(TVVendor) + ")" :
+          "Television";
+      }
+    }
+    #endregion
+    #region AVR Vendor
+    private CecVendorId _avrVendor = CecVendorId.Unknown;
+    public CecVendorId AVRVendor
+    {
+      get { return _avrVendor; }
+      private set { _avrVendor = value; }
+    }
+    public string AVRVendorString
+    {
+      get
+      {
+        return AVRVendor != CecVendorId.Unknown ?
+          "AVR (" + Lib.ToString(AVRVendor) + ")" :
+          "AVR";
+      }
+    }
+    #endregion
+    public CecLogicalAddress SelectedConnectedDevice
+    {
+      get
+      {
+        return (cbConnectedDevice.Text.Equals(AVRVendorString)) ? CecLogicalAddress.AudioSystem : CecLogicalAddress.Tv;
+      }
+    }
+    public int SelectedPortNumber
+    {
+      get
+      {
+        int iPortNumber = 0;
+        if (!int.TryParse(cbPortNumber.Text, out iPortNumber))
+          iPortNumber = 1;
+        return iPortNumber;
+      }
+    }
+    protected LibCECConfiguration Config;
+    protected LibCecSharp Lib;
+    private CecCallbackWrapper Callbacks;
+    private UpdateProcess ActiveProcess = null;
+    private bool SuppressUpdates = false;
+    #endregion
   }
 
+  /// <summary>
+  /// A little wrapper that is needed because we already inherit form
+  /// </summary>
   internal class CecCallbackWrapper : CecCallbackMethods
   {
     public CecCallbackWrapper(CecConfigGUI gui)
index c49183f8df8c900ee5a656b5a800e313a5c373c7..b3aad3ea1adbbd1c7d15c91f6fac4522df093c5e 100644 (file)
   <metadata name="cecButtonConfigBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     <value>662, 17</value>
   </metadata>
+  <metadata name="CecButtonName.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="cecButtonConfigBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>662, 17</value>
+  </metadata>
+  <metadata name="helpPortNumber.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>17, 17</value>
+  </metadata>
+  <metadata name="helpConnectedHDMIDevice.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>160, 17</value>
+  </metadata>
+  <metadata name="helpPhysicalAddress.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>362, 17</value>
+  </metadata>
 </root>
\ No newline at end of file
index d340e4774f1805fed5c87bf1c9595827521e33bd..2900ab31e164187611e9db19fb4495fb7fb0f5a8 100644 (file)
@@ -9,7 +9,7 @@ using CecSharp;
 
 namespace CecConfigGui
 {
-  public partial class DeviceInformation : Form
+  public partial class DeviceInformation : AsyncForm
   {
     public DeviceInformation(CecConfigGUI gui, CecLogicalAddress address, ref LibCecSharp lib,
       bool devicePresent, CecVendorId vendor, bool isActiveSource, ushort physicalAddress,
@@ -34,42 +34,6 @@ namespace CecConfigGui
       this.Text = "Device: " + osdName;
     }
 
-    delegate void SetControlVisibleCallback(Control control, bool val);
-    private void SetControlVisible(Control control, bool val)
-    {
-      if (control.InvokeRequired)
-      {
-        SetControlVisibleCallback d = new SetControlVisibleCallback(SetControlVisible);
-        try
-        {
-          this.Invoke(d, new object[] { control, val });
-        }
-        catch (Exception) { }
-      }
-      else
-      {
-        control.Visible = val;
-      }
-    }
-
-    delegate void SetControlTextCallback(Control control, string val);
-    private void SetControlText(Control control, string val)
-    {
-      if (control.InvokeRequired)
-      {
-        SetControlTextCallback d = new SetControlTextCallback(SetControlText);
-        try
-        {
-          this.Invoke(d, new object[] { control, val });
-        }
-        catch (Exception) { }
-      }
-      else
-      {
-        control.Text = val;
-      }
-    }
-
     private void lInactiveSource_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
     {
       SetControlVisible(lInactiveSource, false);
@@ -77,7 +41,6 @@ namespace CecConfigGui
       Gui.ActivateSource(Address);
     }
 
-
     private void lStandby_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
     {
       LinkLabel label = sender as LinkLabel;
index 4b83aaac6a6dd129af6286eaf53645b0f0e19f72..3594a16bd7c37cc27c138d5cff02f3f49638293c 100644 (file)
@@ -61,6 +61,9 @@
     <Compile Include="actions\ShowDeviceInfo.cs" />
     <Compile Include="actions\UpdateConnectedDevice.cs" />
     <Compile Include="actions\UpdatePhysicalAddress.cs" />
+    <Compile Include="AsyncForm.cs">
+      <SubType>Form</SubType>
+    </Compile>
     <Compile Include="CecButtonConfig.cs" />
     <Compile Include="CecConfigGUI.cs">
       <SubType>Form</SubType>