LibCecSharp: more cosmetics
[deb_libcec.git] / src / cec-config-gui / DeviceInformation.cs
CommitLineData
96fa7764 1using System;
96fa7764
LOK
2using System.Windows.Forms;
3using CecSharp;
4
5namespace CecConfigGui
6{
75af24f1 7 public partial class DeviceInformation : AsyncForm
96fa7764 8 {
ece1582e 9 public DeviceInformation(CecConfigGUI gui, CecLogicalAddress address, ref LibCecSharp lib,
96fa7764
LOK
10 bool devicePresent, CecVendorId vendor, bool isActiveSource, ushort physicalAddress,
11 CecVersion version, CecPowerStatus power, string osdName, string menuLanguage)
12 {
ece1582e
LOK
13 Gui = gui;
14 Lib = lib;
15 Address = address;
96fa7764 16 InitializeComponent();
a42ad439
LOK
17 lDevice.Text = lib.ToString(address);
18 lLogicalAddress.Text = String.Format("{0,1:X}", (int)address);
6d866874
LOK
19 Update(devicePresent, vendor, isActiveSource, physicalAddress, version, power, osdName, menuLanguage);
20 }
21
22 public void Update(bool devicePresent, CecVendorId vendor, bool isActiveSource, ushort physicalAddress,
23 CecVersion version, CecPowerStatus power, string osdName, string menuLanguage)
24 {
25 SetControlText(lPhysicalAddress, String.Format("{0,4:X}", physicalAddress));
26 SetControlText(lDevicePresent, devicePresent ? "yes" : "no");
27 SetControlVisible(lActiveSource, isActiveSource);
28 SetControlVisible(lInactiveSource, !isActiveSource);
29 SetControlText(lVendor, vendor != CecVendorId.Unknown ? Lib.ToString(vendor) : "unknown");
30 SetControlText(lCecVersion, Lib.ToString(version));
31 SetControlText(lPowerStatus, Lib.ToString(power));
32 SetControlText(lOsdName, osdName);
33 SetControlText(lMenuLanguage, menuLanguage);
34 SetControlText(this, "Device: " + osdName);
96fa7764 35 }
ece1582e 36
ece1582e
LOK
37 private void lInactiveSource_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
38 {
39 SetControlVisible(lInactiveSource, false);
40 SetControlVisible(lActiveSource, true);
41 Gui.ActivateSource(Address);
42 }
43
ece1582e
LOK
44 private void lStandby_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
45 {
46 LinkLabel label = sender as LinkLabel;
47 bool sendPowerOn = label.Text != Lib.ToString(CecPowerStatus.InTransitionStandbyToOn) &&
48 label.Text != Lib.ToString(CecPowerStatus.On);
49
50 SetControlText(lPowerStatus, Lib.ToString(sendPowerOn ? CecPowerStatus.On : CecPowerStatus.Standby));
51 if (sendPowerOn)
52 Gui.SendImageViewOn(Address);
53 else
54 Gui.SendStandby(Address);
55 }
56
6d866874
LOK
57
58 private void button1_Click(object sender, EventArgs e)
59 {
60 Gui.UpdateInfoPanel(this);
61 }
62
63 public CecLogicalAddress Address
64 {
65 private set;
66 get;
67 }
ece1582e
LOK
68 private CecConfigGUI Gui;
69 private LibCecSharp Lib;
96fa7764
LOK
70 }
71}