private int RegisterHotkey(Hotkey hotkey, int? id, bool suppressEvent) { int idValue = _DefaultID; if (id == null) { while (_Hotkeys.ContainsKey(_DefaultID)) { _DefaultID++; } idValue = _DefaultID; _DefaultID++; } uint modifiers = 0; foreach (Modifier mod in hotkey.Modifiers) { modifiers |= (uint)mod; } if (RegisterHotKey(_Window.Handle, idValue, modifiers, (uint)hotkey.Key)) { hotkey.ListenerWindow = _Window; hotkey.Pressed += (HotkeyPressedEventArgs args) => { if (HotkeyPressed != null) { HotkeyPressed(args); } }; _Hotkeys.Add(idValue, hotkey); } else { if (!suppressEvent && UnavailableHotkeyRegistered != null) { UnavailableHotkeyRegistered(new HotkeyEventArgs(hotkey)); } idValue = -1; } return idValue; }
public bool IsHotkeyAvailable(Hotkey hotkey) { bool retVal = true; int hotkeyID = RegisterHotkey(hotkey, null, true); if (hotkeyID < 0) retVal = false; else UnregisterHotkey(hotkeyID); return retVal; }
public void RegisterHotkey(Hotkey hotkey) { RegisterHotkey(hotkey, null, false); }
// returns the ID of the registered hotkey public int RegisterHotkey(Hotkey hotkey, int? id) { return RegisterHotkey(hotkey, id, false); }
public HotkeyEventArgs(Hotkey hotkey) { this.Hotkey = hotkey; }
public HotkeyPressedEventArgs(Hotkey hotkey) : base(hotkey) { }