using System; using System.Collections.Generic; using System.Text; using CecSharp; namespace CecConfigGui { public enum UpdateEventType { ProcessCompleted, StatusText, ProgressBar, TVVendorId, BaseDevicePhysicalAddress, BaseDevice, HDMIPort, PhysicalAddress, HasAVRDevice, AVRVendorId, Configuration } public class UpdateEvent : EventArgs { public UpdateEvent(UpdateEventType type, bool value) { Type = type; BoolValue = value; } public UpdateEvent(UpdateEventType type, int value) { Type = type; IntValue = value; } public UpdateEvent(UpdateEventType type, string value) { Type = type; StringValue = value; } public UpdateEvent(LibCECConfiguration config) { Type = UpdateEventType.Configuration; ConfigValue = config; } public UpdateEventType Type; public bool BoolValue = false; public int IntValue = -1; public string StringValue = String.Empty; public LibCECConfiguration ConfigValue = null; } public abstract class UpdateProcess { public UpdateProcess() { } public void SendEvent(UpdateEventType type, bool value) { EventHandler temp = EventHandler; if (temp != null) temp(this, new UpdateEvent(type, value)); } public void SendEvent(UpdateEventType type, int value) { EventHandler temp = EventHandler; if (temp != null) temp(this, new UpdateEvent(type, value)); } public void SendEvent(UpdateEventType type, string value) { EventHandler temp = EventHandler; if (temp != null) temp(this, new UpdateEvent(type, value)); } public void SendEvent(LibCECConfiguration config) { EventHandler temp = EventHandler; if (temp != null) temp(this, new UpdateEvent(config)); } public void Run() { Process(); SendEvent(UpdateEventType.ProcessCompleted, true); } public abstract void Process(); public event EventHandler EventHandler; } }