From 68b94c34ec2f7de6cd5db434e50242f3ebf8f65a Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Thu, 16 Feb 2012 10:08:13 +0100 Subject: [PATCH] cec-config-gui: make the progress bar invisible when done. disable the physical address/hdmi port settings when the address is autodetected. --- src/cec-config-gui/CecConfigGUI.Designer.cs | 66 ++++++++----------- src/cec-config-gui/CecConfigGUI.cs | 23 ++++++- src/cec-config-gui/actions/ConnectToDevice.cs | 18 +++-- .../actions/UpdateConnectedDevice.cs | 4 +- 4 files changed, 59 insertions(+), 52 deletions(-) diff --git a/src/cec-config-gui/CecConfigGUI.Designer.cs b/src/cec-config-gui/CecConfigGUI.Designer.cs index ca42375..a48c772 100644 --- a/src/cec-config-gui/CecConfigGUI.Designer.cs +++ b/src/cec-config-gui/CecConfigGUI.Designer.cs @@ -7,19 +7,6 @@ /// private System.ComponentModel.IContainer components = null; - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - #region Windows Form Designer generated code /// @@ -44,12 +31,10 @@ 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(); @@ -158,6 +145,7 @@ // 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); @@ -182,7 +170,7 @@ "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"); @@ -311,16 +299,6 @@ 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; @@ -331,7 +309,7 @@ "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\'"); @@ -377,15 +355,6 @@ 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; @@ -406,7 +375,7 @@ 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); @@ -764,6 +733,25 @@ 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); @@ -806,13 +794,11 @@ 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; @@ -853,5 +839,7 @@ 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 diff --git a/src/cec-config-gui/CecConfigGUI.cs b/src/cec-config-gui/CecConfigGUI.cs index 80b4e6e..4f84b2c 100644 --- a/src/cec-config-gui/CecConfigGUI.cs +++ b/src/cec-config-gui/CecConfigGUI.cs @@ -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() { diff --git a/src/cec-config-gui/actions/ConnectToDevice.cs b/src/cec-config-gui/actions/ConnectToDevice.cs index 43d786e..128223f 100644 --- a/src/cec-config-gui/actions/ConnectToDevice.cs +++ b/src/cec-config-gui/actions/ConnectToDevice.cs @@ -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); diff --git a/src/cec-config-gui/actions/UpdateConnectedDevice.cs b/src/cec-config-gui/actions/UpdateConnectedDevice.cs index 46e9f0c..c91358e 100644 --- a/src/cec-config-gui/actions/UpdateConnectedDevice.cs +++ b/src/cec-config-gui/actions/UpdateConnectedDevice.cs @@ -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); -- 2.34.1