2 using System.Windows.Forms;
4 namespace CecConfigGui.actions
6 class ConnectToDevice : UpdateProcess
8 public ConnectToDevice(ref LibCecSharp lib, LibCECConfiguration config)
14 public override void Process()
16 SendEvent(UpdateEventType.StatusText, "Detecting TV vendor...");
17 SendEvent(UpdateEventType.ProgressBar, 25);
18 SendEvent(UpdateEventType.TVVendorId, (int)Lib.GetDeviceVendorId(CecLogicalAddress.Tv));
20 SendEvent(UpdateEventType.StatusText, "Detecting menu language...");
21 SendEvent(UpdateEventType.ProgressBar, 40);
22 SendEvent(UpdateEventType.MenuLanguage, Lib.GetDeviceMenuLanguage(CecLogicalAddress.Tv));
24 SendEvent(UpdateEventType.ProgressBar, 50);
25 SendEvent(UpdateEventType.StatusText, "Detecting AVR devices...");
27 bool hasAVRDevice = Lib.IsActiveDevice(CecLogicalAddress.AudioSystem);
28 SendEvent(UpdateEventType.HasAVRDevice, hasAVRDevice);
32 SendEvent(UpdateEventType.ProgressBar, 75);
33 SendEvent(UpdateEventType.StatusText, "Detecting AVR vendor...");
34 SendEvent(UpdateEventType.AVRVendorId, (int)Lib.GetDeviceVendorId(CecLogicalAddress.AudioSystem));
37 if (!Lib.GetDevicePowerStatus(CecLogicalAddress.Tv).Equals(CecPowerStatus.On))
39 SendEvent(UpdateEventType.ProgressBar, 80);
40 SendEvent(UpdateEventType.StatusText, "Activating the source...");
41 Lib.SetActiveSource(CecDeviceType.Reserved);
44 SendEvent(UpdateEventType.ProgressBar, 90);
45 SendEvent(UpdateEventType.StatusText, "Reading device configuration...");
47 Lib.GetCurrentConfiguration(Config);
50 SendEvent(UpdateEventType.ProgressBar, 100);
51 SendEvent(UpdateEventType.StatusText, "Ready.");
54 private LibCecSharp Lib;
55 private LibCECConfiguration Config;