cec: moved the timed ping to a separate thread. bugzid: 654
[deb_libcec.git] / src / cec-config-gui / DeviceInformation.cs
1 using System;
2 using System.Windows.Forms;
3 using CecSharp;
4
5 namespace CecConfigGui
6 {
7 public partial class DeviceInformation : AsyncForm
8 {
9 public DeviceInformation(CecConfigGUI gui, CecLogicalAddress address, ref LibCecSharp lib,
10 bool devicePresent, CecVendorId vendor, bool isActiveSource, ushort physicalAddress,
11 CecVersion version, CecPowerStatus power, string osdName, string menuLanguage)
12 {
13 Gui = gui;
14 Lib = lib;
15 Address = address;
16 InitializeComponent();
17 lDevice.Text = lib.ToString(address);
18 lLogicalAddress.Text = String.Format("{0,1:X}", (int)address);
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);
35 }
36
37 private void lInactiveSource_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
38 {
39 SetControlVisible(lInactiveSource, false);
40 SetControlVisible(lActiveSource, true);
41 Gui.ActivateSource(Address);
42 }
43
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
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 }
68 private CecConfigGUI Gui;
69 private LibCecSharp Lib;
70 }
71 }