private void RegisterHotKey(HotKey hotkey, HotKeyPressedEventHandler handler, ICollection <string> errors) { try { if (hotkey != null) { hotkey.HotKeyPressed += handler; hotkey.RegisterHotKey(); } } catch (InvalidOperationException) { } catch (HotKeyAleadyInUseException e) { if (_settings.OverrideExistingHotKeys) { _hookHotKey.RegisterHotKey(hotkey.ModifierKeys, hotkey.Key, handler); } else { Trace.WriteLine("Error while registering hot key " + hotkey + "\n" + e); errors.Add("Error while registering hot key " + hotkey); } } }
private void OnHotKeyPressed() { HotKeyPressedEventHandler pressedEventHandler = HotKeyPressed; if (pressedEventHandler == null) { return; } pressedEventHandler(this, new EventArgs()); }
public static HotKey RemoveHandler(this HotKey hotKey, HotKeyPressedEventHandler handler) { Contract.Ensures(Contract.Result <HotKey>() == hotKey); if (hotKey == null) { return(null); } hotKey.HotKeyPressed -= handler; return(hotKey); }
public void RegisterHotKey(ModifierKeys modifierKeys, Keys key, HotKeyPressedEventHandler action) { HotKey hotKey = new HotKey(modifierKeys, key); hotKey.Action = action; if (_hotKeys.Contains(hotKey)) { return; // TODO manage multiple handler } if (_hotKeys.Count == 0) { _hook.Install(); } _hotKeys.Add(hotKey); }
public void RegisterHotKey(ModifierKeys modifierKeys, Keys key, HotKeyPressedEventHandler action) { var hotKey = new HotKey(modifierKeys, key) { Action = action, }; if (_hotKeys.Contains(hotKey)) { return; } if (_hotKeys.Count == 0) { _hook.Install(); } _hotKeys.Add(hotKey); }