CEC_HDMI_PORT variable support for exynos hardware.
[deb_libcec.git] / LibCecTray / ui / DeviceInformation.cs
... / ...
CommitLineData
1/*
2 * This file is part of the libCEC(R) library.
3 *
4 * libCEC(R) is Copyright (C) 2011-2013 Pulse-Eight Limited. All rights reserved.
5 * libCEC(R) is an original work, containing original code.
6 *
7 * libCEC(R) is a trademark of Pulse-Eight Limited.
8 *
9 * This program is dual-licensed; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 *
23 *
24 * Alternatively, you can license this library under a commercial license,
25 * please contact Pulse-Eight Licensing for more information.
26 *
27 * For more information contact:
28 * Pulse-Eight Licensing <license@pulse-eight.com>
29 * http://www.pulse-eight.com/
30 * http://www.pulse-eight.net/
31 */
32
33using System;
34using System.Windows.Forms;
35using CecSharp;
36using LibCECTray.Properties;
37using LibCECTray.controller;
38
39namespace LibCECTray.ui
40{
41 partial class DeviceInformation : AsyncForm
42 {
43 public DeviceInformation(CECController controller, CecLogicalAddress address, ref LibCecSharp lib,
44 bool devicePresent, CecVendorId vendor, bool isActiveSource, ushort physicalAddress,
45 CecVersion version, CecPowerStatus power, string osdName, string menuLanguage)
46 {
47 _controller = controller;
48 _lib = lib;
49 Address = address;
50 InitializeComponent();
51 lDevice.Text = lib.ToString(address);
52 lLogicalAddress.Text = String.Format("{0,1:X}", (int)address);
53 Update(devicePresent, vendor, isActiveSource, physicalAddress, version, power, osdName, menuLanguage);
54 }
55
56 public void Update(bool devicePresent, CecVendorId vendor, bool isActiveSource, ushort physicalAddress,
57 CecVersion version, CecPowerStatus power, string osdName, string menuLanguage)
58 {
59 SetControlText(lPhysicalAddress, String.Format("{0,4:X}", physicalAddress));
60 SetControlText(lDevicePresent, devicePresent ? Resources.yes : Resources.no);
61 SetControlVisible(lActiveSource, isActiveSource);
62 SetControlVisible(lInactiveSource, !isActiveSource);
63 SetControlText(lVendor, vendor != CecVendorId.Unknown ? _lib.ToString(vendor) : Resources.unknown);
64 SetControlText(lCecVersion, _lib.ToString(version));
65 SetControlText(lPowerStatus, _lib.ToString(power));
66 SetControlText(lOsdName, osdName);
67 SetControlText(lMenuLanguage, menuLanguage);
68 SetControlText(this, "Device: " + osdName);
69 }
70
71 private void LInactiveSourceLinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
72 {
73 SetControlVisible(lInactiveSource, false);
74 SetControlVisible(lActiveSource, true);
75 _controller.CECActions.ActivateSource(Address);
76 }
77
78 private void LStandbyLinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
79 {
80 LinkLabel label = sender as LinkLabel;
81 bool sendPowerOn = label != null && label.Text != _lib.ToString(CecPowerStatus.InTransitionStandbyToOn) &&
82 label.Text != _lib.ToString(CecPowerStatus.On);
83
84 SetControlText(lPowerStatus, _lib.ToString(sendPowerOn ? CecPowerStatus.On : CecPowerStatus.Standby));
85 if (sendPowerOn)
86 _controller.CECActions.SendImageViewOn(Address);
87 else
88 _controller.CECActions.SendStandby(Address);
89 }
90
91
92 private void Button1Click(object sender, EventArgs e)
93 {
94 _controller.CECActions.UpdateInfoPanel(this);
95 }
96
97 public CecLogicalAddress Address
98 {
99 private set;
100 get;
101 }
102 private readonly CECController _controller;
103 private readonly LibCecSharp _lib;
104 }
105}