dae21bfc438439d024a819805821bfeedb626f8b
[deb_libcec.git] / src / cec-config-gui / actions / UpdateEvent.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4 using CecSharp;
5
6 namespace CecConfigGui
7 {
8 public enum UpdateEventType
9 {
10 ProcessCompleted,
11 StatusText,
12 ProgressBar,
13 TVVendorId,
14 BaseDevicePhysicalAddress,
15 BaseDevice,
16 HDMIPort,
17 PhysicalAddress,
18 HasAVRDevice,
19 AVRVendorId,
20 Configuration,
21 MenuLanguage,
22 PollDevices
23 }
24
25 public class UpdateEvent : EventArgs
26 {
27 public UpdateEvent(UpdateEventType type)
28 {
29 Type = type;
30 }
31
32 public UpdateEvent(UpdateEventType type, bool value)
33 {
34 Type = type;
35 BoolValue = value;
36 }
37
38 public UpdateEvent(UpdateEventType type, int value)
39 {
40 Type = type;
41 IntValue = value;
42 }
43
44 public UpdateEvent(UpdateEventType type, string value)
45 {
46 Type = type;
47 StringValue = value;
48 }
49
50 public UpdateEvent(LibCECConfiguration config)
51 {
52 Type = UpdateEventType.Configuration;
53 ConfigValue = config;
54 }
55
56 public UpdateEventType Type;
57 public bool BoolValue = false;
58 public int IntValue = -1;
59 public string StringValue = String.Empty;
60 public LibCECConfiguration ConfigValue = null;
61 }
62
63 public abstract class UpdateProcess
64 {
65 public UpdateProcess()
66 {
67 }
68
69 public void SendEvent(UpdateEventType type)
70 {
71 EventHandler<UpdateEvent> temp = EventHandler;
72 if (temp != null)
73 temp(this, new UpdateEvent(type));
74 }
75
76 public void SendEvent(UpdateEventType type, bool value)
77 {
78 EventHandler<UpdateEvent> temp = EventHandler;
79 if (temp != null)
80 temp(this, new UpdateEvent(type, value));
81 }
82
83 public void SendEvent(UpdateEventType type, int value)
84 {
85 EventHandler<UpdateEvent> temp = EventHandler;
86 if (temp != null)
87 temp(this, new UpdateEvent(type, value));
88 }
89
90 public void SendEvent(UpdateEventType type, string value)
91 {
92 EventHandler<UpdateEvent> temp = EventHandler;
93 if (temp != null)
94 temp(this, new UpdateEvent(type, value));
95 }
96
97 public void SendEvent(LibCECConfiguration config)
98 {
99 EventHandler<UpdateEvent> temp = EventHandler;
100 if (temp != null)
101 temp(this, new UpdateEvent(config));
102 }
103
104 public void Run()
105 {
106 Process();
107 SendEvent(UpdateEventType.ProcessCompleted, true);
108 }
109
110 public abstract void Process();
111 public event EventHandler<UpdateEvent> EventHandler;
112 }
113 }