コード例 #1
0
 /// <summary>
 /// Create raw keyevent arguments.
 /// </summary>
 /// <param name="VKCode"></param>
 /// <param name="isSysKey"></param>
 /// <param name="Character">Character</param>
 public RawKeyEventArgs(int VKCode, bool isSysKey, string Character)
 {
     this.VKCode = VKCode;
     this.IsSysKey = isSysKey;
     this.Character = Character;
     this.Key = System.Windows.Input.KeyInterop.KeyFromVirtualKey(VKCode);
 }
コード例 #2
0
 internal KeyMap(KeyInput charpkey, int vncKey)
 {
     this.charpkey = charpkey;
     this.vncKey = vncKey;
 }
コード例 #3
0
        private static bool ReadChar(KeyInput key, ref char c)
        {
            int virtualKey = KeyInterop.VirtualKeyFromKey(key);
            byte[] keyboardState = new byte[256];
            uint code = NativeMethods.MapVirtualKey((uint)virtualKey, NativeMethods.MapType.MAPVK_VK_TO_VSC);
            StringBuilder sb = new StringBuilder(2);
            int result = NativeMethods.ToUnicode((uint)virtualKey, code, keyboardState, sb, sb.Capacity, 0);
            if (result != -1 && result != 0)
            {
                c = sb[0];
                return true;
            }

            return false;
        }
コード例 #4
0
        /// <summary>
        /// Regist a hotkey, it will return: status code + hot key in string + hot key id
        /// </summary>
        /// <param name="window">wpf window</param>
        /// <param name="hotkeyModifiers"></param>
        /// <param name="key"></param>
        /// <param name="callBack"></param>
        public Tuple <RetCode, string, int> Regist(Window window, uint hotkeyModifiers, System.Windows.Input.Key key, HotKeyCallBackHandler callBack)
        {
            lock (_locker)
            {
                var hotKeyString = GetHotKeyString(hotkeyModifiers, key);
                var hWnd         = IntPtr.Zero;
                if (window != null)
                {
                    var win = new System.Windows.Interop.WindowInteropHelper(window);
                    hWnd = win.Handle;
                    if (!_hookedhWnd.Contains(hWnd) && hWnd != IntPtr.Zero)
                    {
                        var source = System.Windows.Interop.HwndSource.FromHwnd(hWnd);
                        source.AddHook(HookHandel);
                    }
                }

                while (_dictHotKeyId2hWnd.ContainsKey(_hotKeyId))
                {
                    ++_hotKeyId;
                }

                // ref https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-registerhotkey
                var vk = System.Windows.Input.KeyInterop.VirtualKeyFromKey(key);
                if (!RegisterHotKey(hWnd, _hotKeyId, hotkeyModifiers, (uint)vk))    // If the function succeeds, the return value is nonzero.
                {
                    var errorCode = GetLastError();
                    var code      = errorCode == (int)RetCode.ERROR_HOTKEY_ALREADY_REGISTERED ? RetCode.ERROR_HOTKEY_ALREADY_REGISTERED : RetCode.ERROR_HOTKEY_NOT_REGISTERED;
                    return(new Tuple <RetCode, string, int>(code, hotKeyString, 0));
                }

                _hookedhWnd.Add(hWnd);
                _dictHotKeyId2hWnd[_hotKeyId]     = hWnd;
                _dictHotKeyId2CallBack[_hotKeyId] = callBack;

                return(new Tuple <RetCode, string, int>(RetCode.Success, hotKeyString, _hotKeyId));
            }
        }
コード例 #5
0
        private static bool ReadChar(KeyInput key, ModifierKeys modifiers, ref char c)
        {
            int virtualKey = KeyInterop.VirtualKeyFromKey(key);
            uint code = NativeMethods.MapVirtualKey((uint)virtualKey, NativeMethods.MapType.MAPVK_VK_TO_CHAR);
            if (code != 0)
            {
                if ((code >= 'A') && (code <= 'Z') && (modifiers & ModifierKeys.Shift) != ModifierKeys.Shift)
                {
                    code += 0x20;
                }
                c = (char)code;
                return true;
            }

            return false;
        }
コード例 #6
0
        /// <summary>
        /// Responds to key down in application
        /// </summary>
        void input_KeyDown(object sender, WindowsInput.KeyEventArgs e)
        {
            _logger.Debug("input_KeyDown {0} Ctrl({1}) Shift({2})", e.Key, IsControlKeyDown(), IsShiftKeyDown());
            if (IsDuplicateMediaKeyEvent(e.Key))
            {
                _logger.Debug("KeyDown IsDuplicateMediaKeyEvent true:- Key {0} after cmd {1}", e.Key, _lastCmd);
            }
            else
            {
                if (_commandReceived != null)
                {
                    var command = _inputCommandMaps.GetMappedCommand(e.Key, IsControlKeyDown(), IsShiftKeyDown());
                    _commandReceived.Invoke(null, new CommandEventArgs {Command = command});
                }
            }

           _lastKeyDown = e.Key;
           _lastKeyDownTime = DateTime.Now;
        }
コード例 #7
0
ファイル: KeyboardUtil.cs プロジェクト: StEvUgnIn/xwt
		// Missing key translations:
		// * NumPad keys other than 1-9
		// * SysReq, Undo, Redo, Menu, Find, Break, Equal
		// * ShiftLock, MetaLeft, MetaRight
		// * SuperLeft, SuperRight (likely not mappeable for Windows)
		// * Less, Greater, Question, At
		public static Key TranslateToXwtKey (WpfKey key)
		{
			// Letter keys
			if (key >= WpfKey.A && key <= WpfKey.Z) {
				bool upperCase = Keyboard.IsKeyToggled (WpfKey.CapsLock);
				if ((Keyboard.Modifiers & System.Windows.Input.ModifierKeys.Shift) > 0)
					upperCase = !upperCase;
				return upperCase ? (Key)(key + U_Pos) : (Key)(key + L_Pos);
			}

			if (key >= WpfKey.D0 && key <= WpfKey.D9)
				return (Key)(key + D_Pos);

			// Numpad- keys
			if (key >= WpfKey.NumPad0 && key <= WpfKey.NumPad9)
				return (Key)(key + N_Pos);

			// F- keys
			if (key >= WpfKey.F1 && key <= WpfKey.F10)
				return (Key)(key + F_Pos);

			bool isShiftToggled = Keyboard.IsKeyToggled (WpfKey.LeftShift) || Keyboard.IsKeyToggled (WpfKey.RightShift);
			switch (key) {
				case WpfKey.Cancel: return Key.Cancel;
				case WpfKey.Back: return Key.BackSpace;
				case WpfKey.Tab: return Key.Tab;
				case WpfKey.LineFeed: return Key.LineFeed;
				case WpfKey.Clear: return Key.Clear;
				case WpfKey.Return: return Key.Return;
				case WpfKey.Pause: return Key.Pause;
				case WpfKey.CapsLock: return Key.CapsLock;
				case WpfKey.Space: return Key.Space;
				case WpfKey.Escape: return Key.Escape;
				case WpfKey.PageDown: return Key.PageDown;
				case WpfKey.PageUp: return Key.PageUp;
				case WpfKey.End: return Key.End;
				case WpfKey.Home: return Key.Home;
				case WpfKey.Left: return Key.Left;
				case WpfKey.Up: return Key.Up;
				case WpfKey.Right: return Key.Right;
				case WpfKey.Down: return Key.Down;
				case WpfKey.Select: return Key.Select;
				case WpfKey.Print: return Key.Print;
				case WpfKey.Execute: return Key.Execute;
				case WpfKey.Delete: return Key.Delete;
				case WpfKey.Help: return Key.Help;
				case WpfKey.Insert: return Key.Insert;
				case WpfKey.Scroll: return Key.ScrollLock;
				case WpfKey.NumLock: return Key.NumLock;
				case WpfKey.LeftShift: return Key.ShiftLeft;
				case WpfKey.RightShift: return Key.ShiftRight;
				case WpfKey.LeftCtrl: return Key.ControlLeft;
				case WpfKey.RightCtrl: return Key.ControlRight;
				case WpfKey.LeftAlt: return Key.AltLeft;
				case WpfKey.RightAlt: return Key.AltRight;
				case WpfKey.Multiply: return Key.Asterisk;
				case WpfKey.Add: return Key.Plus;
				case WpfKey.OemComma: return isShiftToggled ? Key.Semicolon : Key.Comma;
				case WpfKey.Subtract: return Key.Minus;
				case WpfKey.Divide: return Key.Slash;
				case WpfKey.OemPeriod: return isShiftToggled ? Key.Colon : Key.Period;
			}

			return (Key)0;
		}
コード例 #8
0
        public EventMethod RetrieveEventFromKeyInput(System.Windows.Forms.Keys vkCode, System.Windows.Input.Key inputKey)
        {
            if (Helper.GlobalVariables_CurrentActiveWindowName == Constants.ACTIVE_ATTACK_WIDGET)
            {
                if (inputKey == Key.Enter)
                {
                    if (this.SetActiveAttackCommand.CanExecute(null))
                    {
                        this.SetActiveAttackCommand.Execute(null);
                    }
                }
                else if (inputKey == Key.Escape)
                {
                    if (this.CancelActiveAttackCommand.CanExecute(null))
                    {
                        this.CancelActiveAttackCommand.Execute(null);
                    }
                }
                else if (inputKey == Key.H || inputKey == Key.M || inputKey == Key.S || inputKey == Key.U ||
                         inputKey == Key.Y || inputKey == Key.D || inputKey == Key.K || inputKey == Key.N || inputKey == Key.T ||
                         (inputKey >= Key.D0 && inputKey <= Key.D9) || (inputKey >= Key.NumPad0 && inputKey <= Key.NumPad9))
                {
                    foreach (var defender in this.DefendingCharacters)
                    {
                        if (inputKey == Key.H)
                        {
                            if (!defender.AttackConfigurationMap[AttackConfigKey].Item2.HasMultipleAttackers)
                            {
                                defender.AttackConfigurationMap[AttackConfigKey].Item2.IsHit = true;
                            }
                            else
                            {
                                foreach (var ar in defender.AttackConfigurationMap[AttackConfigKey].Item2.AttackResults)
                                {
                                    ar.IsHit = true;
                                }
                            }
                        }
                        else if (inputKey == Key.M)
                        {
                            if (!defender.AttackConfigurationMap[AttackConfigKey].Item2.HasMultipleAttackers)
                            {
                                defender.AttackConfigurationMap[AttackConfigKey].Item2.IsHit = false;
                            }
                            else
                            {
                                foreach (var ar in defender.AttackConfigurationMap[AttackConfigKey].Item2.AttackResults)
                                {
                                    ar.IsHit = false;
                                }
                            }
                        }
                        else if (inputKey == Key.S)
                        {
                            defender.AttackConfigurationMap[AttackConfigKey].Item2.IsStunned = true;
                        }
                        else if (inputKey == Key.U)
                        {
                            defender.AttackConfigurationMap[AttackConfigKey].Item2.IsUnconcious = true;
                        }
                        else if (inputKey == Key.Y)
                        {
                            defender.AttackConfigurationMap[AttackConfigKey].Item2.IsDying = true;
                        }
                        else if (inputKey == Key.D)
                        {
                            defender.AttackConfigurationMap[AttackConfigKey].Item2.IsDead = true;
                        }
                        else if (inputKey == Key.K)
                        {
                            defender.AttackConfigurationMap[AttackConfigKey].Item2.IsKnockedBack = true;
                        }
                        else if (inputKey == Key.N)
                        {
                            defender.AttackConfigurationMap[AttackConfigKey].Item2.IsKnockedBack = false;
                        }
                        else if (inputKey == Key.T)
                        {
                            defender.AttackConfigurationMap[AttackConfigKey].Item2.MoveAttackerToTarget = true;
                        }
                        else if ((inputKey >= Key.D0 && inputKey <= Key.D9) || (inputKey >= Key.NumPad0 && inputKey <= Key.NumPad9))
                        {
                            var intkey = (inputKey >= Key.D0 && inputKey <= Key.D9) ? inputKey - Key.D0 : inputKey - Key.NumPad0;
                            if (defender.AttackConfigurationMap[AttackConfigKey].Item2.KnockBackDistance > 0)
                            {
                                string current = defender.AttackConfigurationMap[AttackConfigKey].Item2.KnockBackDistance.ToString();
                                current += intkey.ToString();
                                defender.AttackConfigurationMap[AttackConfigKey].Item2.KnockBackDistance = Convert.ToInt32(current);
                            }
                            else
                            {
                                defender.AttackConfigurationMap[AttackConfigKey].Item2.KnockBackDistance = intkey;
                            }
                        }

                        defender.RefreshAttackConfigurationParameters();
                    }
                }
            }
            return(null);
        }
 public EventMethod RetrieveEventFromKeyInput(System.Windows.Forms.Keys vkCode, System.Windows.Input.Key inputKey)
 {
     if (!this.IsReadOnlyMode && Keyboard.Modifiers == ModifierKeys.Control && Helper.GlobalVariables_CurrentActiveWindowName == Constants.CHARACTER_EDITOR)
     {
         if (inputKey == Key.I &&
             this.OptionGroup.Type == OptionType.Identity && this.AddOptionCommand.CanExecute(null))
         {
             this.AddIdentity(null);
         }
         else if (inputKey == Key.M &&
                  this.OptionGroup.Type == OptionType.CharacterMovement && this.AddOptionCommand.CanExecute(null))
         {
             this.AddCharacterMovement(null);
         }
         else if (inputKey == Key.P &&
                  this.OptionGroup.Type == OptionType.Ability && this.AddOptionCommand.CanExecute(null))
         {
             this.AddAbility(null);
         }
         SaveUpdatedOptions();
     }
     else if (!this.IsReadOnlyMode && Keyboard.Modifiers == ModifierKeys.Alt)
     {
         var optionToRemove = SelectedOption;
         if (inputKey == Key.I && this.OptionGroup.Type == OptionType.Identity && this.RemoveOptionCommand.CanExecute(null))
         {
             this.RemoveIdentity(null);
         }
         else if (inputKey == Key.M && this.OptionGroup.Type == OptionType.CharacterMovement && this.RemoveOptionCommand.CanExecute(null))
         {
             this.RemoveCharacterMovement(null);
         }
         else if (inputKey == Key.P && this.OptionGroup.Type == OptionType.Ability && this.RemoveOptionCommand.CanExecute(null))
         {
             optionGroup.Remove(SelectedOption);
         }
         else if (inputKey == Key.X && this.OptionGroup.Type == OptionType.Mixed && this.RemoveOptionCommand.CanExecute(null))
         {
             optionGroup.Remove(SelectedOption);
         }
         this.eventAggregator.GetEvent <RemoveOptionEvent>().Publish(optionToRemove);
         SaveUpdatedOptions();
     }
     return(null);
 }
コード例 #10
0
        public static void keyPressed(System.Windows.Input.Key keyData)
        {
            if (keyboardCommandsDisabled != true)
            {
                // Check modifier keys
                if (keyData == Key.LeftShift || keyData == Key.RightShift)
                {
                    shiftModifierDown = true;
                }


                //ATC
                if (keyData == System.Windows.Input.Key.D1)
                {
                    commands.atc1();
                }
                else if (keyData == System.Windows.Input.Key.D2)
                {
                    commands.atc2();
                }
                else if (keyData == System.Windows.Input.Key.D3)
                {
                    commands.atc3();
                }
                else if (keyData == System.Windows.Input.Key.D4)
                {
                    commands.atc4();
                }
                else if (keyData == System.Windows.Input.Key.D5)
                {
                    commands.atc5();
                }
                else if (keyData == System.Windows.Input.Key.D6)
                {
                    commands.atc6();
                }
                else if (keyData == System.Windows.Input.Key.D7)
                {
                    commands.atc7();
                }
                else if (keyData == System.Windows.Input.Key.D8)
                {
                    commands.atc8();
                }
                else if (keyData == System.Windows.Input.Key.D9)
                {
                    commands.atc9();
                }
                else if (keyData == System.Windows.Input.Key.D0)
                {
                    commands.atc10();
                }
                else if (keyData == System.Windows.Input.Key.A)
                {
                    //toggle atc window
                    commands.atcMenu();
                }

                //flight controls
                if (keyData == System.Windows.Input.Key.G)
                {
                    //toggle landing gear
                    commands.landingGear();
                }
                else if (keyData == System.Windows.Input.Key.P)
                {
                    //shift + p
                    //pushback
                    commands.pushback();
                }
                else if (keyData == System.Windows.Input.Key.Space)
                {
                    //pause
                    commands.pause();
                }
                else if (keyData == System.Windows.Input.Key.OemPeriod)
                {
                    //brake
                    commands.parkingBrake();
                }
                else if (keyData == System.Windows.Input.Key.OemOpenBrackets)
                {
                    //retract flaps
                    commands.flapsUp();
                }

                else if (keyData == System.Windows.Input.Key.OemCloseBrackets)
                {
                    //extend flaps
                    commands.flapsDown();
                }
                else if (keyData == System.Windows.Input.Key.OemQuestion)
                {
                    //spoilers
                    commands.spoilers();
                }
                else if (keyData == System.Windows.Input.Key.L)
                {
                    //kanding lights
                    commands.landing();
                }
                else if (keyData == System.Windows.Input.Key.S)
                {
                    //strobe
                    commands.strobe();
                }
                else if (keyData == System.Windows.Input.Key.N)
                {
                    //nav
                    commands.nav();
                }
                else if (keyData == System.Windows.Input.Key.B)
                {
                    //beacon
                    commands.beacon();
                }
                else if (keyData == System.Windows.Input.Key.Z)
                {
                    //toggle autopilot
                    commands.autopilot();
                }
                else if (keyData == System.Windows.Input.Key.OemMinus)
                {
                    //zoomout
                    commands.zoomOut();
                }
                else if (keyData == System.Windows.Input.Key.OemPlus)
                {
                    //zoomout
                    commands.zoomIn();
                }
                else if ((keyData == System.Windows.Input.Key.Up) && shiftModifierDown)
                {
                    //move up
                    commands.movePOV(0);
                }
                else if ((keyData == System.Windows.Input.Key.Down) && shiftModifierDown)
                {
                    //move down
                    commands.movePOV(18000);
                }
                else if ((keyData == System.Windows.Input.Key.Left) && shiftModifierDown)
                {
                    //move left
                    commands.movePOV(27000);
                }
                else if ((keyData == System.Windows.Input.Key.Right) && shiftModifierDown)
                {
                    //move right
                    commands.movePOV(9000);
                }
                else if (keyData == System.Windows.Input.Key.Up)
                {
                    //move pitch down
                    commands.pitchDown();
                }
                else if (keyData == System.Windows.Input.Key.Down)
                {
                    //move pitch up
                    commands.pitchUp();
                }
                else if (keyData == System.Windows.Input.Key.Left)
                {
                    //move roll left
                    commands.rollLeft();
                }
                else if (keyData == System.Windows.Input.Key.Right)
                {
                    //move roll right
                    commands.rollRight();
                }
                else if (keyData == System.Windows.Input.Key.D)
                {
                    //increase throttle
                    commands.increaseThrottle();
                }
                else if (keyData == System.Windows.Input.Key.C)
                {
                    //decrease throttle
                    commands.decreaseThrottle();
                }
                else if (keyData == System.Windows.Input.Key.E)
                {
                    //Next Camera
                    commands.nextCamera();
                }
                else if (keyData == System.Windows.Input.Key.Q)
                {
                    //previous Camera
                    commands.previousCamera();
                }
            }
            else
            {
                Console.WriteLine("Ignoring keyboard command input...");
            }
        }
コード例 #11
0
ファイル: GuiHelper_Controls.cs プロジェクト: olesar/Altaxo
        public static AltaxoKeyboardKey ToAltaxo(System.Windows.Input.Key key)
        {
            switch (key)
            {
            case Key.None:
                return(AltaxoKeyboardKey.None);

            case Key.Cancel:
                return(AltaxoKeyboardKey.Cancel);

            case Key.Back:
                return(AltaxoKeyboardKey.Back);

            case Key.Tab:
                return(AltaxoKeyboardKey.Tab);

            case Key.LineFeed:
                return(AltaxoKeyboardKey.LineFeed);

            case Key.Clear:
                return(AltaxoKeyboardKey.Clear);

            case Key.Return:
                return(AltaxoKeyboardKey.Return);

            case Key.Pause:
                return(AltaxoKeyboardKey.Pause);

            case Key.Capital:
                return(AltaxoKeyboardKey.Capital);

            case Key.KanaMode:
                return(AltaxoKeyboardKey.KanaMode);

            case Key.JunjaMode:
                return(AltaxoKeyboardKey.JunjaMode);

            case Key.FinalMode:
                return(AltaxoKeyboardKey.FinalMode);

            case Key.HanjaMode:
                return(AltaxoKeyboardKey.HanjaMode);

            case Key.Escape:
                return(AltaxoKeyboardKey.Escape);

            case Key.ImeConvert:
                return(AltaxoKeyboardKey.ImeConvert);

            case Key.ImeNonConvert:
                return(AltaxoKeyboardKey.ImeNonConvert);

            case Key.ImeAccept:
                return(AltaxoKeyboardKey.ImeAccept);

            case Key.ImeModeChange:
                return(AltaxoKeyboardKey.ImeModeChange);

            case Key.Space:
                return(AltaxoKeyboardKey.Space);

            case Key.PageUp:
                return(AltaxoKeyboardKey.PageUp);

            case Key.Next:
                return(AltaxoKeyboardKey.Next);

            case Key.End:
                return(AltaxoKeyboardKey.End);

            case Key.Home:
                return(AltaxoKeyboardKey.Home);

            case Key.Left:
                return(AltaxoKeyboardKey.Left);

            case Key.Up:
                return(AltaxoKeyboardKey.Up);

            case Key.Right:
                return(AltaxoKeyboardKey.Right);

            case Key.Down:
                return(AltaxoKeyboardKey.Down);

            case Key.Select:
                return(AltaxoKeyboardKey.Select);

            case Key.Print:
                return(AltaxoKeyboardKey.Print);

            case Key.Execute:
                return(AltaxoKeyboardKey.Execute);

            case Key.Snapshot:
                return(AltaxoKeyboardKey.Snapshot);

            case Key.Insert:
                return(AltaxoKeyboardKey.Insert);

            case Key.Delete:
                return(AltaxoKeyboardKey.Delete);

            case Key.Help:
                return(AltaxoKeyboardKey.Help);

            case Key.D0:
                return(AltaxoKeyboardKey.D0);

            case Key.D1:
                return(AltaxoKeyboardKey.D1);

            case Key.D2:
                return(AltaxoKeyboardKey.D2);

            case Key.D3:
                return(AltaxoKeyboardKey.D3);

            case Key.D4:
                return(AltaxoKeyboardKey.D4);

            case Key.D5:
                return(AltaxoKeyboardKey.D5);

            case Key.D6:
                return(AltaxoKeyboardKey.D6);

            case Key.D7:
                return(AltaxoKeyboardKey.D7);

            case Key.D8:
                return(AltaxoKeyboardKey.D8);

            case Key.D9:
                return(AltaxoKeyboardKey.D9);

            case Key.A:
                return(AltaxoKeyboardKey.A);

            case Key.B:
                return(AltaxoKeyboardKey.B);

            case Key.C:
                return(AltaxoKeyboardKey.C);

            case Key.D:
                return(AltaxoKeyboardKey.D);

            case Key.E:
                return(AltaxoKeyboardKey.E);

            case Key.F:
                return(AltaxoKeyboardKey.F);

            case Key.G:
                return(AltaxoKeyboardKey.G);

            case Key.H:
                return(AltaxoKeyboardKey.H);

            case Key.I:
                return(AltaxoKeyboardKey.I);

            case Key.J:
                return(AltaxoKeyboardKey.J);

            case Key.K:
                return(AltaxoKeyboardKey.K);

            case Key.L:
                return(AltaxoKeyboardKey.L);

            case Key.M:
                return(AltaxoKeyboardKey.M);

            case Key.N:
                return(AltaxoKeyboardKey.N);

            case Key.O:
                return(AltaxoKeyboardKey.O);

            case Key.P:
                return(AltaxoKeyboardKey.P);

            case Key.Q:
                return(AltaxoKeyboardKey.Q);

            case Key.R:
                return(AltaxoKeyboardKey.R);

            case Key.S:
                return(AltaxoKeyboardKey.S);

            case Key.T:
                return(AltaxoKeyboardKey.T);

            case Key.U:
                return(AltaxoKeyboardKey.U);

            case Key.V:
                return(AltaxoKeyboardKey.V);

            case Key.W:
                return(AltaxoKeyboardKey.W);

            case Key.X:
                return(AltaxoKeyboardKey.X);

            case Key.Y:
                return(AltaxoKeyboardKey.Y);

            case Key.Z:
                return(AltaxoKeyboardKey.Z);

            case Key.LWin:
                return(AltaxoKeyboardKey.LWin);

            case Key.RWin:
                return(AltaxoKeyboardKey.RWin);

            case Key.Apps:
                return(AltaxoKeyboardKey.Apps);

            case Key.Sleep:
                return(AltaxoKeyboardKey.Sleep);

            case Key.NumPad0:
                return(AltaxoKeyboardKey.NumPad0);

            case Key.NumPad1:
                return(AltaxoKeyboardKey.NumPad1);

            case Key.NumPad2:
                return(AltaxoKeyboardKey.NumPad2);

            case Key.NumPad3:
                return(AltaxoKeyboardKey.NumPad3);

            case Key.NumPad4:
                return(AltaxoKeyboardKey.NumPad4);

            case Key.NumPad5:
                return(AltaxoKeyboardKey.NumPad5);

            case Key.NumPad6:
                return(AltaxoKeyboardKey.NumPad6);

            case Key.NumPad7:
                return(AltaxoKeyboardKey.NumPad7);

            case Key.NumPad8:
                return(AltaxoKeyboardKey.NumPad8);

            case Key.NumPad9:
                return(AltaxoKeyboardKey.NumPad9);

            case Key.Multiply:
                return(AltaxoKeyboardKey.Multiply);

            case Key.Add:
                return(AltaxoKeyboardKey.Add);

            case Key.Separator:
                return(AltaxoKeyboardKey.Separator);

            case Key.Subtract:
                return(AltaxoKeyboardKey.Subtract);

            case Key.Decimal:
                return(AltaxoKeyboardKey.Decimal);

            case Key.Divide:
                return(AltaxoKeyboardKey.Divide);

            case Key.F1:
                return(AltaxoKeyboardKey.F1);

            case Key.F2:
                return(AltaxoKeyboardKey.F2);

            case Key.F3:
                return(AltaxoKeyboardKey.F3);

            case Key.F4:
                return(AltaxoKeyboardKey.F4);

            case Key.F5:
                return(AltaxoKeyboardKey.F5);

            case Key.F6:
                return(AltaxoKeyboardKey.F6);

            case Key.F7:
                return(AltaxoKeyboardKey.F7);

            case Key.F8:
                return(AltaxoKeyboardKey.F8);

            case Key.F9:
                return(AltaxoKeyboardKey.F9);

            case Key.F10:
                return(AltaxoKeyboardKey.F10);

            case Key.F11:
                return(AltaxoKeyboardKey.F11);

            case Key.F12:
                return(AltaxoKeyboardKey.F12);

            case Key.F13:
                return(AltaxoKeyboardKey.F13);

            case Key.F14:
                return(AltaxoKeyboardKey.F14);

            case Key.F15:
                return(AltaxoKeyboardKey.F15);

            case Key.F16:
                return(AltaxoKeyboardKey.F16);

            case Key.F17:
                return(AltaxoKeyboardKey.F17);

            case Key.F18:
                return(AltaxoKeyboardKey.F18);

            case Key.F19:
                return(AltaxoKeyboardKey.F19);

            case Key.F20:
                return(AltaxoKeyboardKey.F20);

            case Key.F21:
                return(AltaxoKeyboardKey.F21);

            case Key.F22:
                return(AltaxoKeyboardKey.F22);

            case Key.F23:
                return(AltaxoKeyboardKey.F23);

            case Key.F24:
                return(AltaxoKeyboardKey.F24);

            case Key.NumLock:
                return(AltaxoKeyboardKey.NumLock);

            case Key.Scroll:
                return(AltaxoKeyboardKey.Scroll);

            case Key.LeftShift:
                return(AltaxoKeyboardKey.LeftShift);

            case Key.RightShift:
                return(AltaxoKeyboardKey.RightShift);

            case Key.LeftCtrl:
                return(AltaxoKeyboardKey.LeftCtrl);

            case Key.RightCtrl:
                return(AltaxoKeyboardKey.RightCtrl);

            case Key.LeftAlt:
                return(AltaxoKeyboardKey.LeftAlt);

            case Key.RightAlt:
                return(AltaxoKeyboardKey.RightAlt);

            case Key.BrowserBack:
                return(AltaxoKeyboardKey.BrowserBack);

            case Key.BrowserForward:
                return(AltaxoKeyboardKey.BrowserForward);

            case Key.BrowserRefresh:
                return(AltaxoKeyboardKey.BrowserRefresh);

            case Key.BrowserStop:
                return(AltaxoKeyboardKey.BrowserStop);

            case Key.BrowserSearch:
                return(AltaxoKeyboardKey.BrowserSearch);

            case Key.BrowserFavorites:
                return(AltaxoKeyboardKey.BrowserFavorites);

            case Key.BrowserHome:
                return(AltaxoKeyboardKey.BrowserHome);

            case Key.VolumeMute:
                return(AltaxoKeyboardKey.VolumeMute);

            case Key.VolumeDown:
                return(AltaxoKeyboardKey.VolumeDown);

            case Key.VolumeUp:
                return(AltaxoKeyboardKey.VolumeUp);

            case Key.MediaNextTrack:
                return(AltaxoKeyboardKey.MediaNextTrack);

            case Key.MediaPreviousTrack:
                return(AltaxoKeyboardKey.MediaPreviousTrack);

            case Key.MediaStop:
                return(AltaxoKeyboardKey.MediaStop);

            case Key.MediaPlayPause:
                return(AltaxoKeyboardKey.MediaPlayPause);

            case Key.LaunchMail:
                return(AltaxoKeyboardKey.LaunchMail);

            case Key.SelectMedia:
                return(AltaxoKeyboardKey.SelectMedia);

            case Key.LaunchApplication1:
                return(AltaxoKeyboardKey.LaunchApplication1);

            case Key.LaunchApplication2:
                return(AltaxoKeyboardKey.LaunchApplication2);

            case Key.Oem1:
                return(AltaxoKeyboardKey.Oem1);

            case Key.OemPlus:
                return(AltaxoKeyboardKey.OemPlus);

            case Key.OemComma:
                return(AltaxoKeyboardKey.OemComma);

            case Key.OemMinus:
                return(AltaxoKeyboardKey.OemMinus);

            case Key.OemPeriod:
                return(AltaxoKeyboardKey.OemPeriod);

            case Key.OemQuestion:
                return(AltaxoKeyboardKey.OemQuestion);

            case Key.Oem3:
                return(AltaxoKeyboardKey.Oem3);

            case Key.AbntC1:
                return(AltaxoKeyboardKey.AbntC1);

            case Key.AbntC2:
                return(AltaxoKeyboardKey.AbntC2);

            case Key.OemOpenBrackets:
                return(AltaxoKeyboardKey.OemOpenBrackets);

            case Key.Oem5:
                return(AltaxoKeyboardKey.Oem5);

            case Key.Oem6:
                return(AltaxoKeyboardKey.Oem6);

            case Key.OemQuotes:
                return(AltaxoKeyboardKey.OemQuotes);

            case Key.Oem8:
                return(AltaxoKeyboardKey.Oem8);

            case Key.OemBackslash:
                return(AltaxoKeyboardKey.OemBackslash);

            case Key.ImeProcessed:
                return(AltaxoKeyboardKey.ImeProcessed);

            case Key.System:
                return(AltaxoKeyboardKey.System);

            case Key.OemAttn:
                return(AltaxoKeyboardKey.OemAttn);

            case Key.OemFinish:
                return(AltaxoKeyboardKey.OemFinish);

            case Key.OemCopy:
                return(AltaxoKeyboardKey.OemCopy);

            case Key.DbeSbcsChar:
                return(AltaxoKeyboardKey.DbeSbcsChar);

            case Key.OemEnlw:
                return(AltaxoKeyboardKey.OemEnlw);

            case Key.OemBackTab:
                return(AltaxoKeyboardKey.OemBackTab);

            case Key.DbeNoRoman:
                return(AltaxoKeyboardKey.DbeNoRoman);

            case Key.DbeEnterWordRegisterMode:
                return(AltaxoKeyboardKey.DbeEnterWordRegisterMode);

            case Key.DbeEnterImeConfigureMode:
                return(AltaxoKeyboardKey.DbeEnterImeConfigureMode);

            case Key.EraseEof:
                return(AltaxoKeyboardKey.EraseEof);

            case Key.Play:
                return(AltaxoKeyboardKey.Play);

            case Key.DbeNoCodeInput:
                return(AltaxoKeyboardKey.DbeNoCodeInput);

            case Key.NoName:
                return(AltaxoKeyboardKey.NoName);

            case Key.Pa1:
                return(AltaxoKeyboardKey.Pa1);

            case Key.OemClear:
                return(AltaxoKeyboardKey.OemClear);

            case Key.DeadCharProcessed:
                return(AltaxoKeyboardKey.DeadCharProcessed);

            default:
                throw new NotImplementedException("Unknown key");
            }
            ;
        }
コード例 #12
0
 public EventMethod RetrieveEventFromKeyInput(System.Windows.Forms.Keys vkCode, System.Windows.Input.Key inputKey)
 {
     if (Helper.GlobalVariables_CurrentActiveWindowName == Constants.MOVEMENT_EDITOR)
     {
         if (inputKey == Key.N && Keyboard.Modifiers == ModifierKeys.Control)
         {
             if (this.SpawnModelsCommand.CanExecute(null))
             {
                 this.SpawnModelsCommand.Execute(null);
             }
         }
         else if ((inputKey == Key.OemMinus || inputKey == Key.Subtract || inputKey == Key.Delete) && Keyboard.Modifiers == ModifierKeys.Control)
         {
             if (this.ClearFromDesktopCommand.CanExecute(null))
             {
                 this.ClearFromDesktopCommand.Execute(null);
             }
         }
         else if (inputKey == Key.S && Keyboard.Modifiers == ModifierKeys.Control)
         {
             if (this.SaveCrowdCommand.CanExecute(null))
             {
                 this.SaveCrowdCommand.Execute(null);
             }
         }
     }
     return(null);
 }
コード例 #13
0
 static Keys GetKeyConversion(SWI.Key slKey)
 {
     Debug.Assert((int)slKey < 256);
     return(SilverlightToXna[(int)slKey]);
 }
コード例 #14
0
 static void SetKeyConversion(SWI.Key slKey, Keys xnaKey)
 {
     Debug.Assert((int)slKey < 256);
     SilverlightToXna[(int)slKey] = xnaKey;
 }
コード例 #15
0
 private bool IsUpDownKey(Key key)
 {
     return key == Key.Up || key == Key.Down;
 }
コード例 #16
0
        // Missing key translations:
        // * NumPad keys other than 1-9
        // * SysReq, Undo, Redo, Menu, Find, Break, Equal
        // * ShiftLock, MetaLeft, MetaRight
        // * SuperLeft, SuperRight (likely not mappeable for Windows)
        // * Less, Greater, Question, At
        public static Key TranslateToXwtKey(WpfKey key)
        {
            // Letter keys
            if (key >= WpfKey.A && key <= WpfKey.Z)
            {
                bool upperCase = Keyboard.IsKeyToggled(WpfKey.CapsLock);
                if ((Keyboard.Modifiers & System.Windows.Input.ModifierKeys.Shift) > 0)
                {
                    upperCase = !upperCase;
                }
                return(upperCase ? (Key)(key + U_Pos) : (Key)(key + L_Pos));
            }

            if (key >= WpfKey.D0 && key <= WpfKey.D9)
            {
                return((Key)(key + D_Pos));
            }

            // Numpad- keys
            if (key >= WpfKey.NumPad0 && key <= WpfKey.NumPad9)
            {
                return((Key)(key + N_Pos));
            }

            // F- keys
            if (key >= WpfKey.F1 && key <= WpfKey.F10)
            {
                return((Key)(key + F_Pos));
            }

            bool isShiftToggled = Keyboard.IsKeyToggled(WpfKey.LeftShift) || Keyboard.IsKeyToggled(WpfKey.RightShift);

            switch (key)
            {
            case WpfKey.Cancel: return(Key.Cancel);

            case WpfKey.Back: return(Key.BackSpace);

            case WpfKey.Tab: return(Key.Tab);

            case WpfKey.LineFeed: return(Key.LineFeed);

            case WpfKey.Clear: return(Key.Clear);

            case WpfKey.Return: return(Key.Return);

            case WpfKey.Pause: return(Key.Pause);

            case WpfKey.CapsLock: return(Key.CapsLock);

            case WpfKey.Space: return(Key.Space);

            case WpfKey.Escape: return(Key.Escape);

            case WpfKey.PageDown: return(Key.PageDown);

            case WpfKey.PageUp: return(Key.PageUp);

            case WpfKey.End: return(Key.End);

            case WpfKey.Home: return(Key.Home);

            case WpfKey.Left: return(Key.Left);

            case WpfKey.Up: return(Key.Up);

            case WpfKey.Right: return(Key.Right);

            case WpfKey.Down: return(Key.Down);

            case WpfKey.Select: return(Key.Select);

            case WpfKey.Print: return(Key.Print);

            case WpfKey.Execute: return(Key.Execute);

            case WpfKey.Delete: return(Key.Delete);

            case WpfKey.Help: return(Key.Help);

            case WpfKey.Insert: return(Key.Insert);

            case WpfKey.Scroll: return(Key.ScrollLock);

            case WpfKey.NumLock: return(Key.NumLock);

            case WpfKey.LeftShift: return(Key.ShiftLeft);

            case WpfKey.RightShift: return(Key.ShiftRight);

            case WpfKey.LeftCtrl: return(Key.ControlLeft);

            case WpfKey.RightCtrl: return(Key.ControlRight);

            case WpfKey.LeftAlt: return(Key.AltLeft);

            case WpfKey.RightAlt: return(Key.AltRight);

            case WpfKey.Multiply: return(Key.Asterisk);

            case WpfKey.Add: return(Key.Plus);

            case WpfKey.OemComma: return(isShiftToggled ? Key.Semicolon : Key.Comma);

            case WpfKey.Subtract: return(Key.Minus);

            case WpfKey.Divide: return(Key.Slash);

            case WpfKey.OemPeriod: return(isShiftToggled ? Key.Colon : Key.Period);

            case WpfKey.Oem5: return(Key.Caret);

            case WpfKey.OemPlus: return(Key.Plus);

            case WpfKey.OemMinus: return(Key.Minus);

            case WpfKey.OemQuestion: return(Key.Question);
            }

            return((Key)0);
        }
コード例 #17
0
 private bool IsVirtualKeyboardControlKey(Key key)
 {
     switch (key)
     {
         case Key.Left:
         case Key.Right:
         case Key.Up:
         case Key.Down:
         case Key.Enter:
         case Key.Escape:
         case Key.Multiply:
         case Key.D8:
         case Key.LeftShift:
             return true;
         default:
             return false;
     }
 }
 public EventMethod RetrieveEventFromKeyInput(System.Windows.Forms.Keys vkCode, System.Windows.Input.Key inputKey)
 {
     if (Helper.GlobalVariables_CurrentActiveWindowName == Constants.ACTIVE_ATTACK_WIDGET)
     {
         if (inputKey == Key.Enter)
         {
             if (this.ConfirmAttacksCommand.CanExecute(null))
             {
                 this.ConfirmAttacksCommand.Execute(null);
             }
         }
         else if (inputKey == Key.Escape)
         {
             if (this.CancelAttacksCommand.CanExecute())
             {
                 this.CancelAttacksCommand.Execute();
             }
         }
     }
     return(null);
 }
コード例 #19
0
        private void mainForm_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {
            System.Windows.Input.Key key = new System.Windows.Input.Key();
            key = Key.Enter;

            if(e.Key == key)
                if(labelLog.Visibility != Visibility.Hidden)
                    login();

        }
コード例 #20
0
 public IDelegateCommand AddKeyGesture(System.Windows.Input.Key key)
 {
     return(this.AddKeyGesture(key, ModifierKeys.None));
 }
コード例 #21
0
ファイル: WindowsSpinButton.xaml.cs プロジェクト: Jeha/xwt
 private void textBox_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
 {
     if (e.Key == Key.Return || e.Key == Key.Tab)
         parseTextBox();
     else if (e.Key == Key.Up)
     {
         IncreaseValue(Increment);
         StartKeyboardTimer();
     }
     else if (e.Key == Key.Down)
     {
         DecreaseValue(Increment);
         StartKeyboardTimer();
     }
     else if (e.Key == Key.PageDown)
     {
         DecreaseValue(Increment * 10);
         StartKeyboardTimer();
     }
     else if (e.Key == Key.PageUp)
     {
         IncreaseValue(Increment * 10);
         StartKeyboardTimer();
     }
     pressedKey = e.Key;
 }
コード例 #22
0
 /// <summary>
 /// Regist a hotkey, it will return: status code + hot key in string + hot key id
 /// </summary>
 public Tuple <RetCode, string, int> Regist(Window window, HotkeyModifiers hotkeyModifiers, System.Windows.Input.Key key, HotKeyCallBackHandler callBack)
 {
     return(Regist(window, (uint)hotkeyModifiers, key, callBack));
 }