X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcec-config-gui%2FCecConfigGUI.cs;h=b8c2b54fa68ca7031ef3b410c72639a63f9e732c;hb=ece1582ec85912aebc8f87c0dca015ae62b29331;hp=a75f6c4e0590dd8e340466ba0584fa2501fbb5bd;hpb=96fa7764c1af5034afaba2646831df0a74419249;p=deb_libcec.git diff --git a/src/cec-config-gui/CecConfigGUI.cs b/src/cec-config-gui/CecConfigGUI.cs index a75f6c4..b8c2b54 100644 --- a/src/cec-config-gui/CecConfigGUI.cs +++ b/src/cec-config-gui/CecConfigGUI.cs @@ -224,6 +224,16 @@ namespace CecConfigGui public int ReceiveCommand(CecCommand command) { + bool bGetNewPhysicalAddress = false; + if (command.Opcode == CecOpcode.ReportPhysicalAddress) + bGetNewPhysicalAddress = true; + + if (bGetNewPhysicalAddress) + { + LibCECConfiguration config = new LibCECConfiguration(); + Lib.GetCurrentConfiguration(config); + SetControlText(this.tbPhysicalAddress, String.Format("{0,4:X}", config.PhysicalAddress)); + } return 1; } @@ -348,14 +358,25 @@ namespace CecConfigGui SetControlEnabled(cbPortNumber, val); SetControlEnabled(cbConnectedDevice, cbConnectedDevice.Items.Count > 1 ? val : false); SetControlEnabled(tbPhysicalAddress, val); - SetControlEnabled(cbDeviceType, val); + SetControlEnabled(cbDeviceType, false); // TODO not implemented yet SetControlEnabled(cbUseTVMenuLanguage, val); SetControlEnabled(cbPowerOnStartup, val); SetControlEnabled(cbPowerOffShutdown, val); SetControlEnabled(cbPowerOffScreensaver, val); SetControlEnabled(cbPowerOffOnStandby, val); + SetControlEnabled(cbWakeDevices, false); // TODO not implemented yet SetControlEnabled(bClose, val); SetControlEnabled(bSave, val); + + SetControlEnabled(bSendImageViewOn, val); + SetControlEnabled(bStandby, val); + SetControlEnabled(bActivateSource, val); + SetControlEnabled(bScan, val); + + bool enableVolumeButtons = (GetTargetDevice() == CecLogicalAddress.AudioSystem) && val; + SetControlEnabled(bVolUp, enableVolumeButtons); + SetControlEnabled(bVolDown, enableVolumeButtons); + SetControlEnabled(bMute, enableVolumeButtons); } delegate void SetControlTextCallback(Control control, string val); @@ -530,21 +551,26 @@ namespace CecConfigGui private CecCallbackWrapper Callbacks; private UpdateProcess ActiveProcess = null; - private void connectedDevice_SelectedIndexChanged(object sender, EventArgs e) + public void SetConnectedDevice(CecLogicalAddress address, int portnumber) { if (ActiveProcess == null) { SetControlsEnabled(false); - SelectedConnectedDevice = (this.cbConnectedDevice.Text.Equals(AVRVendorString)) ? CecLogicalAddress.AudioSystem : CecLogicalAddress.Tv; - int iPortNumber = 0; - if (!int.TryParse(cbPortNumber.Text, out iPortNumber)) - iPortNumber = 1; - ActiveProcess = new UpdateConnectedDevice(ref Lib, cbConnectedDevice.Text.Equals(AVRVendorString) ? CecLogicalAddress.AudioSystem : CecLogicalAddress.Tv, iPortNumber); + ActiveProcess = new UpdateConnectedDevice(ref Lib, address, portnumber); ActiveProcess.EventHandler += new EventHandler(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); + } + private void bCancel_Click(object sender, EventArgs e) { this.Dispose(); @@ -621,15 +647,10 @@ namespace CecConfigGui SetControlsEnabled(true); } - private void tbPhysicalAddress_TextChanged(object sender, EventArgs e) + public void SetPhysicalAddress(ushort physicalAddress) { if (ActiveProcess == null) { - if (tbPhysicalAddress.Text.Length != 4) - return; - ushort physicalAddress = 0; - if (!ushort.TryParse(tbPhysicalAddress.Text, NumberStyles.AllowHexSpecifier, null, out physicalAddress)) - return; SetControlsEnabled(false); SetControlText(cbPortNumber, string.Empty); SetControlText(cbConnectedDevice, string.Empty); @@ -639,6 +660,17 @@ namespace CecConfigGui } } + 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; @@ -682,8 +714,21 @@ namespace CecConfigGui e.CellStyle.ForeColor = Color.Gray; } + delegate CecLogicalAddress GetTargetDeviceCallback(); private CecLogicalAddress GetTargetDevice() { + if (this.cbCommandDestination.InvokeRequired) + { + GetTargetDeviceCallback d = new GetTargetDeviceCallback(GetTargetDevice); + CecLogicalAddress retval = CecLogicalAddress.Unknown; + try + { + retval = (CecLogicalAddress)this.Invoke(d, new object[] { }); + } + catch (Exception) { } + return retval; + } + switch (this.cbCommandDestination.Text.Substring(0, 1).ToLower()) { case "0": @@ -723,49 +768,98 @@ namespace CecConfigGui } } - private void bSendImageViewOn_Click(object sender, EventArgs e) + public void SendImageViewOn(CecLogicalAddress address) { if (ActiveProcess == null) { SetControlsEnabled(false); - ActiveProcess = new SendImageViewOn(ref Lib, GetTargetDevice()); + ActiveProcess = new SendImageViewOn(ref Lib, address); ActiveProcess.EventHandler += new EventHandler(ProcessEventHandler); (new Thread(new ThreadStart(ActiveProcess.Run))).Start(); } } - private void bStandby_Click(object sender, EventArgs e) + 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, GetTargetDevice()); + ActiveProcess = new SendStandby(ref Lib, address); ActiveProcess.EventHandler += new EventHandler(ProcessEventHandler); (new Thread(new ThreadStart(ActiveProcess.Run))).Start(); } } - private void bScan_Click(object sender, EventArgs e) + private void bStandby_Click(object sender, EventArgs e) + { + SendStandby(GetTargetDevice()); + } + + public void ShowDeviceInfo(CecLogicalAddress address) { if (ActiveProcess == null) { SetControlsEnabled(false); - ActiveProcess = new ShowDeviceInfo(ref Lib, GetTargetDevice()); + ActiveProcess = new ShowDeviceInfo(this, ref Lib, address); ActiveProcess.EventHandler += new EventHandler(ProcessEventHandler); (new Thread(new ThreadStart(ActiveProcess.Run))).Start(); } } - private void bActivateSource_Click(object sender, EventArgs e) + 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, GetTargetDevice()); + ActiveProcess = new SendActivateSource(ref Lib, address); ActiveProcess.EventHandler += new EventHandler(ProcessEventHandler); (new Thread(new ThreadStart(ActiveProcess.Run))).Start(); } } + + private void bActivateSource_Click(object sender, EventArgs e) + { + ActivateSource(GetTargetDevice()); + } + + private void cbCommandDestination_SelectedIndexChanged(object sender, EventArgs e) + { + bool enableVolumeButtons = (GetTargetDevice() == CecLogicalAddress.AudioSystem); + this.bVolUp.Enabled = enableVolumeButtons; + this.bVolDown.Enabled = enableVolumeButtons; + this.bMute.Enabled = enableVolumeButtons; + } + + private void bVolUp_Click(object sender, EventArgs e) + { + SetControlsEnabled(false); + Lib.VolumeUp(true); + SetControlsEnabled(true); + } + + private void bVolDown_Click(object sender, EventArgs e) + { + SetControlsEnabled(false); + Lib.VolumeDown(true); + SetControlsEnabled(true); + } + + private void bMute_Click(object sender, EventArgs e) + { + SetControlsEnabled(false); + Lib.MuteAudio(true); + SetControlsEnabled(true); + } } internal class CecCallbackWrapper : CecCallbackMethods