cec-config-gui: updated labels, added 'not implemented' warning for the button config...
[deb_libcec.git] / src / cec-config-gui / actions / ConnectToDevice.cs
CommitLineData
4555ed72 1using CecSharp;
006b76b9 2using System.Windows.Forms;
006b76b9
LOK
3
4namespace CecConfigGui.actions
5{
6 class ConnectToDevice : UpdateProcess
7 {
4555ed72 8 public ConnectToDevice(ref LibCecSharp lib, LibCECConfiguration config)
006b76b9
LOK
9 {
10 Lib = lib;
4555ed72 11 Config = config;
006b76b9
LOK
12 }
13
14 public override void Process()
15 {
006b76b9
LOK
16 SendEvent(UpdateEventType.StatusText, "Detecting TV vendor...");
17 SendEvent(UpdateEventType.ProgressBar, 25);
18 SendEvent(UpdateEventType.TVVendorId, (int)Lib.GetDeviceVendorId(CecLogicalAddress.Tv));
19
f976869e
LOK
20 SendEvent(UpdateEventType.StatusText, "Detecting menu language...");
21 SendEvent(UpdateEventType.ProgressBar, 40);
22 SendEvent(UpdateEventType.MenuLanguage, Lib.GetDeviceMenuLanguage(CecLogicalAddress.Tv));
23
006b76b9
LOK
24 SendEvent(UpdateEventType.ProgressBar, 50);
25 SendEvent(UpdateEventType.StatusText, "Detecting AVR devices...");
26
27 bool hasAVRDevice = Lib.IsActiveDevice(CecLogicalAddress.AudioSystem);
28 SendEvent(UpdateEventType.HasAVRDevice, hasAVRDevice);
29
30 if (hasAVRDevice)
31 {
32 SendEvent(UpdateEventType.ProgressBar, 75);
33 SendEvent(UpdateEventType.StatusText, "Detecting AVR vendor...");
34 SendEvent(UpdateEventType.AVRVendorId, (int)Lib.GetDeviceVendorId(CecLogicalAddress.AudioSystem));
35 }
36
37 if (!Lib.GetDevicePowerStatus(CecLogicalAddress.Tv).Equals(CecPowerStatus.On))
38 {
39 SendEvent(UpdateEventType.ProgressBar, 80);
4555ed72
LOK
40 SendEvent(UpdateEventType.StatusText, "Activating the source...");
41 Lib.SetActiveSource(CecDeviceType.Reserved);
006b76b9
LOK
42 }
43
44 SendEvent(UpdateEventType.ProgressBar, 90);
45 SendEvent(UpdateEventType.StatusText, "Reading device configuration...");
46
4555ed72
LOK
47 Lib.GetCurrentConfiguration(Config);
48 SendEvent(Config);
006b76b9
LOK
49
50 SendEvent(UpdateEventType.ProgressBar, 100);
51 SendEvent(UpdateEventType.StatusText, "Ready.");
52 }
53
54 private LibCecSharp Lib;
4555ed72 55 private LibCECConfiguration Config;
006b76b9
LOK
56 }
57}