From: Lars Op den Kamp Date: Sun, 19 Feb 2012 00:59:30 +0000 (+0100) Subject: cec-config-gui: make overriding the physical address optional X-Git-Tag: upstream/2.2.0~1^2~35^2~3 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=66609663d93f48b37fa79647e339ab48a70f73d8;p=deb_libcec.git cec-config-gui: make overriding the physical address optional --- diff --git a/src/cec-config-gui/CecConfigGUI.Designer.cs b/src/cec-config-gui/CecConfigGUI.Designer.cs index a48c772..d45e6d3 100644 --- a/src/cec-config-gui/CecConfigGUI.Designer.cs +++ b/src/cec-config-gui/CecConfigGUI.Designer.cs @@ -31,21 +31,21 @@ 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(); - this.lPhysicalAddress = 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.bRescanDevices = new System.Windows.Forms.Button(); @@ -73,8 +73,7 @@ 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.cbOverrideAddress = new System.Windows.Forms.CheckBox(); this.tabControl1.SuspendLayout(); this.Configuration.SuspendLayout(); this.tbButtons.SuspendLayout(); @@ -99,6 +98,7 @@ // // Configuration // + this.Configuration.Controls.Add(this.cbOverrideAddress); this.Configuration.Controls.Add(this.bReloadConfig); this.Configuration.Controls.Add(this.cbVendorOverride); this.Configuration.Controls.Add(this.cbVendorId); @@ -120,7 +120,6 @@ this.Configuration.Controls.Add(this.tbPhysicalAddress); this.Configuration.Controls.Add(this.cbConnectedDevice); this.Configuration.Controls.Add(this.lDeviceType); - this.Configuration.Controls.Add(this.lPhysicalAddress); this.Configuration.Controls.Add(this.lConnectedDevice); this.Configuration.Controls.Add(this.lPortNumber); this.Configuration.Location = new System.Drawing.Point(4, 22); @@ -299,6 +298,16 @@ 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; @@ -355,6 +364,15 @@ 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(340, 71); + 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; @@ -389,15 +407,6 @@ this.lDeviceType.TabIndex = 3; this.lDeviceType.Text = "Device type"; // - // lPhysicalAddress - // - this.lPhysicalAddress.AutoSize = true; - this.lPhysicalAddress.Location = new System.Drawing.Point(6, 98); - this.lPhysicalAddress.Name = "lPhysicalAddress"; - this.lPhysicalAddress.Size = new System.Drawing.Size(86, 13); - this.lPhysicalAddress.TabIndex = 2; - this.lPhysicalAddress.Text = "Physical address"; - // // lConnectedDevice // this.lConnectedDevice.AutoSize = true; @@ -448,8 +457,7 @@ this.dgButtons.AutoGenerateColumns = false; this.dgButtons.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dgButtons.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { - this.CecButtonName, - this.playerButtonDataGridViewTextBoxColumn}); + this.CecButtonName}); this.dgButtons.DataSource = this.cecButtonConfigBindingSource; this.dgButtons.Location = new System.Drawing.Point(7, 7); this.dgButtons.Name = "dgButtons"; @@ -467,14 +475,6 @@ 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); @@ -733,24 +733,17 @@ 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 + // cbOverrideAddress // - 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"; + this.cbOverrideAddress.AutoSize = true; + this.cbOverrideAddress.Enabled = false; + this.cbOverrideAddress.Location = new System.Drawing.Point(10, 97); + this.cbOverrideAddress.Name = "cbOverrideAddress"; + this.cbOverrideAddress.Size = new System.Drawing.Size(147, 17); + this.cbOverrideAddress.TabIndex = 31; + this.cbOverrideAddress.Text = "Override physical address"; + this.cbOverrideAddress.UseVisualStyleBackColor = true; + this.cbOverrideAddress.CheckedChanged += new System.EventHandler(this.cbOverrideAddress_CheckedChanged); // // CecConfigGUI // @@ -788,7 +781,6 @@ private System.Windows.Forms.TabPage LogOutput; private System.Windows.Forms.Label lPortNumber; private System.Windows.Forms.Label lDeviceType; - private System.Windows.Forms.Label lPhysicalAddress; private System.Windows.Forms.Label lConnectedDevice; private System.Windows.Forms.ComboBox cbConnectedDevice; private System.Windows.Forms.TextBox tbPhysicalAddress; @@ -841,5 +833,6 @@ private System.Windows.Forms.Button bRescanDevices; private System.Windows.Forms.Label lConnectedPhysicalAddress; private System.Windows.Forms.Label lAdapterConfig; + private System.Windows.Forms.CheckBox cbOverrideAddress; } } \ No newline at end of file diff --git a/src/cec-config-gui/CecConfigGUI.cs b/src/cec-config-gui/CecConfigGUI.cs index 06e6601..5004e04 100644 --- a/src/cec-config-gui/CecConfigGUI.cs +++ b/src/cec-config-gui/CecConfigGUI.cs @@ -326,7 +326,8 @@ namespace CecConfigGui { SetControlEnabled(cbPortNumber, val && !Config.AutodetectAddress); SetControlEnabled(cbConnectedDevice, cbConnectedDevice.Items.Count > 1 && !Config.AutodetectAddress ? val : false); - SetControlEnabled(tbPhysicalAddress, val && !Config.AutodetectAddress); + SetControlEnabled(cbOverrideAddress, val); + SetControlEnabled(tbPhysicalAddress, val && !Config.AutodetectAddress && cbOverrideAddress.Checked); SetControlEnabled(cbDeviceType, val); SetControlEnabled(cbUseTVMenuLanguage, val); SetControlEnabled(cbActivateSource, val); @@ -413,7 +414,7 @@ namespace CecConfigGui public void SetPhysicalAddress(ushort physicalAddress) { - if (!SuppressUpdates && ActiveProcess == null) + if (!SuppressUpdates && ActiveProcess == null && cbOverrideAddress.Checked) { SetControlsEnabled(false); SetControlText(cbPortNumber, string.Empty); @@ -481,9 +482,15 @@ namespace CecConfigGui #endregion #region Configuration tab + private void cbOverrideAddress_CheckedChanged(object sender, EventArgs e) + { + SetControlEnabled(tbPhysicalAddress, ((CheckBox)sender).Checked); + } + private void tbPhysicalAddress_TextChanged(object sender, EventArgs e) { - if (tbPhysicalAddress.Text.Length != 4) + if (tbPhysicalAddress.Text.Length != 4 || + cbOverrideAddress.Checked) return; ushort physicalAddress = 0; if (!ushort.TryParse(tbPhysicalAddress.Text, NumberStyles.AllowHexSpecifier, null, out physicalAddress)) @@ -583,20 +590,24 @@ namespace CecConfigGui // only supported by 1.5.0+ clients output.AppendLine(""); output.AppendLine(""); - output.AppendLine(""); + output.AppendLine(""); output.AppendLine(""); output.AppendLine(""); output.Append(""); output.Append(""); output.AppendLine("");