X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcec-config-gui%2FCecConfigGUI.cs;h=e3b1a0607742f3383c07c4ffa2cd73fc3f793331;hb=c9549d3519b254239eac22685ea22d81ffa00761;hp=2bafae814b45e2867bf1240781791f29f0afdca3;hpb=6d866874c4acb7620caea7a4415357bbf56f1a62;p=deb_libcec.git diff --git a/src/cec-config-gui/CecConfigGUI.cs b/src/cec-config-gui/CecConfigGUI.cs index 2bafae8..e3b1a06 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,22 +317,23 @@ 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); SetControlEnabled(cbPowerOffScreensaver, val); SetControlEnabled(cbPowerOffOnStandby, val); - SetControlEnabled(cbWakeDevices, false); // TODO not implemented yet - SetControlEnabled(cbPowerOffDevices, false); // TODO not implemented yet + SetControlEnabled(cbWakeDevices, val); + SetControlEnabled(cbPowerOffDevices, val); SetControlEnabled(cbVendorOverride, val); SetControlEnabled(cbVendorId, val && cbVendorOverride.Checked); SetControlEnabled(bClose, 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() { @@ -512,6 +529,8 @@ namespace CecConfigGui Config.ActivateSource = cbActivateSource.Checked; Config.PowerOffScreensaver = cbPowerOffScreensaver.Checked; Config.PowerOffOnStandby = cbPowerOffOnStandby.Checked; + Config.WakeDevices = WakeDevices; + Config.PowerOffDevices = PowerOffDevices; if (!Lib.CanPersistConfiguration()) { @@ -563,20 +582,21 @@ 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(""); @@ -722,7 +742,7 @@ namespace CecConfigGui List deviceList = new List(); foreach (CecLogicalAddress activeDevice in activeDevices.Addresses) { - if (activeDevice != CecLogicalAddress.Unregistered) + if (activeDevice != CecLogicalAddress.Unknown) deviceList.Add(string.Format("{0,1:X} : {1}", (int)activeDevice, Lib.ToString(activeDevice))); } deviceList.Add(string.Format("{0,1:X} : {1}", (int)CecLogicalAddress.Broadcast, Lib.ToString(CecLogicalAddress.Broadcast))); @@ -765,7 +785,12 @@ namespace CecConfigGui return retval; } - switch (this.cbCommandDestination.Text.Substring(0, 1).ToLower()) + return GetLogicalAddressFromString(this.cbCommandDestination.Text); + } + + private CecLogicalAddress GetLogicalAddressFromString(string name) + { + switch (name.Substring(0, 1).ToLower()) { case "0": return CecLogicalAddress.Tv; @@ -860,7 +885,7 @@ namespace CecConfigGui if (!SuppressUpdates && ActiveProcess == null) { SetControlsEnabled(false); - ActiveProcess = new RescanDevices(); + ActiveProcess = new RescanDevices(ref Lib); ActiveProcess.EventHandler += new EventHandler(ProcessEventHandler); (new Thread(new ThreadStart(ActiveProcess.Run))).Start(); } @@ -1003,6 +1028,13 @@ namespace CecConfigGui SetCheckboxChecked(cbPowerOffScreensaver, Config.PowerOffScreensaver); SetCheckboxChecked(cbPowerOffOnStandby, Config.PowerOffOnStandby); UpdateSelectedDevice(); + + for (int iPtr = 0; iPtr < 15; iPtr++) + SetCheckboxItemChecked(cbWakeDevices, iPtr, Config.WakeDevices.IsSet((CecLogicalAddress)iPtr)); + for (int iPtr = 0; iPtr < 15; iPtr++) + SetCheckboxItemChecked(cbPowerOffDevices, iPtr, Config.PowerOffDevices.IsSet((CecLogicalAddress)iPtr)); + + SetControlText(this, "Pulse-Eight USB-CEC Adapter - libCEC " + Lib.ToString(Config.ServerVersion)); return 1; } @@ -1019,7 +1051,11 @@ namespace CecConfigGui public int ReceiveLogMessage(CecLogMessage message) { - AddLogMessage(message); + try + { + AddLogMessage(message); + } + catch (Exception) { } return 1; } #endregion @@ -1101,6 +1137,32 @@ namespace CecConfigGui private string Log = string.Empty; private DeviceInformation UpdatingInfoPanel = null; private bool DeviceChangeWarningDisplayed = false; + public CecLogicalAddresses WakeDevices + { + get + { + CecLogicalAddresses addr = new CecLogicalAddresses(); + foreach (object item in this.cbWakeDevices.CheckedItems) + { + string c = item as string; + addr.Set(GetLogicalAddressFromString(c)); + } + return addr; + } + } + public CecLogicalAddresses PowerOffDevices + { + get + { + CecLogicalAddresses addr = new CecLogicalAddresses(); + foreach (object item in this.cbPowerOffDevices.CheckedItems) + { + string c = item as string; + addr.Set(GetLogicalAddressFromString(c)); + } + return addr; + } + } #endregion }