using System; using System.ComponentModel; namespace Inspectron.Settings { public static class Event { public static void Raise(this EventHandler handler, object sender, EventArgs e) { if (handler != null) handler(sender, e); } public static void Raise(this EventHandler handler, object sender, T e) where T : EventArgs { if (handler != null) handler(sender, e); } public static bool RaiseCancellable(this CancelEventHandler handler, object sender, CancelEventArgs e) { if (handler != null) foreach (CancelEventHandler h in handler.GetInvocationList()) { h(sender, e); if (e.Cancel) break; } return e.Cancel; } public static bool RaiseCancellable(this EventHandler handler, object sender, T e) where T : CancelEventArgs { if (handler != null) foreach (EventHandler h in handler.GetInvocationList()) { h(sender, e); if (e.Cancel) break; } return e.Cancel; } } }