Пример #1
0
        public void AddAlias(Shortcut shortcut)
        {
            if (!Shortcut.ValidateMainKey(shortcut.Main))
            {
                throw new ArgumentException();
            }
            Key key;

            if (!ShortcutMap.TryGetValue(shortcut, out key))
            {
                ShortcutMap.Add(shortcut, this);
            }
            else if (key != this)
            {
                throw new InvalidOperationException();
            }
        }
Пример #2
0
        private void ProcessKeyEvent(Key key, bool value)
        {
            // Dont let system key repeat events get to us, for our key repeat mechanism to work properly
            if (keys[key].CurrentState && value)
            {
                return;
            }
            var previousCurrentShortcut = currentShortcut;

            if (currentShortcut != Key.Unknown)
            {
                // If currentShortcut == key, we will restore state by the next call.
                SetKeyStateInternal(currentShortcut, false);
                currentShortcut = Key.Unknown;
            }
            SetKeyStateInternal(key, value);
            if (value && key > Key.LastNormal)
            {
                // Shortcut was simulated by menu item.
                currentShortcut = key;
                return;
            }
            // Give priority to the last pressed key, choose arbitrarily among others.
            Key mainKey = value && Shortcut.ValidateMainKey(key) ? key : FindMainKey();

            if (mainKey == Key.Unknown)
            {
                return;
            }
            if (Key.ShortcutMap.TryGetValue(new Shortcut(GetModifiers(), mainKey), out currentShortcut))
            {
                SetKeyStateInternal(currentShortcut, true);
                if (previousCurrentShortcut == currentShortcut)
                {
                    // Prevent setting Repeated = true before key repeat timeout for given key in case
                    // we're here because another key has been released. e.g. releasing key "3" while still holding "Enter" key in edit box (see CIT-783)
                    keys[currentShortcut].Repeated = false;
                }
            }
        }
Пример #3
0
 private static Keys ToNativeKeys(Shortcut shortcut)
 {
     return(ToNativeKeys(shortcut.Modifiers) | ToNativeKeys(shortcut.Main));
 }
Пример #4
0
 public Command(string text, Shortcut shortcut, Action execute) : this(text, shortcut)
 {
     Issued += execute;
 }
Пример #5
0
 public Command(string text, Shortcut shortcut) : this(text)
 {
     Shortcut = shortcut;
 }
Пример #6
0
 public Command(Key main)
 {
     Shortcut = new Shortcut(main);
 }
Пример #7
0
 public Command(Modifiers modifiers, Key main)
 {
     Shortcut = new Shortcut(modifiers, main);
 }
Пример #8
0
 public Command(Shortcut shortcut)
 {
     Shortcut = shortcut;
 }