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