public static void Remove(HotkeyHandler h) { lock (handlers) { if (handlers.Value.ContainsValue(h)) { int id = handlers.Value.First(x => x.Value == h).Key; handlers.Value.Remove(id); User32.UnregisterHotKey(form.Value.Handle, id); } } }
public static void Add(HotkeyHandler h) { lock (handlers) { if (!handlers.Value.ContainsValue(h)) { int id = ++iids; handlers.Value.Add(id, h); User32.RegisterHotKey(form.Value.Handle, id, h.ModKey, h.Key); } } }