コード例 #1
0
ファイル: OneClickToolBase.cs プロジェクト: ProSuite/ProSuite
        protected override void OnToolKeyUp(MapViewKeyEventArgs k)
        {
            _msg.VerboseDebug("OnToolKeyUp");

            try
            {
                QueuedTaskUtils.Run(
                    delegate
                {
                    if (IsShiftKey(k.Key))
                    {
                        ShiftReleasedCore();
                    }

                    OnKeyUpCore(k);
                    return(true);
                });
            }
            catch (Exception e)
            {
                HandleError($"Error in tool key up ({Caption}): {e.Message}", e, true);
            }
            finally
            {
                PressedKeys.Remove(k.Key);
            }
        }
コード例 #2
0
        private void keyUp(object sender, KeyEventArgs e)
        {
            Key tkKey = getTkKeyFrom(e.KeyCode);

            if (tkKey != Key.Unknown)
            {
                PressedKeys.Remove(tkKey);
            }
        }
コード例 #3
0
ファイル: BaseKeyboard.cs プロジェクト: uta-org/SharpNeedle
        /// <summary>
        ///     Releases the specified virtual key to the window.
        /// </summary>
        /// <param name="key">The virtual key to release.</param>
        public virtual void Release(Keys key)
        {
            // Create the tuple
            var tuple = Tuple.Create(Window.Handle, key);

            // If the key is pressed with an interval
            if (PressedKeys.Contains(tuple))
            {
                PressedKeys.Remove(tuple);
            }
        }
コード例 #4
0
 /// <summary>
 /// Simulate key release
 /// </summary>
 public void KeyRelease(Keys key)
 {
     if (PressedKeys.Contains(key))
     {
         PressedKeys.Remove(key);
     }
     if (SimulatedKeys.Contains(key))
     {
         SimulatedKeys.Remove(key);
     }
 }
コード例 #5
0
        private void OnKeyPressed(object sender, GlobalKeyboardHookEventArgs e)
        {
            // https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx

            // Remote Play not found
            if (CurrentProcess == null)
            {
                return;
            }

            // Check for active window
            var activeWindow = GetForegroundWindow();

            if (activeWindow != IntPtr.Zero)
            {
                if (activeWindow != CurrentProcess.MainWindowHandle)
                {
                    return;
                }
            }

            int  vk  = e.KeyboardData.VirtualCode;
            Keys key = (Keys)vk;

            //System.Diagnostics.Debug.WriteLine("KEY: " + vk);

            if (e.KeyboardState == GlobalKeyboardHook.KeyboardState.KeyDown)
            {
                //System.Diagnostics.Debug.WriteLine("KEY DOWN");

                if (!PressedKeys.ContainsKey(key))
                {
                    PressedKeys.Add(key, true);
                }

                e.Handled = true;
            }
            else if (e.KeyboardState == GlobalKeyboardHook.KeyboardState.KeyUp)
            {
                //System.Diagnostics.Debug.WriteLine("KEY UP");

                if (PressedKeys.ContainsKey(key))
                {
                    PressedKeys.Remove(key);
                }

                e.Handled = true;
            }
        }
コード例 #6
0
        public void OnKeyUp(KeyEventArgs e)
        {
            Handler.KeyInPutHandler(this, e.KeyCode, KeyHandlerAction.Up);
            while (PressedKeys.Contains(e.KeyData))
            {
                PressedKeys.Remove(e.KeyData);
            }
            if (e.KeyData != Keys.Space)
            {
                return;
            }
            Field.AddObject(AddableObjects.Mine, this, MainPlayer.CenterPosition());
            var obj = Field.Objects.Last();

            obj.Position = obj.Position.Sub(obj.Size.Div(2));
        }
コード例 #7
0
ファイル: KeyboardInput.cs プロジェクト: lukastk/TakaGUI
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            ReleasedKeys.Clear();
            ClickedKeys.Clear();

            KeyboardState state = Keyboard.GetState();

            foreach (IPressedKey pressedKey in new List <IPressedKey>(PressedKeys))
            {
                bool isPressed = false;
                foreach (Keys key in state.GetPressedKeys())
                {
                    if (key == pressedKey.Key)
                    {
                        isPressed = true;
                    }
                }

                if (!isPressed)
                {
                    PressedKeys.Remove(pressedKey);
                    ReleasedKeys.Add(pressedKey.Key);
                }
            }

            foreach (Keys key in state.GetPressedKeys())
            {
                bool isAlreadyPressed = false;

                foreach (IPressedKey pressedKey in PressedKeys)
                {
                    if (key == pressedKey.Key)
                    {
                        isAlreadyPressed = true;
                    }
                }

                if (!isAlreadyPressed)
                {
                    PressedKeys.Add(new PressedKey(key, gameTime.TotalGameTime.TotalSeconds));
                    ClickedKeys.Add(key);
                }
            }
        }
コード例 #8
0
ファイル: Remapper.cs プロジェクト: MrDadosz/PS4Macro
        public void OnKeyPressed(object sender, GlobalKeyboardHookEventArgs e)
        {
            // https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx

            if (!CheckFocusedWindow())
            {
                return;
            }

            int  vk  = e.KeyboardData.VirtualCode;
            Keys key = (Keys)vk;

            // Key down
            if (e.KeyboardState == GlobalKeyboardHook.KeyboardState.KeyDown)
            {
                if (!PressedKeys.ContainsKey(key))
                {
                    PressedKeys.Add(key, true);
                    ExecuteActionsByKey(PressedKeys.Keys.ToList());
                }

                e.Handled = true;
            }
            // Key up
            else if (e.KeyboardState == GlobalKeyboardHook.KeyboardState.KeyUp)
            {
                if (PressedKeys.ContainsKey(key))
                {
                    PressedKeys.Remove(key);
                    ExecuteActionsByKey(PressedKeys.Keys.ToList());
                }

                e.Handled = true;
            }

            // Reset state
            if (!IsKeyDown())
            {
                CurrentState = null;
            }
        }