Ejemplo n.º 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;
        }
Ejemplo n.º 2
0
 protected bool Equals(KeyPress other)
 {
     return(_key == other._key && _modifier == other._modifier);
 }
Ejemplo n.º 3
0
 private void RemoveHotKey(HotkeyRegistration registration, KeyPress keyPress)
 {
     UnregisterHotKey(_window.Handle, registration.Id);
     _shortcutsByKeyPress.Remove(keyPress);
 }