cec-config-gui: set cbPortNumber enabled when the physical address override isn't...
[deb_libcec.git] / src / cec-config-gui / actions / ShowDeviceInfo.cs
CommitLineData
96fa7764
LOK
1using System;
2using System.Collections.Generic;
3using System.Text;
4using CecSharp;
5
6namespace CecConfigGui.actions
7{
8 class ShowDeviceInfo : UpdateProcess
9 {
ece1582e 10 public ShowDeviceInfo(CecConfigGUI gui, ref LibCecSharp lib, CecLogicalAddress address)
96fa7764 11 {
ece1582e 12 Gui = gui;
96fa7764
LOK
13 Lib = lib;
14 Address = address;
15 }
16
6d866874
LOK
17 public virtual void ShowDialog(CecConfigGUI gui, CecLogicalAddress address, ref LibCecSharp lib,
18 bool devicePresent, CecVendorId vendor, bool isActiveSource, ushort physicalAddress,
19 CecVersion version, CecPowerStatus power, string osdName, string menuLanguage)
20 {
21 DeviceInformation di = new DeviceInformation(Gui, Address, ref Lib, devicePresent, vendor, isActiveSource, physicalAddress, version, power, osdName, menuLanguage);
22 Gui.DisplayDialog(di, false);
23 }
24
96fa7764
LOK
25 public override void Process()
26 {
27 CecVendorId vendor = CecVendorId.Unknown;
28 bool isActiveSource = false;
29 ushort physicalAddress = 0xFFFF;
30 CecVersion version = CecVersion.Unknown;
31 CecPowerStatus power = CecPowerStatus.Unknown;
32 string osdName = "unknown";
33 string menuLanguage = "unknown";
34
35 SendEvent(UpdateEventType.StatusText, "Checking device presense...");
36 SendEvent(UpdateEventType.ProgressBar, 10);
37
38 bool devicePresent = Lib.IsActiveDevice(Address);
39 if (devicePresent)
40 {
41 SendEvent(UpdateEventType.StatusText, "Requesting the vendor ID...");
42 SendEvent(UpdateEventType.ProgressBar, 20);
43 vendor = Lib.GetDeviceVendorId(Address);
44
45 SendEvent(UpdateEventType.StatusText, "Requesting active source state...");
46 SendEvent(UpdateEventType.ProgressBar, 30);
47 isActiveSource = Lib.IsActiveSource(Address);
48
49 SendEvent(UpdateEventType.StatusText, "Requesting physical address...");
50 SendEvent(UpdateEventType.ProgressBar, 40);
51 physicalAddress = Lib.GetDevicePhysicalAddress(Address);
52
53 SendEvent(UpdateEventType.StatusText, "Requesting CEC version...");
54 SendEvent(UpdateEventType.ProgressBar, 50);
55 version = Lib.GetDeviceCecVersion(Address);
56
57 SendEvent(UpdateEventType.StatusText, "Requesting power status...");
58 SendEvent(UpdateEventType.ProgressBar, 60);
59 power = Lib.GetDevicePowerStatus(Address);
60
61 SendEvent(UpdateEventType.StatusText, "Requesting OSD name...");
62 SendEvent(UpdateEventType.ProgressBar, 70);
63 osdName = Lib.GetDeviceOSDName(Address);
64
65 SendEvent(UpdateEventType.StatusText, "Requesting menu language...");
66 SendEvent(UpdateEventType.ProgressBar, 80);
67 menuLanguage = Lib.GetDeviceMenuLanguage(Address);
68 }
69
70 SendEvent(UpdateEventType.StatusText, "Showing device information");
71 SendEvent(UpdateEventType.ProgressBar, 90);
ece1582e 72 SendEvent(UpdateEventType.ProcessCompleted, true);
96fa7764 73
6d866874 74 ShowDialog(Gui, Address, ref Lib, devicePresent, vendor, isActiveSource, physicalAddress, version, power, osdName, menuLanguage);
96fa7764
LOK
75
76 SendEvent(UpdateEventType.StatusText, "Ready.");
77 SendEvent(UpdateEventType.ProgressBar, 100);
78 }
79
ece1582e 80 private CecConfigGUI Gui;
96fa7764
LOK
81 private LibCecSharp Lib;
82 private CecLogicalAddress Address;
83 }
84}