cec-config-gui: don't update the log window all the time when it's not the selected tab
[deb_libcec.git] / src / cec-config-gui / actions / UpdateConnectedDevice.cs
CommitLineData
006b76b9
LOK
1using System;
2using System.Collections.Generic;
3using System.Text;
4using CecSharp;
5
6namespace CecConfigGui.actions
7{
8 class UpdateConnectedDevice : UpdateProcess
9 {
10 public UpdateConnectedDevice(ref LibCecSharp lib, CecLogicalAddress address, int portNumber)
11 {
12 Lib = lib;
13 Address = address;
14 PortNumber = portNumber;
15 }
16
17 public override void Process()
18 {
19 SendEvent(UpdateEventType.StatusText, "Requesting physical address...");
20 SendEvent(UpdateEventType.ProgressBar, 0);
21
22 ushort iPhysicalAddress = Lib.GetDevicePhysicalAddress(Address);
23 SendEvent(UpdateEventType.BaseDevicePhysicalAddress, iPhysicalAddress);
24
25 SendEvent(UpdateEventType.StatusText, "Setting new configuration...");
26 SendEvent(UpdateEventType.ProgressBar, 25);
27
28 if (!Lib.SetHDMIPort(Address, (byte)PortNumber))
29 {
30 SendEvent(UpdateEventType.StatusText, "Could not activate the new source");
31 }
32 else
33 {
34 LibCECConfiguration config = new LibCECConfiguration();
35 Lib.GetCurrentConfiguration(config);
36
37 SendEvent(UpdateEventType.StatusText, "Activating source...");
38 SendEvent(UpdateEventType.ProgressBar, 50);
39 Lib.SetActiveSource(config.DeviceTypes.Types[0]);
40
41 SendEvent(UpdateEventType.StatusText, "Reading configuration...");
42 SendEvent(UpdateEventType.ProgressBar, 75);
43 Lib.GetCurrentConfiguration(config);
44
45 SendEvent(UpdateEventType.PhysicalAddress, config.PhysicalAddress);
46 SendEvent(UpdateEventType.BaseDevice, (int)config.BaseDevice);
47 SendEvent(UpdateEventType.HDMIPort, config.HDMIPort);
48 SendEvent(UpdateEventType.StatusText, "Ready.");
49 }
50 SendEvent(UpdateEventType.ProgressBar, 100);
51 }
52
53 private LibCecSharp Lib;
54 private CecLogicalAddress Address;
55 private int PortNumber;
56 }
57}