2 using System.Collections.Generic;
3 using System.ComponentModel;
7 using System.Windows.Forms;
10 namespace CecConfigGui
12 public partial class DeviceInformation : Form
14 public DeviceInformation(CecConfigGUI gui, CecLogicalAddress address, ref LibCecSharp lib,
15 bool devicePresent, CecVendorId vendor, bool isActiveSource, ushort physicalAddress,
16 CecVersion version, CecPowerStatus power, string osdName, string menuLanguage)
21 InitializeComponent();
22 this.lDevice.Text = lib.ToString(address);
23 this.lLogicalAddress.Text = String.Format("{0,1:X}", (int)address);
24 this.lPhysicalAddress.Text = String.Format("{0,4:X}", physicalAddress);
25 this.lDevicePresent.Text = devicePresent ? "yes" : "no";
26 this.lActiveSource.Visible = isActiveSource;
27 this.lInactiveSource.Visible = !isActiveSource;
28 this.lVendor.Text = vendor != CecVendorId.Unknown ? lib.ToString(vendor) : "unknown";
29 this.lCecVersion.Text = lib.ToString(version);
30 this.lPowerStatus.Text = lib.ToString(power);
31 bool isPoweredOn = (power == CecPowerStatus.On || power == CecPowerStatus.InTransitionStandbyToOn);
32 this.lOsdName.Text = osdName;
33 this.lMenuLanguage.Text = menuLanguage;
34 this.Text = "Device: " + osdName;
37 delegate void SetControlVisibleCallback(Control control, bool val);
38 private void SetControlVisible(Control control, bool val)
40 if (control.InvokeRequired)
42 SetControlVisibleCallback d = new SetControlVisibleCallback(SetControlVisible);
45 this.Invoke(d, new object[] { control, val });
51 control.Visible = val;
55 delegate void SetControlTextCallback(Control control, string val);
56 private void SetControlText(Control control, string val)
58 if (control.InvokeRequired)
60 SetControlTextCallback d = new SetControlTextCallback(SetControlText);
63 this.Invoke(d, new object[] { control, val });
73 private void lInactiveSource_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
75 SetControlVisible(lInactiveSource, false);
76 SetControlVisible(lActiveSource, true);
77 Gui.ActivateSource(Address);
81 private void lStandby_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
83 LinkLabel label = sender as LinkLabel;
84 bool sendPowerOn = label.Text != Lib.ToString(CecPowerStatus.InTransitionStandbyToOn) &&
85 label.Text != Lib.ToString(CecPowerStatus.On);
87 SetControlText(lPowerStatus, Lib.ToString(sendPowerOn ? CecPowerStatus.On : CecPowerStatus.Standby));
89 Gui.SendImageViewOn(Address);
91 Gui.SendStandby(Address);
94 private CecLogicalAddress Address;
95 private CecConfigGUI Gui;
96 private LibCecSharp Lib;