private void OnExecuteVirtualKeyStroke(string partName, VirtualKeyboardButton key)
        {
            if (!OnCanExecuteStringStroke(partName))
            {
                return;
            }

            VirtualKeyboardButton.KeyType type = key.GetKeyType();
            switch (type)
            {
            case VirtualKeyboardButton.KeyType.Input:
                VirtualKeyboardInputButton inputButton = (VirtualKeyboardInputButton)key;
                string keyInput      = inputButton.GetKeyInputValue();
                string keyShiftInput = inputButton.GetKeyShiftInputValue();
                VirtualKeyboardService.Instance.SendKey(IsShiftPressed && !String.IsNullOrEmpty(keyShiftInput)
                        ? keyShiftInput[0]
                        : keyInput[0]);
                UpdateKeyboardShift(ShiftState.ShiftUp);
                break;

            case VirtualKeyboardButton.KeyType.Control:
                VirtualKeyboardControlButton controlButton = (VirtualKeyboardControlButton)key;
                VirtualKeyboardService.Instance.SendKey((KeysEx)controlButton.GetKeyControlInputValue());
                OnControlKeyEvent((KeysEx)controlButton.GetKeyControlInputValue());
                break;

            case VirtualKeyboardButton.KeyType.Special:
                VirtualKeyboardSpecialButton specialButton = (VirtualKeyboardSpecialButton)key;
                OnCustomKeyEvent(specialButton.GetKeySpecialInputValue());
                break;

            default:
                break;
            }
        }
Esempio n. 2
0
 private void UpdateButtonLabels()
 {
     foreach (var key in KeyboardButtons)
     {
         if (key.GetKeyType() == VirtualKeyboardButton.KeyType.Input)
         {
             VirtualKeyboardInputButton inputButton = (VirtualKeyboardInputButton)key;
             if (inputButton.GetAutoLabel())
             {
                 string shiftInputValue = inputButton.GetKeyShiftInputValue();
                 inputButton.Content = IsShiftPressed && !String.IsNullOrEmpty(shiftInputValue)
                     ? shiftInputValue
                     : inputButton.GetKeyInputValue();
             }
         }
     }
 }
        public void ProcessCustomKeyboardKeys()
        {
            foreach (var customKeyLayout in this.customKeyboardLayout)
            {
                string row       = customKeyLayout[0];
                int    index     = int.Parse(customKeyLayout[1]);
                string lowercase = customKeyLayout[2];
                string uppercase = customKeyLayout[3];

                StackPanel keyboardRow = ViewHelpers.FindChildByName <StackPanel>(this, row);

                VirtualKeyboard.VirtualKeyboardInputButton keyToChange = keyboardRow.Children[index] as VirtualKeyboard.VirtualKeyboardInputButton;

                VirtualKeyboard.VirtualKeyboardInputButton.SetKeyInputValue(keyToChange, lowercase);

                if (lowercase != "")
                {
                    VirtualKeyboard.VirtualKeyboardInputButton.SetKeyShiftInputValue(keyToChange, uppercase);
                }
                else if (VirtualKeyboard.VirtualKeyboardInputButton.GetKeyShiftInputValue(keyToChange) != null)
                {
                    uppercase = lowercase;
                    VirtualKeyboard.VirtualKeyboardInputButton.SetKeyShiftInputValue(keyToChange, uppercase);
                }

                if (keyToChange.GetAutoLabel())
                {
                    keyToChange.Content = keyToChange.GetKeyInputValue();
                }
                else
                {
                    StackPanel customKeyLabel = ViewHelpers.FindChildByName <StackPanel>(this, "Label" + customKeyLayout[1]);

                    TextBlock upperCaseLabel = customKeyLabel.Children[0] as TextBlock;
                    upperCaseLabel.Text = uppercase;

                    TextBlock lowerCaseLabel = customKeyLabel.Children[1] as TextBlock;
                    lowerCaseLabel.Text = lowercase;
                }
            }
        }