Commit | Line | Data |
---|---|---|
006b76b9 LOK |
1 | using System; |
2 | using System.Collections.Generic; | |
3 | using System.Text; | |
4 | using CecSharp; | |
5 | ||
6 | namespace CecConfigGui.actions | |
7 | { | |
8 | class UpdatePhysicalAddress : UpdateProcess | |
9 | { | |
10 | public UpdatePhysicalAddress(ref LibCecSharp lib, ushort physicalAddress) | |
11 | { | |
12 | Lib = lib; | |
13 | PhysicalAddress = physicalAddress; | |
14 | } | |
15 | ||
16 | public override void Process() | |
17 | { | |
18 | SendEvent(UpdateEventType.BaseDevicePhysicalAddress, 0); | |
19 | SendEvent(UpdateEventType.StatusText, "Setting new configuration..."); | |
20 | SendEvent(UpdateEventType.ProgressBar, 25); | |
21 | ||
22 | if (!Lib.SetPhysicalAddress(PhysicalAddress)) | |
23 | { | |
24 | SendEvent(UpdateEventType.StatusText, "Could not activate the new source"); | |
25 | } | |
26 | else | |
27 | { | |
28 | LibCECConfiguration config = new LibCECConfiguration(); | |
29 | Lib.GetCurrentConfiguration(config); | |
30 | ||
31 | SendEvent(UpdateEventType.StatusText, "Activating source..."); | |
32 | SendEvent(UpdateEventType.ProgressBar, 50); | |
33 | Lib.SetActiveSource(config.DeviceTypes.Types[0]); | |
34 | ||
35 | SendEvent(UpdateEventType.StatusText, "Reading configuration..."); | |
36 | SendEvent(UpdateEventType.ProgressBar, 75); | |
37 | Lib.GetCurrentConfiguration(config); | |
38 | ||
39 | SendEvent(config); | |
40 | SendEvent(UpdateEventType.StatusText, "Ready."); | |
41 | } | |
42 | SendEvent(UpdateEventType.ProgressBar, 100); | |
43 | } | |
44 | ||
45 | protected LibCecSharp Lib; | |
46 | protected ushort PhysicalAddress; | |
47 | } | |
48 | } |