Пример #1
0
        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;
        }
Пример #2
0
 private void RemoveHotKey(HotkeyRegistration registration, KeyPress keyPress)
 {
     UnregisterHotKey(_window.Handle, registration.Id);
     _shortcutsByKeyPress.Remove(keyPress);
 }