cec-config-gui: make the progress bar invisible when done. disable the physical addre...
authorLars Op den Kamp <lars@opdenkamp.eu>
Thu, 16 Feb 2012 09:08:13 +0000 (10:08 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Thu, 16 Feb 2012 09:08:13 +0000 (10:08 +0100)
src/cec-config-gui/CecConfigGUI.Designer.cs
src/cec-config-gui/CecConfigGUI.cs
src/cec-config-gui/actions/ConnectToDevice.cs
src/cec-config-gui/actions/UpdateConnectedDevice.cs

index ca42375490083b0e5cf6a77a38ab1633343a67f2..a48c772dd4ce368bc7e6b968eaa433cbee29c6b6 100644 (file)
@@ -7,19 +7,6 @@
     /// </summary>
     private System.ComponentModel.IContainer components = null;
 
-    /// <summary>
-    /// Clean up any resources being used.
-    /// </summary>
-    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
-    protected override void Dispose(bool disposing)
-    {
-      if (disposing && (components != null))
-      {
-        components.Dispose();
-      }
-      base.Dispose(disposing);
-    }
-
     #region Windows Form Designer generated code
 
     /// <summary>
       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.cbDeviceType = new System.Windows.Forms.ComboBox();
       this.bClose = new System.Windows.Forms.Button();
       this.bSaveConfig = new System.Windows.Forms.Button();
       this.cbPortNumber = new System.Windows.Forms.ComboBox();
-      this.lConnectedPhysicalAddress = new System.Windows.Forms.Label();
       this.tbPhysicalAddress = new System.Windows.Forms.TextBox();
       this.cbConnectedDevice = new System.Windows.Forms.ComboBox();
       this.lDeviceType = new System.Windows.Forms.Label();
@@ -88,6 +73,8 @@
       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.lConnectedPhysicalAddress = new System.Windows.Forms.Label();
+      this.lAdapterConfig = new System.Windows.Forms.Label();
       this.tabControl1.SuspendLayout();
       this.Configuration.SuspendLayout();
       this.tbButtons.SuspendLayout();
       // cbVendorOverride
       // 
       this.cbVendorOverride.AutoSize = true;
+      this.cbVendorOverride.Enabled = false;
       this.cbVendorOverride.Location = new System.Drawing.Point(10, 156);
       this.cbVendorOverride.Name = "cbVendorOverride";
       this.cbVendorOverride.Size = new System.Drawing.Size(130, 17);
             "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.Size = new System.Drawing.Size(157, 21);
       this.cbVendorId.TabIndex = 28;
       this.cbVendorId.Text = "- autodetect -";
       this.helpDeviceType.SetToolTip(this.cbVendorId, "Only set this value when autodetection isn\'t working");
       this.lPlayerConfig.TabIndex = 16;
       this.lPlayerConfig.Text = "Player Configuration";
       // 
-      // lAdapterConfig
-      // 
-      this.lAdapterConfig.AutoSize = true;
-      this.lAdapterConfig.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
-      this.lAdapterConfig.Location = new System.Drawing.Point(6, 3);
-      this.lAdapterConfig.Name = "lAdapterConfig";
-      this.lAdapterConfig.Size = new System.Drawing.Size(213, 24);
-      this.lAdapterConfig.TabIndex = 15;
-      this.lAdapterConfig.Text = "Adapter Configuration";
-      // 
       // cbDeviceType
       // 
       this.cbDeviceType.Enabled = false;
             "Tuner"});
       this.cbDeviceType.Location = new System.Drawing.Point(174, 123);
       this.cbDeviceType.Name = "cbDeviceType";
-      this.cbDeviceType.Size = new System.Drawing.Size(121, 21);
+      this.cbDeviceType.Size = new System.Drawing.Size(157, 21);
       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.helpPortNumber.SetToolTip(this.cbPortNumber, "The HDMI port number, to which you connected your USB-CEC adapter.");
       this.cbPortNumber.SelectedIndexChanged += new System.EventHandler(this.connectedDevice_SelectedIndexChanged);
       // 
-      // lConnectedPhysicalAddress
-      // 
-      this.lConnectedPhysicalAddress.AutoSize = true;
-      this.lConnectedPhysicalAddress.Location = new System.Drawing.Point(310, 70);
-      this.lConnectedPhysicalAddress.Name = "lConnectedPhysicalAddress";
-      this.lConnectedPhysicalAddress.Size = new System.Drawing.Size(75, 13);
-      this.lConnectedPhysicalAddress.TabIndex = 10;
-      this.lConnectedPhysicalAddress.Text = "Address: 0000";
-      // 
       // tbPhysicalAddress
       // 
       this.tbPhysicalAddress.Enabled = false;
       this.cbConnectedDevice.FormattingEnabled = true;
       this.cbConnectedDevice.Location = new System.Drawing.Point(174, 67);
       this.cbConnectedDevice.Name = "cbConnectedDevice";
-      this.cbConnectedDevice.Size = new System.Drawing.Size(121, 21);
+      this.cbConnectedDevice.Size = new System.Drawing.Size(157, 21);
       this.cbConnectedDevice.TabIndex = 5;
       this.helpConnectedHDMIDevice.SetToolTip(this.cbConnectedDevice, "The HDMI device to which the USB-CEC adapter is connected");
       this.cbConnectedDevice.SelectedIndexChanged += new System.EventHandler(this.connectedDevice_SelectedIndexChanged);
       this.lStatus.TabIndex = 2;
       this.lStatus.Text = "Initialising...";
       // 
+      // lConnectedPhysicalAddress
+      // 
+      this.lConnectedPhysicalAddress.AutoSize = true;
+      this.lConnectedPhysicalAddress.Location = new System.Drawing.Point(340, 71);
+      this.lConnectedPhysicalAddress.Name = "lConnectedPhysicalAddress";
+      this.lConnectedPhysicalAddress.Size = new System.Drawing.Size(75, 13);
+      this.lConnectedPhysicalAddress.TabIndex = 10;
+      this.lConnectedPhysicalAddress.Text = "Address: 0000";
+      // 
+      // lAdapterConfig
+      // 
+      this.lAdapterConfig.AutoSize = true;
+      this.lAdapterConfig.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+      this.lAdapterConfig.Location = new System.Drawing.Point(6, 3);
+      this.lAdapterConfig.Name = "lAdapterConfig";
+      this.lAdapterConfig.Size = new System.Drawing.Size(213, 24);
+      this.lAdapterConfig.TabIndex = 15;
+      this.lAdapterConfig.Text = "Adapter Configuration";
+      // 
       // CecConfigGUI
       // 
       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     private System.Windows.Forms.TextBox tbPhysicalAddress;
     private System.Windows.Forms.ProgressBar pProgress;
     private System.Windows.Forms.Label lStatus;
-    private System.Windows.Forms.Label lConnectedPhysicalAddress;
     private System.Windows.Forms.TextBox tbLog;
     private System.Windows.Forms.ComboBox cbPortNumber;
     private System.Windows.Forms.Button bClose;
     private System.Windows.Forms.Button bSaveConfig;
     private System.Windows.Forms.ComboBox cbDeviceType;
-    private System.Windows.Forms.Label lAdapterConfig;
     private System.Windows.Forms.CheckBox cbPowerOffOnStandby;
     private System.Windows.Forms.CheckBox cbPowerOffScreensaver;
     private System.Windows.Forms.CheckBox cbActivateSource;
     private System.Windows.Forms.ComboBox cbVendorId;
     private System.Windows.Forms.Button bReloadConfig;
     private System.Windows.Forms.Button bRescanDevices;
+    private System.Windows.Forms.Label lConnectedPhysicalAddress;
+    private System.Windows.Forms.Label lAdapterConfig;
   }
 }
\ No newline at end of file
index 80b4e6ef530f5986f5e148dd497318cdf22190cf..4f84b2cf2f22de0005c37e87d98ce5b5c5f56cf3 100644 (file)
@@ -271,6 +271,7 @@ namespace CecConfigGui
           SetControlText(tbPhysicalAddress, string.Format("{0,4:X}", updateEvent.IntValue));
           break;
         case UpdateEventType.ProgressBar:
+          SetControlVisible(pProgress, true);
           SetProgressValue(pProgress, updateEvent.IntValue);
           break;
         case UpdateEventType.TVVendorId:
@@ -316,15 +317,16 @@ namespace CecConfigGui
             UpdatingInfoPanel.SetControlEnabled(UpdatingInfoPanel.bUpdate, true);
             UpdatingInfoPanel = null;
           }
+          SetControlVisible(pProgress, false);
           break;
       }
     }
 
     private void SetControlsEnabled(bool val)
     {
-      SetControlEnabled(cbPortNumber, val);
-      SetControlEnabled(cbConnectedDevice, cbConnectedDevice.Items.Count > 1 ? val : false);
-      SetControlEnabled(tbPhysicalAddress, val);
+      SetControlEnabled(cbPortNumber, val && !Config.AutodetectAddress);
+      SetControlEnabled(cbConnectedDevice, cbConnectedDevice.Items.Count > 1 && !Config.AutodetectAddress ? val : false);
+      SetControlEnabled(tbPhysicalAddress, val && !Config.AutodetectAddress);
       SetControlEnabled(cbDeviceType, val);
       SetControlEnabled(cbUseTVMenuLanguage, val);
       SetControlEnabled(cbActivateSource, val);
@@ -373,6 +375,21 @@ namespace CecConfigGui
       }
     }
 
+    protected override void Dispose(bool disposing)
+    {
+      if (disposing)
+      {
+        Lib.DisableCallbacks();
+        Lib.StandbyDevices(CecLogicalAddress.Broadcast);
+        Lib.Close();
+      }
+      if (disposing && (components != null))
+      {
+        components.Dispose();
+      }
+      base.Dispose(disposing);
+    }
+
     #region Actions
     public void ReloadXMLConfiguration()
     {
index 43d786eccf1df168f9751e447f539c0583e98882..128223f94ec01a919b8f11f37b295bc1f300ef8b 100644 (file)
@@ -24,15 +24,19 @@ namespace CecConfigGui.actions
         Application.Exit();
       }
 
-      SendEvent(UpdateEventType.StatusText, "Detecting TV vendor...");
       SendEvent(UpdateEventType.ProgressBar, 20);
+      SendEvent(UpdateEventType.StatusText, "Sending power on commands...");
+      Lib.PowerOnDevices(CecLogicalAddress.Broadcast);
+
+      SendEvent(UpdateEventType.StatusText, "Detecting TV vendor...");
+      SendEvent(UpdateEventType.ProgressBar, 30);
       SendEvent(UpdateEventType.TVVendorId, (int)Lib.GetDeviceVendorId(CecLogicalAddress.Tv));
 
       SendEvent(UpdateEventType.StatusText, "Detecting menu language...");
-      SendEvent(UpdateEventType.ProgressBar, 30);
+      SendEvent(UpdateEventType.ProgressBar, 40);
       SendEvent(UpdateEventType.MenuLanguage, Lib.GetDeviceMenuLanguage(CecLogicalAddress.Tv));
 
-      SendEvent(UpdateEventType.ProgressBar, 40);
+      SendEvent(UpdateEventType.ProgressBar, 50);
       SendEvent(UpdateEventType.StatusText, "Detecting AVR devices...");
 
       bool hasAVRDevice = Lib.IsActiveDevice(CecLogicalAddress.AudioSystem);
@@ -40,25 +44,25 @@ namespace CecConfigGui.actions
 
       if (hasAVRDevice)
       {
-        SendEvent(UpdateEventType.ProgressBar, 50);
+        SendEvent(UpdateEventType.ProgressBar, 60);
         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, 60);
+        SendEvent(UpdateEventType.ProgressBar, 70);
         SendEvent(UpdateEventType.StatusText, "Activating the source...");
         Lib.SetActiveSource(CecDeviceType.Reserved);
       }
 
-      SendEvent(UpdateEventType.ProgressBar, 70);
+      SendEvent(UpdateEventType.ProgressBar, 80);
       SendEvent(UpdateEventType.StatusText, "Reading device configuration...");
 
       Lib.GetCurrentConfiguration(Config);
       SendEvent(Config);
 
-      SendEvent(UpdateEventType.ProgressBar, 80);
+      SendEvent(UpdateEventType.ProgressBar, 90);
       SendEvent(UpdateEventType.StatusText, "Polling active devices");
       SendEvent(UpdateEventType.PollDevices);
 
index 46e9f0c3846ccae89a4374e4b20ba2e6f61beab9..c91358ebbc9ca2dea206b2be1b942cfe7c27a198 100644 (file)
@@ -42,9 +42,7 @@ namespace CecConfigGui.actions
         SendEvent(UpdateEventType.ProgressBar, 75);
         Lib.GetCurrentConfiguration(config);
 
-        SendEvent(UpdateEventType.PhysicalAddress, config.PhysicalAddress);
-        SendEvent(UpdateEventType.BaseDevice, (int)config.BaseDevice);
-        SendEvent(UpdateEventType.HDMIPort, config.HDMIPort);
+        SendEvent(config);
         SendEvent(UpdateEventType.StatusText, "Ready.");
       }
       SendEvent(UpdateEventType.ProgressBar, 100);