public void RegisterGlobalShortcut(string name, ModifierKeys modifier, Keys key) { HotkeyRegistration registration; var keyPress = new KeyPress(modifier, key); var entry = GetShortcutEntryByName(name); if (entry.Value != null) { registration = entry.Value; RemoveHotKey(registration, keyPress); TryRegisterHotKey(name, modifier, key, registration.Id); } else { TryRegisterHotKey(name, modifier, key, ++_currentId); registration = new HotkeyRegistration(_currentId, name); } _shortcutsByKeyPress[keyPress] = registration; }
protected bool Equals(KeyPress other) { return(_key == other._key && _modifier == other._modifier); }
private void RemoveHotKey(HotkeyRegistration registration, KeyPress keyPress) { UnregisterHotKey(_window.Handle, registration.Id); _shortcutsByKeyPress.Remove(keyPress); }