cec: added a .net CEC configuration tool
[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 }
22
23 public class UpdateEvent : EventArgs
24 {
25 public UpdateEvent(UpdateEventType type, bool value)
26 {
27 Type = type;
28 BoolValue = value;
29 }
30
31 public UpdateEvent(UpdateEventType type, int value)
32 {
33 Type = type;
34 IntValue = value;
35 }
36
37 public UpdateEvent(UpdateEventType type, string value)
38 {
39 Type = type;
40 StringValue = value;
41 }
42
43 public UpdateEvent(LibCECConfiguration config)
44 {
45 Type = UpdateEventType.Configuration;
46 ConfigValue = config;
47 }
48
49 public UpdateEventType Type;
50 public bool BoolValue = false;
51 public int IntValue = -1;
52 public string StringValue = String.Empty;
53 public LibCECConfiguration ConfigValue = null;
54 }
55
56 public abstract class UpdateProcess
57 {
58 public UpdateProcess()
59 {
60 }
61
62 public void SendEvent(UpdateEventType type, bool value)
63 {
64 EventHandler<UpdateEvent> temp = EventHandler;
65 if (temp != null)
66 temp(this, new UpdateEvent(type, value));
67 }
68
69 public void SendEvent(UpdateEventType type, int value)
70 {
71 EventHandler<UpdateEvent> temp = EventHandler;
72 if (temp != null)
73 temp(this, new UpdateEvent(type, value));
74 }
75
76 public void SendEvent(UpdateEventType type, string value)
77 {
78 EventHandler<UpdateEvent> temp = EventHandler;
79 if (temp != null)
80 temp(this, new UpdateEvent(type, value));
81 }
82
83 public void SendEvent(LibCECConfiguration config)
84 {
85 EventHandler<UpdateEvent> temp = EventHandler;
86 if (temp != null)
87 temp(this, new UpdateEvent(config));
88 }
89
90 public void Run()
91 {
92 Process();
93 SendEvent(UpdateEventType.ProcessCompleted, true);
94 }
95
96 public abstract void Process();
97 public event EventHandler<UpdateEvent> EventHandler;
98 }
99 }