2 using System.Collections.Generic;
6 namespace CecConfigGui.actions
8 class UpdateConnectedDevice : UpdateProcess
10 public UpdateConnectedDevice(ref LibCecSharp lib, CecLogicalAddress address, int portNumber)
14 PortNumber = portNumber;
17 public override void Process()
19 SendEvent(UpdateEventType.StatusText, "Requesting physical address...");
20 SendEvent(UpdateEventType.ProgressBar, 0);
22 ushort iPhysicalAddress = Lib.GetDevicePhysicalAddress(Address);
23 SendEvent(UpdateEventType.BaseDevicePhysicalAddress, iPhysicalAddress);
25 SendEvent(UpdateEventType.StatusText, "Setting new configuration...");
26 SendEvent(UpdateEventType.ProgressBar, 25);
28 if (!Lib.SetHDMIPort(Address, (byte)PortNumber))
30 SendEvent(UpdateEventType.StatusText, "Could not activate the new source");
34 LibCECConfiguration config = new LibCECConfiguration();
35 Lib.GetCurrentConfiguration(config);
37 SendEvent(UpdateEventType.StatusText, "Activating source...");
38 SendEvent(UpdateEventType.ProgressBar, 50);
39 Lib.SetActiveSource(config.DeviceTypes.Types[0]);
41 SendEvent(UpdateEventType.StatusText, "Reading configuration...");
42 SendEvent(UpdateEventType.ProgressBar, 75);
43 Lib.GetCurrentConfiguration(config);
45 SendEvent(UpdateEventType.PhysicalAddress, config.PhysicalAddress);
46 SendEvent(UpdateEventType.BaseDevice, (int)config.BaseDevice);
47 SendEvent(UpdateEventType.HDMIPort, config.HDMIPort);
48 SendEvent(UpdateEventType.StatusText, "Ready.");
50 SendEvent(UpdateEventType.ProgressBar, 100);
53 private LibCecSharp Lib;
54 private CecLogicalAddress Address;
55 private int PortNumber;