LibCecSharp: added the new parameters
[deb_libcec.git] / src / cec-config-gui / DeviceInformation.cs
CommitLineData
96fa7764
LOK
1using System;
2using System.Collections.Generic;
3using System.ComponentModel;
4using System.Data;
5using System.Drawing;
6using System.Text;
7using System.Windows.Forms;
8using CecSharp;
9
10namespace CecConfigGui
11{
12 public partial class DeviceInformation : Form
13 {
ece1582e 14 public DeviceInformation(CecConfigGUI gui, CecLogicalAddress address, ref LibCecSharp lib,
96fa7764
LOK
15 bool devicePresent, CecVendorId vendor, bool isActiveSource, ushort physicalAddress,
16 CecVersion version, CecPowerStatus power, string osdName, string menuLanguage)
17 {
ece1582e
LOK
18 Gui = gui;
19 Lib = lib;
20 Address = address;
96fa7764
LOK
21 InitializeComponent();
22 this.lDevice.Text = lib.ToString(address);
ece1582e
LOK
23 this.lLogicalAddress.Text = String.Format("{0,1:X}", (int)address);
24 this.lPhysicalAddress.Text = String.Format("{0,4:X}", physicalAddress);
96fa7764 25 this.lDevicePresent.Text = devicePresent ? "yes" : "no";
ece1582e
LOK
26 this.lActiveSource.Visible = isActiveSource;
27 this.lInactiveSource.Visible = !isActiveSource;
28 this.lVendor.Text = vendor != CecVendorId.Unknown ? lib.ToString(vendor) : "unknown";
96fa7764
LOK
29 this.lCecVersion.Text = lib.ToString(version);
30 this.lPowerStatus.Text = lib.ToString(power);
ece1582e 31 bool isPoweredOn = (power == CecPowerStatus.On || power == CecPowerStatus.InTransitionStandbyToOn);
96fa7764
LOK
32 this.lOsdName.Text = osdName;
33 this.lMenuLanguage.Text = menuLanguage;
ece1582e 34 this.Text = "Device: " + osdName;
96fa7764 35 }
ece1582e
LOK
36
37 delegate void SetControlVisibleCallback(Control control, bool val);
38 private void SetControlVisible(Control control, bool val)
39 {
40 if (control.InvokeRequired)
41 {
42 SetControlVisibleCallback d = new SetControlVisibleCallback(SetControlVisible);
43 try
44 {
45 this.Invoke(d, new object[] { control, val });
46 }
47 catch (Exception) { }
48 }
49 else
50 {
51 control.Visible = val;
52 }
53 }
54
55 delegate void SetControlTextCallback(Control control, string val);
56 private void SetControlText(Control control, string val)
57 {
58 if (control.InvokeRequired)
59 {
60 SetControlTextCallback d = new SetControlTextCallback(SetControlText);
61 try
62 {
63 this.Invoke(d, new object[] { control, val });
64 }
65 catch (Exception) { }
66 }
67 else
68 {
69 control.Text = val;
70 }
71 }
72
73 private void lInactiveSource_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
74 {
75 SetControlVisible(lInactiveSource, false);
76 SetControlVisible(lActiveSource, true);
77 Gui.ActivateSource(Address);
78 }
79
80
81 private void lStandby_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
82 {
83 LinkLabel label = sender as LinkLabel;
84 bool sendPowerOn = label.Text != Lib.ToString(CecPowerStatus.InTransitionStandbyToOn) &&
85 label.Text != Lib.ToString(CecPowerStatus.On);
86
87 SetControlText(lPowerStatus, Lib.ToString(sendPowerOn ? CecPowerStatus.On : CecPowerStatus.Standby));
88 if (sendPowerOn)
89 Gui.SendImageViewOn(Address);
90 else
91 Gui.SendStandby(Address);
92 }
93
94 private CecLogicalAddress Address;
95 private CecConfigGUI Gui;
96 private LibCecSharp Lib;
96fa7764
LOK
97 }
98}