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