Example #1
0
        private void ExtraKeysComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            if ((!ExtraKeysComboBox.IsDropDownOpen || e.AddedItems.Count == 0))
            {
                return;
            }

            _KeyCode.Add((Keys)ExtraKeysComboBox.SelectedValue);

            string keyCodes = _KeyCode.Aggregate(string.Empty, (current, k) => current + (HotKeyPlugin.GetKeyName(k) + " + "));

            txtKey.Text = keyCodes.Substring(0, keyCodes.Length - 2);

            ExtraKeysComboBox.IsDropDownOpen = false;
            ExtraKeysComboBox.SelectedIndex  = 0;
        }
Example #2
0
        private void Grid_PreviewKeyUp(object sender, KeyEventArgs e)
        {
            e.Handled = true;

            switch (e.Key)
            {
            case Key.System:
            {
                if (e.SystemKey == Key.LeftAlt || e.SystemKey == Key.RightAlt)
                {
                    return;
                }
                break;
            }

            case Key.LeftCtrl:
            case Key.RightCtrl:
            case Key.LeftAlt:
            case Key.RightAlt:
            case Key.LeftShift:
            case Key.RightShift:
            case Key.LWin:
            case Key.RWin:
                return;
            }

            var keyCode = (e.Key == Key.System) ? (Keys)KeyInterop.VirtualKeyFromKey(e.SystemKey) :
                          (Keys)KeyInterop.VirtualKeyFromKey(e.Key);

            _KeyCode.Add(keyCode);
            string keyCodes = _KeyCode.Aggregate(string.Empty, (current, k) => current + (HotKeyPlugin.GetKeyName(k) + " + "));

            txtKey.Text = keyCodes.Substring(0, keyCodes.Length - 2);
        }