X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcec-config-gui%2FDeviceInformation.cs;h=0743e9ed655905b6784b1c7b7da93b6b875f08e1;hb=c9549d3519b254239eac22685ea22d81ffa00761;hp=d340e4774f1805fed5c87bf1c9595827521e33bd;hpb=ece1582ec85912aebc8f87c0dca015ae62b29331;p=deb_libcec.git diff --git a/src/cec-config-gui/DeviceInformation.cs b/src/cec-config-gui/DeviceInformation.cs index d340e47..0743e9e 100644 --- a/src/cec-config-gui/DeviceInformation.cs +++ b/src/cec-config-gui/DeviceInformation.cs @@ -9,7 +9,7 @@ using CecSharp; namespace CecConfigGui { - public partial class DeviceInformation : Form + public partial class DeviceInformation : AsyncForm { public DeviceInformation(CecConfigGUI gui, CecLogicalAddress address, ref LibCecSharp lib, bool devicePresent, CecVendorId vendor, bool isActiveSource, ushort physicalAddress, @@ -21,53 +21,22 @@ namespace CecConfigGui InitializeComponent(); this.lDevice.Text = lib.ToString(address); this.lLogicalAddress.Text = String.Format("{0,1:X}", (int)address); - this.lPhysicalAddress.Text = String.Format("{0,4:X}", physicalAddress); - this.lDevicePresent.Text = devicePresent ? "yes" : "no"; - this.lActiveSource.Visible = isActiveSource; - this.lInactiveSource.Visible = !isActiveSource; - this.lVendor.Text = vendor != CecVendorId.Unknown ? lib.ToString(vendor) : "unknown"; - this.lCecVersion.Text = lib.ToString(version); - this.lPowerStatus.Text = lib.ToString(power); - bool isPoweredOn = (power == CecPowerStatus.On || power == CecPowerStatus.InTransitionStandbyToOn); - this.lOsdName.Text = osdName; - this.lMenuLanguage.Text = menuLanguage; - this.Text = "Device: " + osdName; + Update(devicePresent, vendor, isActiveSource, physicalAddress, version, power, osdName, menuLanguage); } - delegate void SetControlVisibleCallback(Control control, bool val); - private void SetControlVisible(Control control, bool val) - { - if (control.InvokeRequired) - { - SetControlVisibleCallback d = new SetControlVisibleCallback(SetControlVisible); - try - { - this.Invoke(d, new object[] { control, val }); - } - catch (Exception) { } - } - else - { - control.Visible = val; - } - } - - delegate void SetControlTextCallback(Control control, string val); - private void SetControlText(Control control, string val) + public void Update(bool devicePresent, CecVendorId vendor, bool isActiveSource, ushort physicalAddress, + CecVersion version, CecPowerStatus power, string osdName, string menuLanguage) { - if (control.InvokeRequired) - { - SetControlTextCallback d = new SetControlTextCallback(SetControlText); - try - { - this.Invoke(d, new object[] { control, val }); - } - catch (Exception) { } - } - else - { - control.Text = val; - } + SetControlText(lPhysicalAddress, String.Format("{0,4:X}", physicalAddress)); + SetControlText(lDevicePresent, devicePresent ? "yes" : "no"); + SetControlVisible(lActiveSource, isActiveSource); + SetControlVisible(lInactiveSource, !isActiveSource); + SetControlText(lVendor, vendor != CecVendorId.Unknown ? Lib.ToString(vendor) : "unknown"); + SetControlText(lCecVersion, Lib.ToString(version)); + SetControlText(lPowerStatus, Lib.ToString(power)); + SetControlText(lOsdName, osdName); + SetControlText(lMenuLanguage, menuLanguage); + SetControlText(this, "Device: " + osdName); } private void lInactiveSource_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) @@ -77,7 +46,6 @@ namespace CecConfigGui Gui.ActivateSource(Address); } - private void lStandby_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { LinkLabel label = sender as LinkLabel; @@ -91,7 +59,17 @@ namespace CecConfigGui Gui.SendStandby(Address); } - private CecLogicalAddress Address; + + private void button1_Click(object sender, EventArgs e) + { + Gui.UpdateInfoPanel(this); + } + + public CecLogicalAddress Address + { + private set; + get; + } private CecConfigGUI Gui; private LibCecSharp Lib; }