public void KeyReleased(object sender, KeyboardEventArgs e)
 {
     switch (e.key_)
     {
         case Keys.W:
             if (keys[0])
                 dir_dirty = true;
             keys[0] = false;
             break;
         case Keys.A:
             if (keys[0])
                 dir_dirty = true;
             keys[1] = false;
             break;
         case Keys.S:
             if (keys[0])
                 dir_dirty = true;
             keys[2] = false;
             break;
         case Keys.D:
             if (keys[0])
                 dir_dirty = true;
             keys[3] = false;
             break;
     }
 }
Esempio n. 2
0
 public override void KeyboardDown(KeyboardEventArgs args)
 {
     if (args.Key == Key.DownArrow
         || args.Key == Key.UpArrow) {
         listbox.KeyboardDown (args);
     }
     else
         base.KeyboardDown (args);
 }
Esempio n. 3
0
 public override void KeyboardDown(KeyboardEventArgs args)
 {
     if (args.Key == Key.Escape
         || args.Key == Key.Return
         || args.Key == Key.Space) {
         player.Stop ();
         PlayerFinished ();
     }
 }
        public void CustomKeyButton_KeyPressedEvent(object sender, CustomKeyButton.KeyPressedEventArgs e)
        {
            CustomKeyButton.CustomKeyButton ckb = (CustomKeyButton.CustomKeyButton)sender;

            switch (e.KeyboardKeyPressed)
            {
                case "CLR":
                    SendKeys.Send("{BACKSPACE}");
                    break;
                default:
                    SendKeys.Send(e.KeyboardKeyPressed);
                    break;
            }

            //Raise Key Pressed Event
            KeyboardEventArgs dea = new KeyboardEventArgs(e.KeyboardKeyPressed);
            OnUserKeyPressed(dea);
        }
Esempio n. 5
0
        public void KeyboardDown(KeyboardEventArgs args)
        {
            bool changed = false;

            /* navigation keys */
            if (args.Key == Key.LeftArrow) {
                if (cursor > 0) cursor--;
            }
            else if (args.Key == Key.RightArrow) {
                if (cursor < value.Length) cursor++;
            }
            else if (args.Key == Key.Home) {
                cursor = 0;
            }
            else if (args.Key == Key.End) {
                cursor = value.Length;
            }
            /* keys that modify the text */
            else if (args.Key == Key.Backspace) {
                if (value.Length > 0) {
                    value = value.Remove (cursor-1, 1);
                    cursor--;
                    changed = true;
                }
            }
            else {
                char[] cs = Encoding.ASCII.GetChars (new byte[] {(byte)args.Key});
                foreach (char c in cs) {
                    if (!Char.IsLetterOrDigit (c) && c != ' ')
                        continue;
                    char cc;
                    if ((args.Mod & (ModifierKeys.RightShift | ModifierKeys.LeftShift)) != 0)
                        cc = Char.ToUpper (c);
                    else
                        cc = c;
                    value.Insert (cursor++, cc);
                    changed = true;
                }
                changed = true;
            }

            if (changed)
                Text = Value;
        }
Esempio n. 6
0
 private void MainWindow_OnKeyDown(object sender, KeyboardEventArgs e)
 {
     if (Keyboard.IsKeyDown(Key.W))
     {
         _leftPad.YPosition -= PadSpeed;
     }
     if (Keyboard.IsKeyDown(Key.S))
     {
         _leftPad.YPosition += PadSpeed;
     }
     if (Keyboard.IsKeyDown(Key.Up))
     {
         _rightPad.YPosition -= PadSpeed;
     }
     if (Keyboard.IsKeyDown(Key.Down))
     {
         _rightPad.YPosition += PadSpeed;
     }
 }
Esempio n. 7
0
 public bool OnKeyDown(KeyboardEventArgs args)
 {
     if (_isAIRace || args.Key == Key.Escape)
     {
         // TODO: need to have resume callback from menu
         //if (_raceStartSequence > 0 && _bannerTween != null)
         //  _bannerTween.Pause();
         if (_isAIRace)
         {
             LF.Menu.ShowMenu(MenuClass.eMenuMain, false);
         }
         else
         {
             LF.Menu.ShowMenu(MenuClass.eMenuMainInGame, true);
         }
         return(true);
     }
     return(false);
 }
Esempio n. 8
0
        protected async Task OnKeyUpAsync(KeyboardEventArgs args)
        {
            if (!EqualityComparer <TValue> .Default.Equals(CurrentValue, _inputValue))
            {
                if (!_compositionInputting)
                {
                    CurrentValue = _inputValue;
                    if (OnChange.HasDelegate)
                    {
                        await OnChange.InvokeAsync(Value);
                    }
                }
            }

            if (OnkeyUp.HasDelegate)
            {
                await OnkeyUp.InvokeAsync(args);
            }
        }
        /// <summary>
        /// Method is called via EventCallBack if the keyboard key is no longer pressed inside the Input element.
        /// </summary>
        /// <param name="e">Contains the key (combination) which was pressed inside the Input element</param>
        /// <param name="index">Refers to picker index - 0 for starting date, 1 for ending date</param>
        protected async Task OnKeyUp(KeyboardEventArgs e, int index)
        {
            if (e == null)
            {
                throw new ArgumentNullException(nameof(e));
            }

            var key = e.Key.ToUpperInvariant();

            if (key == "ENTER")
            {
                var input = (index == 0 ? _inputStart : _inputEnd);
                if (string.IsNullOrWhiteSpace(input.Value))
                {
                    ClearValue(index);
                }
                else
                {
                    if (BindConverter.TryConvertTo(input.Value, CultureInfo, out DateTime changeValue))
                    {
                        var array = Value as Array;
                        array.SetValue(changeValue, index);
                    }
                    if (index == 0)
                    {
                        await Blur(0);
                        await Focus(1);
                    }
                    else
                    {
                        Close();
                    }
                }
            }
            if (key == "ARROWDOWN" && !_dropDown.IsOverlayShow())
            {
                await _dropDown.Show();
            }
            if (key == "ARROWUP" && _dropDown.IsOverlayShow())
            {
                Close();
            }
        }
Esempio n. 10
0
 private void MainWindow_OnKeyDown(object sender, KeyboardEventArgs e)
 {
     if (Keyboard.IsKeyDown(Key.A))
     {
         playerTank.XPosition -= tankSpeed;
     }
     if (Keyboard.IsKeyDown(Key.D))
     {
         playerTank.XPosition += tankSpeed;
     }
     if (Keyboard.IsKeyDown(Key.W))
     {
         if (gameParams.reload >= barsLength && playerTank.shootFired == false)
         {
             gameParams.reload     = 0;
             playerTank.shootFired = true;
         }
     }
 }
Esempio n. 11
0
 private bool CheckShift56(KeyboardEventArgs args)
 {
     if (!_shift5 && args.Modifier == KeyModifier.Shift && args.KeyChar == '5')
     {
         _shift5 = true;
         return(true);
     }
     else if (_shift5 && args.Modifier == KeyModifier.Shift && args.KeyChar == '6')
     {
         _shift5 = false;
         Settings.RevealWorldCheat();
         return(true);
     }
     else if (_shift5)
     {
         _shift5 = false;
     }
     return(false);
 }
Esempio n. 12
0
 private void MainWindowOnKeyDown(object sender, KeyboardEventArgs e)        //handles the controls that result in corresponding method calls.
 {
     if (Keyboard.IsKeyDown(Key.W))
     {
         view.LeftPadPosition = VerifyBounds(view.LeftPadPosition, -PadSpeed);                                   //player 1 controls.
     }
     if (Keyboard.IsKeyDown(Key.S))
     {
         view.LeftPadPosition = VerifyBounds(view.LeftPadPosition, PadSpeed);                                    //W moves paddle up. S moves paddle down.
     }
     if (Keyboard.IsKeyDown(Key.Up))
     {
         view.RightPadPosition = VerifyBounds(view.RightPadPosition, -PadSpeed);                                 //player 2 controls.
     }
     if (Keyboard.IsKeyDown(Key.Down))
     {
         view.RightPadPosition = VerifyBounds(view.RightPadPosition, PadSpeed);                                  //Up arrow moves paddle up. Down arrow moves down.
     }
 }
Esempio n. 13
0
        public override bool doEvent(object caller, KeyboardEventArgs e)
        {
            if (!e.Down)
            {
                return(true);
            }

            if (e.Key == Key.Return || e.Key == Key.Space)
            {
                boxChecked = !boxChecked;

                if (callbackHandler != null)
                {
                    callbackHandler(boxChecked);
                }
            }

            return(true);
        }
Esempio n. 14
0
        protected override async Task HandleKeyUpAsync(KeyboardEventArgs args)
        {
            await base.HandleKeyUpAsync(args);

            var key = args.Key;

            if (key == " " || key == "Enter")
            {
                await HandleClickAsync(args);
            }
            else if (Deletable && (key == "Backspace" || key == "Delete"))
            {
                await OnDelete.InvokeAsync(args);
            }
            else if (key == "Escape")
            {
                await DomHelpers.BlurAsync(RootRef.Current);
            }
        }
Esempio n. 15
0
        // Should the input be more changable?
        protected override void OnKeyDown(KeyboardEventArgs e)
        {
            switch (Orientation)
            {
            case Controls.Orientation.Vertical:
            {
                if (e.Key == Microsoft.Xna.Framework.Input.Keys.Down)
                {
                    if (SelectedIndex < (Children.Count - 1))
                    {
                        SelectedIndex++;
                    }
                }
                else if (e.Key == Microsoft.Xna.Framework.Input.Keys.Up)
                {
                    if (SelectedIndex > 0)
                    {
                        SelectedIndex--;
                    }
                }
                break;
            }

            case Controls.Orientation.Horizontal:
            {
                if (e.Key == Microsoft.Xna.Framework.Input.Keys.Right)
                {
                    if (SelectedIndex < (Children.Count - 1))
                    {
                        SelectedIndex++;
                    }
                }
                else if (e.Key == Microsoft.Xna.Framework.Input.Keys.Left)
                {
                    if (SelectedIndex > 0)
                    {
                        SelectedIndex--;
                    }
                }
                break;
            }
            }
        }
Esempio n. 16
0
        public override void HandleKeyReleasedEvent(object sender, KeyboardEventArgs e)
        {
            base.HandleKeyReleasedEvent(sender, e);

            var keyReleased = e.KeyInformation.VirtualKey;

            if (keyReleased == SharpDL.Input.VirtualKeyCode.ArrowLeft)
            {
                isArrowLeftDown = false;
            }
            if (keyReleased == SharpDL.Input.VirtualKeyCode.ArrowRight)
            {
                isArrowRightDown = false;
            }
            if (keyReleased == SharpDL.Input.VirtualKeyCode.Space)
            {
                isSpacebarDown = false;
            }
        }
        public void SpinButtonArrowDownKeyDownTest(double defaultValue, double step, double min)
        {
            var component = RenderComponent <BitSpinButton>(parameters =>
            {
                parameters.Add(p => p.Step, step);
                parameters.Add(p => p.Min, min);
                parameters.Add(p => p.DefaultValue, defaultValue);
            });

            var input = component.Find("input");
            var args  = new KeyboardEventArgs();

            args.Key = "ArrowDown";
            input.KeyDown(args);
            var inputValue     = input.GetAttribute("value");
            var expectedResult = defaultValue - step >= min ? defaultValue - step : defaultValue;

            Assert.AreEqual(expectedResult.ToString(), inputValue);
        }
Esempio n. 18
0
        protected void OnKeyUp(KeyboardEventArgs args)
        {
            var currentKey = KeyHelper.GetKeyFromString(args.Key);

            Console.WriteLine(currentKey.ToString());

            if (currentKey == Key.Up)
            {
                SelectPrevResult();
            }
            else if (currentKey == Key.Down)
            {
                SelectNextResult();
            }
            else if (currentKey == Key.Enter)
            {
                HandleDblClick(this.CurrentItem);
            }
        }
Esempio n. 19
0
        /// <summary>Repeatedly called with a period defined by WorkerInterval. Used to poll the device for data and raise any desired events.</summary>
        /// <param name="sender">Always null.</param>
        protected override void CheckEvents(object sender)
        {
            if (!this.CheckObjectState(false))
            {
                return;
            }

            byte key = 0, keyState = 0;
            var  ascii = '\0';

            try {
                if (!this.NativeGetState(out key, out ascii, out keyState))
                {
                    return;
                }
            }
            catch {
            }

            var args = new KeyboardEventArgs()
            {
                ASCII = ascii, Which = (Key)key
            };

            if ((KeyState)keyState == KeyState.Pressed)
            {
                this.OnKeyDown(args);

                if (args.ASCII != 0)
                {
                    this.OnCharDown(args);
                }
            }
            else if ((KeyState)keyState == KeyState.Released)
            {
                this.OnKeyUp(args);

                if (args.ASCII != 0)
                {
                    this.OnCharUp(args);
                }
            }
        }
Esempio n. 20
0
        /// <summary>
        /// Overrides KeyDown event, intercepts Arrow Up/Down and uses them to add/substract the value manually by the step value.
        /// Relying on the browser mean the steps are each integer multiple from <see cref="Min"/> up until <see cref="Max"/>.
        /// This align the behaviour with the spinner buttons.
        /// </summary>
        /// <remarks>https://try.mudblazor.com/snippet/QamlkdvmBtrsuEtb</remarks>
        protected async Task InterceptArrowKey(KeyboardEventArgs obj)
        {
            if (Disabled || ReadOnly)
            {
                return;
            }

            if (obj.Type == "keydown")//KeyDown or repeat, blazor never fires InvokeKeyPress
            {
                if (obj.Key == "ArrowUp")
                {
                    _keyDownPreventDefault = true;
                    if (RuntimeLocation.IsServerSide)
                    {
                        var value = Value;
                        await Task.Delay(1);

                        Value = value;
                    }
                    await Increment();

                    return;
                }
                else if (obj.Key == "ArrowDown")
                {
                    _keyDownPreventDefault = true;
                    if (RuntimeLocation.IsServerSide)
                    {
                        var value = Value;
                        await Task.Delay(1);

                        Value = value;
                    }
                    await Decrement();

                    return;
                }
            }

            _keyDownPreventDefault = KeyDownPreventDefault;
            OnKeyDown.InvokeAsync(obj).AndForget();
        }
Esempio n. 21
0
        private void Events_KeyDown(object sender, KeyboardEventArgs e)
        {
            switch (e.Key)
            {
            case Key.Escape:
                if (SDLExitEvent != null)
                {
                    SDLExitEvent();
                }
                Events.QuitApplication();
                break;

            case Key.LeftArrow:
                rotX += 5f;
                break;

            case Key.RightArrow:
                rotX -= 5f;
                break;

            case Key.UpArrow:
                rotY += 5f;
                if (rotY >= 30f)
                {
                    rotY = 30f;
                }
                break;

            case Key.DownArrow:
                rotY -= 5f;
                if (rotY <= -20f)
                {
                    rotY = -20f;
                }
                break;

            case Key.R:
                rotX = -45f;
                rotY = 10f;
                break;
            }
        }
Esempio n. 22
0
        public static KeyboardEventArgs ProcessWindowsKeyMessage(ref WindowsMessage m)
        {
            var val             = m.LParam.ToInt64();
            KeyboardEventArgs e = new KeyboardEventArgs();

            e.KeyCode = Keys.None;
            if ((m.Msg == WM_KEYDOWN || m.Msg == WM_KEYUP) && ((int)m.WParam == VK_CONTROL || (int)m.WParam == VK_SHIFT))
            {
                switch ((OemScanCode)(((Int64)m.LParam >> 16) & 0x1FF))
                {
                case OemScanCode.LControl:
                {
                    e.KeyCode = Keys.LControlKey;
                }
                break;

                case OemScanCode.RControl:
                    e.KeyCode = Keys.RControlKey;
                    break;

                case OemScanCode.LShift:
                    e.KeyCode = Keys.LShiftKey;
                    break;

                case OemScanCode.RShift:
                    e.KeyCode = Keys.RShiftKey;
                    break;

                default:
                    if ((int)m.WParam == VK_SHIFT)
                    {
                        e.KeyCode = Keys.ShiftKey;
                    }
                    else if ((int)m.WParam == VK_CONTROL)
                    {
                        e.KeyCode = Keys.ControlKey;
                    }
                    break;
                }
            }
            return(e);
        }
Esempio n. 23
0
        public void Key_Typed(object sender, KeyboardEventArgs args)
        {
            if (args.Key == Keys.Back)
            {
                if (text.Length > 0)
                {
                    var left  = text.Substring(0, (int)cursor.X);
                    var right = text.Remove(0, (int)cursor.X);
                    left = left.Substring(0, left.Length - 1);
                    text = left + right;
                    cursor.X--;
                }
            }
            else if (args.Key == Keys.Enter)
            {
                // handle input
                try
                {
                    lua.DoString(text);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }

                history.Add(text);

                text = "";
            }
            else if (!(args.Key == Keys.OemTilde && args.Modifiers != KeyboardModifiers.Shift) && args.Key != Keys.Tab)
            {
                if (text.Length > 0)
                {
                    text = text.Insert((int)cursor.X, args.Character?.ToString() ?? "");
                }
                else
                {
                    text += args.Character?.ToString() ?? "";
                }
                cursor.X++;
            }
        }
Esempio n. 24
0
        protected async Task HandleKeydown(KeyboardEventArgs obj)
        {
            if (Disabled || ReadOnly)
            {
                return;
            }
            switch (obj.Key)
            {
            case "ArrowUp":
                await Increment();

                break;

            case "ArrowDown":
                await Decrement();

                break;
            }
            OnKeyDown.InvokeAsync(obj).AndForget();
        }
Esempio n. 25
0
        // Set the W and S keyboards to be the ones that contorl the left paddle and Up and Down arrows to control the right paddle
        private void MainWindow_OnKeyDown(object sender, KeyboardEventArgs e)
        {
            if (Keyboard.IsKeyDown(Key.W))
            {
                myPaddle.P1PadPosition = checkBounds(myPaddle.P1PadPosition, -PadSpeed);
            }
            if (Keyboard.IsKeyDown(Key.S))
            {
                myPaddle.P1PadPosition = checkBounds(myPaddle.P1PadPosition, PadSpeed);
            }

            if (Keyboard.IsKeyDown(Key.Up))
            {
                myPaddle.P2PadPosition = checkBounds(myPaddle.P2PadPosition, -PadSpeed);
            }
            if (Keyboard.IsKeyDown(Key.Down))
            {
                myPaddle.P2PadPosition = checkBounds(myPaddle.P2PadPosition, PadSpeed);
            }
        }
Esempio n. 26
0
        public void KeyDown(KeyboardEventArgs e)
        {
            if (!this.Editing)
            {
                return;
            }

            if (e.Key.ToLower() == "backspace")
            {
                this.Value = this.Value.Length <= 0 ? "" : this.Value.Substring(0, this.Value.Length - 1);
                return;
            }

            if (e.Key.ToString().Length > 1)
            {
                return;
            }

            this.Value += e.Key.ToString();
        }
Esempio n. 27
0
        private async Task OnInputKeyDown(KeyboardEventArgs e)
        {
            if (e.AltKey == true && e.Code == "KeyO")
            {
                await Open();
            }
            else if (e.AltKey == true && e.Code == "KeyX")
            {
                if (IsDisabled)
                {
                    return;
                }

                await Clear();
            }
            else if (e.AltKey == true && e.Code == "KeyA")
            {
                await OnAddNewClick();
            }
        }
Esempio n. 28
0
        private void MainWindow_OnKeyDown(object sender, KeyboardEventArgs e)
        {
            if (Keyboard.IsKeyDown(Key.W))
            {
                vm.LeftPadPosition = verifyBounds(vm.LeftPadPosition, -padSpeed);
            }
            if (Keyboard.IsKeyDown(Key.S))
            {
                vm.LeftPadPosition = verifyBounds(vm.LeftPadPosition, padSpeed);
            }

            if (Keyboard.IsKeyDown(Key.Up))
            {
                vm.RightPadPosition = verifyBounds(vm.RightPadPosition, -padSpeed);
            }
            if (Keyboard.IsKeyDown(Key.Down))
            {
                vm.RightPadPosition = verifyBounds(vm.RightPadPosition, padSpeed);
            }
        }
        private void Diagram_KeyDown(KeyboardEventArgs e)
        {
            if (e.AltKey || e.CtrlKey || e.ShiftKey || e.Code != Diagram.Options.DeleteKey)
            {
                return;
            }

            Diagram.Batch(() =>
            {
                foreach (var sm in Diagram.GetSelectedModels().ToList())
                {
                    if (sm.Locked)
                    {
                        continue;
                    }

                    if (sm is GroupModel group && Diagram.Options.Constraints.ShouldDeleteGroup(group))
                    {
                        Diagram.RemoveGroup(group);
                    }
Esempio n. 30
0
 private void Events_KeyboardUp(object sender, KeyboardEventArgs e)
 {
     // Check which key was brought up and stop the hero if needed
     if (e.Key == Key.LeftArrow && hero.CurrentAnimation == "WalkLeft")
     {
         hero.Animate = false;
     }
     else if (e.Key == Key.UpArrow && hero.CurrentAnimation == "WalkUp")
     {
         hero.Animate = false;
     }
     else if (e.Key == Key.DownArrow && hero.CurrentAnimation == "WalkDown")
     {
         hero.Animate = false;
     }
     else if (e.Key == Key.RightArrow && hero.CurrentAnimation == "WalkRight")
     {
         hero.Animate = false;
     }
 }
Esempio n. 31
0
        /// <summary>
        /// Overrides KeyDown event, intercepts Arrow Up/Down and uses them to add/substract the value manually by the step value.
        /// Relying on the browser mean the steps are each integer multiple from <see cref="Min"/> up until <see cref="Max"/>.
        /// This align the behaviour with the spinner buttons.
        /// </summary>
        /// <remarks>https://try.mudblazor.com/snippet/QamlkdvmBtrsuEtb</remarks>
        protected async Task InterceptArrowKey(KeyboardEventArgs obj)
        {
            if (obj.Type == "keydown")//KeyDown or repeat, blazor never fire InvokeKeyPress
            {
                if (obj.Key == "ArrowUp")
                {
                    await Increment();

                    return;
                }
                else if (obj.Key == "ArrowDown")
                {
                    await Decrement();

                    return;
                }
            }
            _keyDownPreventDefault = KeyDownPreventDefault;
            OnKeyPress.InvokeAsync(obj).AndForget();
        }
Esempio n. 32
0
            private void HandleEventKeyboard(SDL_KeyboardEvent keyboardEvent)
            {
                KeyboardEventArgs args = ConvertKeyEvent(keyboardEvent);

                if (args == null)
                {
                    return;
                }

                switch (keyboardEvent.State)
                {
                case SDL_KeyState.SDL_PRESSED:
                    OnKeyDown?.Invoke(this, args);
                    return;

                case SDL_KeyState.SDL_RELEASED:
                    OnKeyUp?.Invoke(this, args);
                    return;
                }
            }
        public async Task AddToDo(KeyboardEventArgs e)
        {
            if (e.Key == "Enter" && !string.IsNullOrWhiteSpace(Description) ||
                e.Key == "NumpadEnter" && !string.IsNullOrWhiteSpace(Description))
            {
                var request = new ToDoStructure()
                {
                    Id          = ServerToDoResponse.Count,
                    Description = this.Description,
                    IsCompleted = false
                };
                Description = null;

                await UserClient.AddToDoAsync(request);
                await GetToDoList();
            }
            else
            {
            }
        }
        private void OnKeyDownHandler(KeyboardEventArgs args)
        {
            // Console.WriteLine($"KeyboardEventArgs key: {args.Key} code: {args.Code} type: {args.Type} meta: {args.MetaKey} shift: {args.ShiftKey} ctrl: {args.CtrlKey} repeat: {args.Repeat}");

            if (args.Code.Contains("Backspace"))
            {
                lock (inputBufferSync)
                {
                    if (inputBuffer.Any())
                    {
                        var items = inputBuffer.ToList();
                        items.RemoveAt(items.Count - 1);
                        inputBuffer = new Queue <char>(items);

                        this.Text = this.Text.Substring(0, this.Text.Length - 1);
                        this.mustRefreshOutput = true;
                    }
                }
            }
        }
Esempio n. 35
0
        private void RaiseRepeatEvents(GameTime gameTime, KeyboardState currentState)
        {
            var elapsedTime = (gameTime.TotalGameTime - _lastPressTime).TotalMilliseconds;

            if (currentState.IsKeyDown(_previousKey) &&
                (_isInitial && elapsedTime > InitialDelay || !_isInitial && elapsedTime > RepeatDelay))
            {
                var args = new KeyboardEventArgs(_previousKey, currentState);

                KeyPressed?.Invoke(this, args);

                if (args.Character.HasValue)
                {
                    KeyTyped?.Invoke(this, args);
                }

                _lastPressTime = gameTime.TotalGameTime;
                _isInitial     = false;
            }
        }
Esempio n. 36
0
        public void SetUp()
        {
            var kernel32 = MockRepository.GenerateStub<IKernel32>();
            HookProc callback = delegate { return 1; };

            _user32 = MockRepository.GenerateStub<IUser32>();
            _user32.Stub(usr32 => usr32.SetWindowsHook(Arg<int>.Is.Anything, Arg<HookProc>.Is.Anything, Arg<IntPtr>.Is.Anything, Arg<int>.Is.Anything))
                .WhenCalled(invocation=>callback = (HookProc)invocation.Arguments[1])
                .Return(KEYBOARD_HOOK_HANDLE);

            EventHandler<KeyboardEventArgs> keyboardEventHandler = MockRepository.GenerateStub<EventHandler<KeyboardEventArgs>>();
            KeyboardEventArgs eventArgs = new KeyboardEventArgs(0, new Dictionary<VirtualKeyCode, KeyState>()) {Handled = false};
            keyboardEventHandler.Stub(handler => handler(null, null)).IgnoreArguments().WhenCalled(invocation => invocation.Arguments[1] = eventArgs);

            Keyboard keyboard = new Keyboard(_user32, kernel32);
            keyboard.KeyUp += keyboardEventHandler;

            KeyboardHookStruct keyboardData = new KeyboardHookStruct();
            _ptr = Marshal.AllocHGlobal(Marshal.SizeOf(keyboardData));
            Marshal.StructureToPtr(keyboardData, _ptr, true);

            callback(Constants.HC_ACTION, Constants.WM_KEYUP, _ptr);
        }
Esempio n. 37
0
 static void sdl_OnKeyPressedOrReleased(object sender, KeyboardEventArgs e)
 {
     if (null == e)
     {
         Console.WriteLine("Key pressed: empty key data!!!!");
     }
     else
     {
         Console.WriteLine("Key pressed: code:{0} state:{1} repeat:{2} mod:{3}", e.KeyInfo.Scancode, e.State, e.Repeat, e.KeyInfo.Modifier);
         if (e.KeyInfo.Scancode == KeyScancode.A && e.State == KeyState.PRESSED)
         {
             sample.Play();
         }
         else if (e.KeyInfo.Scancode == KeyScancode.NumPadPlus && e.State == KeyState.PRESSED)
         {
             delay++;
         }
         else if (e.KeyInfo.Scancode == KeyScancode.NumPadMinus && e.State == KeyState.PRESSED)
         {
             delay--;
         }
     }
 }
Esempio n. 38
0
 void _KeyUp(object source, KeyboardEventArgs e)
 {
     if (KeyUp != null)
     {
         KeyUp(source, e);
     }
 }
Esempio n. 39
0
 private void KeyUp(object sender, KeyboardEventArgs e)
 {
     KeyHandler.Instance.KeyUp(e.KeyCode);
 }
Esempio n. 40
0
        public void HandleKeyboardUp(KeyboardEventArgs args)
        {
            /* just return if the modifier keys are released */
            if (args.Key >= Key.NumLock && args.Key <= Key.Compose)
                return;

            if (dialog != null)
                dialog.HandleKeyboardUp (args);
            else
                KeyboardUp (args);
        }
Esempio n. 41
0
 /// <summary>
 /// Triggered when the user releases or presses a key.
 /// </summary>
 public void Key(KeyboardEventArgs args)
 {
 }
Esempio n. 42
0
 public virtual void KeyboardUp(KeyboardEventArgs args)
 {
 }
Esempio n. 43
0
 public virtual void KeyboardDown(KeyboardEventArgs args)
 {
     if (Elements != null) {
         foreach (UIElement e in Elements) {
             if ( (args.Key == e.Hotkey)
                  ||
                  (args.Key == Key.Return
                   && (e.Flags & ElementFlags.DefaultButton) == ElementFlags.DefaultButton)
                  ||
                  (args.Key == Key.Escape
                   && (e.Flags & ElementFlags.CancelButton) == ElementFlags.CancelButton)) {
                 ActivateElement (e);
                 return;
             }
         }
     }
 }
Esempio n. 44
0
 private void KeyboardObject_KeyPress(Object sender, KeyboardEventArgs e) {
     //throw new NotImplementedException();
 }
Esempio n. 45
0
 void KeyUp( object source, KeyboardEventArgs e )
 {
     if( (char)e.Key == 'a' )
     {
         bleftdown = false;
     }
     if( (char)e.Key == 'd' )
     {
         brightdown = false;
     }
     if( (char)e.Key == 'w' )
     {
         bupdown = false;
     }
     if( (char)e.Key == 's' )
     {
         bdowndown = false;
     }
 }
Esempio n. 46
0
 /// <summary>
 /// Triggered when the user releases or presses a key.
 /// </summary>
 public void Key(KeyboardEventArgs args)
 {
     // Break out
     Game.GameMode = new MainMenuMode();
 }
Esempio n. 47
0
        /// <summary>
        /// Triggered when the user releases or presses a key.
        /// </summary>
        public void Key(KeyboardEventArgs args)
        {
            // We only care about keyboard presses
            if (!args.Pressed)
                return;

            Close();
        }
Esempio n. 48
0
 public override void KeyboardUp(KeyboardEventArgs args)
 {
 }
		/// <summary>
		/// Handle a keyboard event.
		/// </summary>
		/// <param name="sender">
		/// The sending object.
		/// </param>
		/// <param name="args">
		/// A <see cref="KeyboardEventArgs"/>.
		/// </param>
		/// <remarks>
		/// This method matches the signature required for
		/// <see cref="KeyboardEventHandler"/> so that it may be used directly
		/// to handle <see cref="IController.KeyboardEvent"/>.
		/// </remarks>
		public void HandleKeyboard(object sender, KeyboardEventArgs args) {
			KeyboardEventHandler handler;
			
			if (this.mKeybindings.TryGetValue(args, out handler))
				handler(this, args);
		}
Esempio n. 50
0
        public override void KeyboardDown(KeyboardEventArgs args)
        {
            switch (args.Key) {
            case Key.F10:
                GameMenuDialog d = new GameMenuDialog (this, mpq);

                d.ReturnToGame += delegate () { DismissDialog (); };
                ShowDialog (d);
                break;

            case Key.RightArrow:
                horiz_delta = SCROLL_DELTA;
                break;
            case Key.LeftArrow:
                horiz_delta = -SCROLL_DELTA;
                break;
            case Key.DownArrow:
                vert_delta = SCROLL_DELTA;
                break;
            case Key.UpArrow:
                vert_delta = -SCROLL_DELTA;
                break;
            }
        }
 protected virtual void OnUserKeyPressed(KeyboardEventArgs e)
 {
     if (UserKeyPressed != null)
         UserKeyPressed(this, e);
 }
Esempio n. 52
0
        /// <summary>
        /// Triggered when the user releases or presses a key.
        /// </summary>
        public void Key(KeyboardEventArgs args)
        {
            // We only care about keyboard presses
            if (!args.Pressed)
                return;

            // Switch the mode
            switch (args.Key)
            {
            case BooGameKeys.Escape:
                // Go to the main menu
                Game.GameMode = new MainMenuMode();
                break;

            #if DEBUG
            case BooGameKeys.F3:
                // Add to the minor mode if we already have one
                if (MinorMode != null && MinorMode is ChestOpenedMinorMode)
                {
                    // Just increment it
                    (MinorMode as ChestOpenedMinorMode).ChestCounter++;
                }
                else
                {
                    // Open up the new mode
                    MinorMode = new ChestOpenedMinorMode(1);
                }
                return;

            case BooGameKeys.F4:
                // Add a bug into the board
                Game.State.Board.AddBugs(1);
                return;

            case BooGameKeys.F5:
                // Give another stage with penalties
                MinorMode = new NewStageMinorMode();
                return;

            case BooGameKeys.F6:
                // Creates a test prayer and inserts it into the system.
                Prayer prayer = Game.PrayerFactory.CreatePrayer();
                prayer.IsAccepted = true;
                Game.State.Prayers.Add(prayer);
                return;

            case BooGameKeys.F7:
                Game.State.GrabCount = 3;
                return;

            case BooGameKeys.F8:
                // Finish up a prayer
                Prayer p = Game.PrayerFactory.CreatePrayer();
                MinorMode = new PrayerCompletedMinorMode(0, 0, p);
                return;

            case BooGameKeys.F9:
                // Finish the game
                MinorMode = new EndOfGameMinorMode();
                return;
            #endif
            }

            // If we have a minor mode, pass it on
            if (minorMode != null)
                minorMode.Key(args);
        }
Esempio n. 53
0
 void _KeyDown(object source, KeyboardEventArgs e)
 {
     //if ((char)e.Key == 'q')
     //{
      //   System.Environment.Exit(0);
     //}
     if( KeyDown != null )
     {
         KeyDown( source, e );
     }
 }
Esempio n. 54
0
 public override void KeyboardDown(KeyboardEventArgs args)
 {
     switch (args.Key)
     {
     case Key.Escape:
         Events.Tick -= FlipPage;
         MarkupFinished ();
         break;
     case Key.Space:
     case Key.Return:
         totalElapsed = 0;
         AdvanceToNextPage ();
         break;
     }
 }
Esempio n. 55
0
        private void CoreDispatcher_AcceleratorKeyActivated(CoreDispatcher sender, AcceleratorKeyEventArgs e)
        {
            if ((e.EventType == CoreAcceleratorKeyEventType.SystemKeyDown ||
                e.EventType == CoreAcceleratorKeyEventType.KeyDown))
            {
                var coreWindow = Windows.UI.Xaml.Window.Current.CoreWindow;
                var downState = CoreVirtualKeyStates.Down;
                var virtualKey = e.VirtualKey;
                bool winKey = ((coreWindow.GetKeyState(VirtualKey.LeftWindows) & downState) == downState || (coreWindow.GetKeyState(VirtualKey.RightWindows) & downState) == downState);
                bool altKey = (coreWindow.GetKeyState(VirtualKey.Menu) & downState) == downState;
                bool controlKey = (coreWindow.GetKeyState(VirtualKey.Control) & downState) == downState;
                bool shiftKey = (coreWindow.GetKeyState(VirtualKey.Shift) & downState) == downState;

                // raise keydown actions
                var keyDown = new KeyboardEventArgs
                {
                    AltKey = altKey,
                    Character = ToChar(virtualKey, shiftKey),
                    ControlKey = controlKey,
                    EventArgs = e,
                    ShiftKey = shiftKey,
                    VirtualKey = virtualKey
                };

                try { _KeyDown?.Raise(this, keyDown); }
                catch { }

                // Handle F5 to refresh content
                if (virtualKey == VirtualKey.F5)
                {
                    bool noModifiers = !altKey && !controlKey && !shiftKey;
                    _RefreshRequest?.Raise(this, keyDown);
                }
            }
        }
Esempio n. 56
0
 public override void KeyboardUp(KeyboardEventArgs args)
 {
     if (args.Key == Key.RightArrow
         || args.Key == Key.LeftArrow) {
         horiz_delta = 0;
     }
     else if (args.Key == Key.UpArrow
          || args.Key == Key.DownArrow) {
         vert_delta = 0;
     }
 }
Esempio n. 57
0
        /// <summary>
        /// Processes key down events, used for triggering things within
        /// the game.
        /// </summary>
        /// <param name="args"></param>
        public override void KeyDown(KeyboardEventArgs args)
        {
            // See if we have one of the universal commands
            switch (args.Key)
            {
                case BooGameKeys.F:
                    FullScreen = !FullScreen;
                    break;

                default:
                    // Pass it on to the game mode
                    if (Game.GameMode != null)
                        Game.GameMode.Key(args);
                    break;
            }
        }
Esempio n. 58
0
 /// <summary>
 /// Triggered when the user releases or presses a key.
 /// </summary>
 public virtual void Key(KeyboardEventArgs args)
 {
     // No timeout if (countingDown)
     if (args.Pressed)
         Timeout();
 }
        private void KeyboardService_KeyDown(object sender, KeyboardEventArgs e)
        {
            if (e.VirtualKey == Windows.System.VirtualKey.Left && e.AltKey == true)
            {
                //TODO: Raise backNavigation();
                //App.InvokeOnBackRequested();

                BindablePage.CurrentPage.OnBackRequested(null, null);
            }

            if (e.VirtualKey == Windows.System.VirtualKey.F5)
            {
                App.Current.InvokeOnRefreshRequested();
            }
        }
Esempio n. 60
0
 public void keyRelease(object sender, KeyboardEventArgs e)
 {
     if (e.key_ == Keys.F1)
     {
         GameEntity entity = Locator.getObjectFactory().createWreck();
         entity.spatial.translation_ = new Vector2(1800, 1000);
         entity.physic.velocity_ = new Vector2(0, -100);
         Locator.getComponentManager().addEntity(entity);
         Locator.getMessageBoard().postMessage(new Post(PostCategory.JUNK_SPAWN, entity, null, null, 0));
     }
     if (e.key_ == Keys.I)
     {
         if (systems == null)
         {
             systems = new SystemsWindow();
             systems.loc_ = new Vector2((screen_.X - systems.size.X) / 2, (screen_.Y - systems.size.Y) / 2);
         }
         if (!windows.Contains(systems))
             windows.Add(systems);
     }
 }