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(); } }
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; } } }
private static Keys ToNativeKeys(Shortcut shortcut) { return(ToNativeKeys(shortcut.Modifiers) | ToNativeKeys(shortcut.Main)); }
public Command(string text, Shortcut shortcut, Action execute) : this(text, shortcut) { Issued += execute; }
public Command(string text, Shortcut shortcut) : this(text) { Shortcut = shortcut; }
public Command(Key main) { Shortcut = new Shortcut(main); }
public Command(Modifiers modifiers, Key main) { Shortcut = new Shortcut(modifiers, main); }
public Command(Shortcut shortcut) { Shortcut = shortcut; }