Exemple #1
0
 private void HandleLogicKeyPressed(DependencyLogicalKey logicalKey)
 {
     if (logicalKey is ModifierKeyBase)
     {
         var modifierKey = (ModifierKeyBase)logicalKey;
         if (modifierKey.KeyCode == VirtualKeyCode.SHIFT)
         {
             HandleShiftKeyPressed(modifierKey);
         }
         else if (modifierKey.KeyCode == VirtualKeyCode.CAPITAL)
         {
             HandleCapsLockKeyPressed(modifierKey);
         }
         else if (modifierKey.KeyCode == VirtualKeyCode.NUMLOCK)
         {
             HandleNumLockKeyPressed(modifierKey);
         }
     }
     else if (UserDefinedKeyHandler != null && logicalKey is UserDefinedKey)
     {
         UserDefinedKeyHandler.HandleUserDefinedKey(this, logicalKey, KeyboardService);
         ResetInstantaneousModifierKeys();
     }
     else
     {
         ResetInstantaneousModifierKeys();
     }
     _modifierKeys
     .OfType <InstantaneousModifierKey>()
     .ToList()
     .ForEach(x => x.SynchroniseKeyState());
     SetKeysContent();
 }
        public void HandleKeyDown(System.Windows.Controls.ContentControl sender, DependencyLogicalKey virtualKeyConfig, Dictionary <ContentControl, DependencyLogicalKey> virtualKeys)
        {
            var virtualKey        = QuertyKeyboard.GetVirtualKey(sender) as VirtualKey;
            var userDefineKey     = QuertyKeyboard.GetVirtualKey(sender) as UserDefinedKey;
            var isShiftVirtualKey = GetIsShiftVirtualKey(virtualKey);

            if (userDefineKey != null)
            {
                foreach (var kvp in _shiftKeys)
                {
                    foreach (var control in _shiftKeys[kvp.Key])
                    {
                        if (control is System.Windows.Controls.CheckBox)
                        {
                            var checkBox = control as System.Windows.Controls.CheckBox;
                            checkBox.IsChecked = false;
                        }
                        else if (control is System.Windows.Controls.Primitives.ToggleButton)
                        {
                            var toggleButton = control as System.Windows.Controls.Primitives.ToggleButton;
                            toggleButton.IsChecked = false;
                        }
                    }
                }
            }

            if (isShiftVirtualKey || virtualKey == null)
            {
                return;
            }

            foreach (var kvp in _shiftKeys)
            {
                foreach (var control in _shiftKeys[kvp.Key])
                {
                    var isKeyDown = virtualKey.KeyboardService.IsKeyDownAsync(kvp.Key);
                    if (control is System.Windows.Controls.CheckBox)
                    {
                        var checkBox = control as System.Windows.Controls.CheckBox;
                        checkBox.IsChecked = isKeyDown;
                    }
                    else if (control is System.Windows.Controls.Primitives.ToggleButton)
                    {
                        var toggleButton = control as System.Windows.Controls.Primitives.ToggleButton;
                        toggleButton.IsChecked = isKeyDown;
                    }
                }
            }
        }
Exemple #3
0
        private void OnHandleButtonDown(ContentControl sender, DependencyLogicalKey virtualKeyConfig)
        {
            virtualKeyConfig.Press();
            HandleLogicKeyPressed(virtualKeyConfig);
            VisualKeyboardHandler.HandleKeyDown(sender, virtualKeyConfig, _virtualKeys);

            if (_lastVirtualKeyPressed != null && (_lastVirtualKeyPressed.KeyCode == VirtualKeyCode.SHIFT))
            {
                HandleShiftKeyPressed(_lastVirtualKeyPressed as ModifierKeyBase);
                ResetInstantaneousModifierKeys();
                _modifierKeys
                .OfType <InstantaneousModifierKey>()
                .ToList()
                .ForEach(x => x.SynchroniseKeyState());
                SetKeysContent();
            }
            _lastVirtualKeyPressed = virtualKeyConfig as VirtualKey;
        }
        public void HandleUserDefinedKey(QuertyKeyboard sender, DependencyLogicalKey virtualKeyConfig, IKeyboardInput keyboardService)
        {
            //var currentLayout = (QuertyKeyboard)sender.KeyboardLayout;

            var keyName = (virtualKeyConfig as UserDefinedKey).Id.ToString();

            switch (keyName)
            {
            case @"KBEXPAND":
                sender.KeyboardLayout = DefaultKeyboardLayout.SplittedKeyboard;
                break;

            case @"KBCOMPACT":
                sender.KeyboardLayout = DefaultKeyboardLayout.StandardKeyboard;
                break;

            case @"KBNUMERIC":
                sender.KeyboardLayout = DefaultKeyboardLayout.NumericKeyboard;
                break;

            default:
                break;
            }
        }
Exemple #5
0
 public LogicalKeyEventArgs(DependencyLogicalKey key)
 {
     Key = key;
 }
Exemple #6
0
 private void OnHandleButtonUp(DependencyLogicalKey virtualKeyConfig)
 {
 }