Beispiel #1
0
 private void RaisePressedEvents(GameTime gameTime, KeyboardState currentState)
 {
     if (currentState.IsKeyDown(Keys.LeftAlt) || currentState.IsKeyDown(Keys.RightAlt))
     {
         return;
     }
     foreach (Keys key in this._keysValues.Cast <Keys>().Where <Keys>((Func <Keys, bool>)(key => currentState.IsKeyDown(key) && this._previousState.IsKeyUp(key))))
     {
         WpfKeyboardEventArgs e = new WpfKeyboardEventArgs(key, currentState);
         EventHandler <WpfKeyboardEventArgs> keyPressed = this.KeyPressed;
         if (keyPressed != null)
         {
             keyPressed((object)this, e);
         }
         if (e.Character.HasValue)
         {
             EventHandler <WpfKeyboardEventArgs> keyTyped = this.KeyTyped;
             if (keyTyped != null)
             {
                 keyTyped((object)this, e);
             }
         }
         this._previousKey   = key;
         this._lastPressTime = gameTime.TotalGameTime;
         this._isInitial     = true;
     }
 }
Beispiel #2
0
        private void RaiseRepeatEvents(GameTime gameTime, KeyboardState currentState)
        {
            double totalMilliseconds = (gameTime.TotalGameTime - this._lastPressTime).TotalMilliseconds;

            if (!currentState.IsKeyDown(this._previousKey) || (!this._isInitial || totalMilliseconds <= (double)this.InitialDelay) && (this._isInitial || totalMilliseconds <= (double)this.RepeatDelay))
            {
                return;
            }
            WpfKeyboardEventArgs e = new WpfKeyboardEventArgs(this._previousKey, currentState);
            EventHandler <WpfKeyboardEventArgs> keyPressed = this.KeyPressed;

            if (keyPressed != null)
            {
                keyPressed((object)this, e);
            }
            if (e.Character.HasValue)
            {
                EventHandler <WpfKeyboardEventArgs> keyTyped = this.KeyTyped;
                if (keyTyped != null)
                {
                    keyTyped((object)this, e);
                }
            }
            this._lastPressTime = gameTime.TotalGameTime;
            this._isInitial     = false;
        }