X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Fcec-config-gui%2FDeviceInformation.cs;h=f7992e3ef68e2fe11cb5872da187380dee61a77d;hb=d3b96c620e8bf4235d0ccee29d5b8e76dcdd86b6;hp=9d9b983a158bd0ae3ead618754caa539029fb456;hpb=96fa7764c1af5034afaba2646831df0a74419249;p=deb_libcec.git diff --git a/src/cec-config-gui/DeviceInformation.cs b/src/cec-config-gui/DeviceInformation.cs index 9d9b983..f7992e3 100644 --- a/src/cec-config-gui/DeviceInformation.cs +++ b/src/cec-config-gui/DeviceInformation.cs @@ -1,31 +1,71 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; using System.Windows.Forms; using CecSharp; namespace CecConfigGui { - public partial class DeviceInformation : Form + public partial class DeviceInformation : AsyncForm { - public DeviceInformation(CecLogicalAddress address, ref LibCecSharp lib, + public DeviceInformation(CecConfigGUI gui, CecLogicalAddress address, ref LibCecSharp lib, bool devicePresent, CecVendorId vendor, bool isActiveSource, ushort physicalAddress, CecVersion version, CecPowerStatus power, string osdName, string menuLanguage) { + Gui = gui; + Lib = lib; + Address = address; InitializeComponent(); - this.lDevice.Text = lib.ToString(address); - this.lLogicalAddress.Text = "#" + (int)address; - this.lPhysicalAddress.Text = physicalAddress.ToString(); - this.lDevicePresent.Text = devicePresent ? "yes" : "no"; - this.lActiveSource.Text = isActiveSource ? "yes" : "no"; - this.lVendor.Text = lib.ToString(vendor) + " (" + (UInt64)vendor +")"; - this.lCecVersion.Text = lib.ToString(version); - this.lPowerStatus.Text = lib.ToString(power); - this.lOsdName.Text = osdName; - this.lMenuLanguage.Text = menuLanguage; + lDevice.Text = lib.ToString(address); + lLogicalAddress.Text = String.Format("{0,1:X}", (int)address); + Update(devicePresent, vendor, isActiveSource, physicalAddress, version, power, osdName, menuLanguage); } + + public void Update(bool devicePresent, CecVendorId vendor, bool isActiveSource, ushort physicalAddress, + CecVersion version, CecPowerStatus power, string osdName, string menuLanguage) + { + 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) + { + SetControlVisible(lInactiveSource, false); + SetControlVisible(lActiveSource, true); + Gui.ActivateSource(Address); + } + + private void lStandby_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + LinkLabel label = sender as LinkLabel; + bool sendPowerOn = label.Text != Lib.ToString(CecPowerStatus.InTransitionStandbyToOn) && + label.Text != Lib.ToString(CecPowerStatus.On); + + SetControlText(lPowerStatus, Lib.ToString(sendPowerOn ? CecPowerStatus.On : CecPowerStatus.Standby)); + if (sendPowerOn) + Gui.SendImageViewOn(Address); + else + Gui.SendStandby(Address); + } + + + private void button1_Click(object sender, EventArgs e) + { + Gui.UpdateInfoPanel(this); + } + + public CecLogicalAddress Address + { + private set; + get; + } + private CecConfigGUI Gui; + private LibCecSharp Lib; } }