Exemplo n.º 1
0
 protected virtual void OnKeyUp(KeyInputEventArgs e)
 {
     if (KeyUp != null)
     {
         KeyUp(this, e);
     }
 }
        /// <inheritdoc />
        public override void OnKeyDown(KeyInputEventArgs keyInput)
        {
            if (keyInput.Key == KeyCodes.C)
            {
                if (_fixture2 == null)
                {
                    var shape = new CircleShape();
                    shape.Radius = 3.0f;
                    shape.Position.Set(0.5f, -4.0f);
                    _fixture2     = _body.CreateFixture(shape, 10.0f);
                    _body.IsAwake = true;
                }
            }

            if (keyInput.Key == KeyCodes.D)
            {
                if (_fixture2 != null)
                {
                    _body.DestroyFixture(_fixture2);
                    _fixture2     = null;
                    _body.IsAwake = true;
                }
            }

            if (keyInput.Key == KeyCodes.S)
            {
                if (_fixture2 != null)
                {
                    _sensor            = !_sensor;
                    _fixture2.IsSensor = _sensor;
                }
            }
        }
Exemplo n.º 3
0
        /// <inheritdoc />
        public override void OnKeyDown(KeyInputEventArgs keyInput)
        {
            if (keyInput.Key == KeyCodes.A)
            {
                _positionB.X -= 0.1f;
            }

            if (keyInput.Key == KeyCodes.D)
            {
                _positionB.X += 0.1f;
            }

            if (keyInput.Key == KeyCodes.S)
            {
                _positionB.Y -= 0.1f;
            }

            if (keyInput.Key == KeyCodes.W)
            {
                _positionB.Y += 0.1f;
            }

            if (keyInput.Key == KeyCodes.Q)
            {
                _angleB += 0.1f * Settings.Pi;
            }

            if (keyInput.Key == KeyCodes.E)
            {
                _angleB -= 0.1f * Settings.Pi;
            }
        }
Exemplo n.º 4
0
        private IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode >= 0)
            {
                int vk   = Marshal.ReadInt32(lParam);
                var kiea = new KeyInputEventArgs(vk);

                if (wParam == (IntPtr)WM_KEYUP)
                {
                    if (KeysDown.Contains(vk))
                    {
                        KeysDown.Remove(vk);
                    }
                    OnKeyUp(kiea);
                }
                else if (wParam == (IntPtr)WM_KEYDOWN &&
                         (!DropHeldDownKeys || !KeysDown.Contains(vk)))
                {
                    KeysDown.Add(vk);
                    OnKeyDown(kiea);
                }
            }

            return(CallNextHookEx(hookId, nCode, wParam, lParam)); // next hook in the chain, pass it on
        }
Exemplo n.º 5
0
 /// <inheritdoc />
 public override void OnKeyUp(KeyInputEventArgs keyInput)
 {
     if (keyInput.Key == KeyCodes.A)
     {
         _button = false;
     }
 }
Exemplo n.º 6
0
        private void OnKeyInputEnd(object sender, KeyInputEventArgs args)
        {
            System.Console.WriteLine("cyc add listener---");

            return;

            IVimBuffer vb = (IVimBuffer)sender;

            if (vb == null)
            {
                return;
            }

            var status = CommandMarginUtil.GetStatus(vb, vb.Mode, forModeSwitch: false);
            int frozen;

            if (_vsStatusbar != null)
            {
                _vsStatusbar.IsFrozen(out frozen);
                if (frozen != 0)
                {
                    _vsStatusbar.FreezeOutput(0);
                }
                _vsStatusbar.SetText(status);
            }
        }
Exemplo n.º 7
0
        /// <inheritdoc />
        public override void OnKeyDown(KeyInputEventArgs keyInput)
        {
            switch (keyInput.Key)
            {
            case KeyCodes.B:
                for (var i = 0; i < 4; ++i)
                {
                    if (m_bodies[i] != null)
                    {
                        World.DestroyBody(m_bodies[i]);
                        m_bodies[i] = null;
                        break;
                    }
                }

                break;

            case KeyCodes.J:
                for (var i = 0; i < 8; ++i)
                {
                    if (m_joints[i] != null)
                    {
                        World.DestroyJoint(m_joints[i]);
                        m_joints[i] = null;
                        break;
                    }
                }

                break;
            }
        }
Exemplo n.º 8
0
 /// <inheritdoc />
 public override void OnKeyDown(KeyInputEventArgs keyInput)
 {
     if (keyInput.Key == KeyCodes.A)
     {
         _button = true;
     }
 }
Exemplo n.º 9
0
 /// <inheritdoc />
 public override void OnKeyDown(KeyInputEventArgs keyInput)
 {
     if (keyInput.Key == KeyCodes.S)
     {
         _go = !_go;
     }
 }
Exemplo n.º 10
0
        private IRecorderItem GetPrviousKeyDownItem(KeyInputEventArgs e)
        {
            List <IRecorderItem> keyDownItems = this.ESRRecorder.Items.FindAll(p => p.Recorder == RecorderType.KeyUpDown && p.Dir == Dir.Down);

            foreach (var item in keyDownItems)
            {
                if (IsCtrlAltShift(item))
                {
                    continue;
                }

                IKeyRecorderItem keyItem = item as IKeyRecorderItem;
                if (keyItem.VkCode != e.KeyData.VkCode)
                {
                    continue;
                }

                if ((DateTime.Now - item.GetVeryLastTime()).TotalSeconds < this.KeyPressIntervalTimeSec)
                {
                    if (!IsCtrlAltShift(keyItem.ModifierKeys))
                    {
                        return(item);
                    }
                }
            }
            return(null);
        }
Exemplo n.º 11
0
        /// <inheritdoc />
        /// <inheritdoc />
        public override void OnKeyDown(KeyInputEventArgs keyInput)
        {
            if (keyInput.Key == KeyCodes.F)
            {
                if (_bullet != null)
                {
                    World.DestroyBody(_bullet);
                    _bullet = null;
                }

                {
                    var shape = new CircleShape {
                        Radius = 0.25f
                    };

                    var fd = new FixtureDef
                    {
                        Shape       = shape, Density = 20.0f,
                        Restitution = 0.05f
                    };

                    var bd = new BodyDef
                    {
                        BodyType = BodyType.DynamicBody, Bullet = true,
                        Position = new Vector2(-31.0f, 5.0f)
                    };

                    _bullet = World.CreateBody(bd);
                    _bullet.CreateFixture(fd);

                    _bullet.SetLinearVelocity(new Vector2(400.0f, 0.0f));
                }
            }
        }
Exemplo n.º 12
0
 /// <inheritdoc />
 public override void OnKeyDown(KeyInputEventArgs keyInput)
 {
     if (keyInput.Key == KeyCodes.H)
     {
         ToggleHeavy();
     }
 }
Exemplo n.º 13
0
 protected virtual void OnKeyDown(KeyInputEventArgs e)
 {
     if (KeyDown != null)
     {
         KeyDown(this, e);
     }
 }
Exemplo n.º 14
0
        public void Add(KeyInputEventArgs e)
        {
            if (this.State != ESRState.Recording)
            {
                return;
            }

            this.KeyRecorder.Add(e);
        }
Exemplo n.º 15
0
        private void KeyboardWatcher_OnKeyInput(object sender, KeyInputEventArgs e)
        {
            KeyToXboxButton button = keyboardToController.ListButtons.FirstOrDefault(x => x.Key == e.KeyData.Keyname);

            if (button != null) //We do have a bind for this key
            {
                controller.Buttons ^= button.x360Buttons;
                _scpBus.Report((int)1, controller.GetReport(), _outputReport);
            }
        }
Exemplo n.º 16
0
 private IRecorderItem CreateKeyPressRecorderItem(KeyInputEventArgs e)
 {
     return(new KeyPressRecorderItem()
     {
         Dir = Dir.Press,
         VkCode = e.KeyData.VkCode,
         Keyname = e.KeyData.Keyname,
         UnicodeCharacter = e.KeyData.UnicodeCharacter,
         ModifierKeys = Control.ModifierKeys
     });
 }
Exemplo n.º 17
0
        private bool IsSameKeyCodeAndWithInIntervalTime(IRecorderItem item, KeyInputEventArgs e)
        {
            IKeyRecorderItem keyItem = item as IKeyRecorderItem;

            if (keyItem.VkCode == e.KeyData.VkCode &&
                (DateTime.Now - item.Time).TotalSeconds < this.KeyPressIntervalTimeSec)
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 18
0
        /// <inheritdoc />
        public override void OnKeyDown(KeyInputEventArgs keyInput)
        {
            if (keyInput.Key == KeyCodes.C)
            {
                CreateCircle();
            }

            if (keyInput.Key == KeyCodes.A)
            {
                _autoCreate = !_autoCreate;
            }
        }
Exemplo n.º 19
0
    private void GlobalKeyEvents(object sender, KeyInputEventArgs e)
    {
        LastKeyPressEvent = DateTime.Now;
        Debug.Print("Keypress: " + e.KeyData.Keyname);
        Enum.TryParse <VirtualKeyCode>(e.KeyData.Keyname, out VirtualKeyCode acc);

        if (this.KeyToPress == acc)
        {
            this.OverallKeypresses++;
            this.KeypressedInRun++;
        }
    }
Exemplo n.º 20
0
        /// <inheritdoc />
        /// <inheritdoc />
        public override void OnKeyDown(KeyInputEventArgs keyInput)
        {
            if (keyInput.Key == KeyCodes.L)
            {
                m_joint.EnableLimit(!m_joint.IsLimitEnabled());
            }

            if (keyInput.Key == KeyCodes.M)
            {
                m_joint.EnableMotor(!m_joint.IsMotorEnabled());
            }
        }
        private void OnKeyInputEnd(object sender, KeyInputEventArgs args)
        {
            // Ignore our own virtual key input events.
            if (_processingVirtualKeyInputs)
            {
                return;
            }

            Debug.Assert(_vimBufferKeyEventState.InEvent);
            var updateCommandLine = true;

            try
            {
                if (!string.IsNullOrEmpty(_vimBufferKeyEventState.Message))
                {
                    UpdateCommandLine(_vimBufferKeyEventState.Message);
                    updateCommandLine = false;
                }
                else if (_vimBufferKeyEventState.SwitchModeEventArgs != null)
                {
                    var switchArgs = _vimBufferKeyEventState.SwitchModeEventArgs;
                    UpdateForSwitchMode(switchArgs.CurrentMode);
                }
                else
                {
                    UpdateCommandLineForNoEvent();
                }

                UpdateStatusLineVisibility();
            }
            finally
            {
                _vimBufferKeyEventState.KeyInputEventCount--;
                _vimBufferKeyEventState.Clear();
            }

            // On entering command mode or forward/backward search, the EditKind state is only
            // updated at KeyInputEnd (and not KeyInputStart), so we need to check again here

            var editKind = CalculateCommandLineEditKind();

            if (editKind != _editKind)
            {
                ChangeEditKind(editKind, updateCommandLine);
                if (editKind != EditKind.None)
                {
                    _margin.UpdateCaretPosition(EditPosition.End);
                }
            }

            UpdateShowCommandText();
        }
Exemplo n.º 22
0
 public void KeyEventHandler(object sender, KeyInputEventArgs e)
 {
     if (e.statut == KeyStatut.DOWN)
     {
         this.remoteOperation.press_key_down(e.key);
         this.keysPress.Add(e.key);
     }
     else
     {
         this.remoteOperation.press_key_up(e.key);
         this.keysPress.Remove(e.key);
     }
 }
Exemplo n.º 23
0
        /// <inheritdoc />
        public override void OnKeyDown(KeyInputEventArgs keyInput)
        {
            Console.WriteLine(keyInput.Key);
            if (keyInput.Key == KeyCodes.A)
            {
                _auto = !_auto;
            }

            if (keyInput.Key == KeyCodes.G)
            {
                Generate();
            }
        }
        /// <inheritdoc />
        public override void OnKeyDown(KeyInputEventArgs keyInput)
        {
            var k = -1;

            if (keyInput.Key == KeyCodes.D1)
            {
                k = 0;
            }

            if (keyInput.Key == KeyCodes.D2)
            {
                k = 1;
            }

            if (keyInput.Key == KeyCodes.D3)
            {
                k = 2;
            }

            if (keyInput.Key == KeyCodes.D4)
            {
                k = 3;
            }

            if (keyInput.Key == KeyCodes.D5)
            {
                k = 4;
            }

            if (k > -1)
            {
                Create(k);
            }

            if (keyInput.Key == KeyCodes.A)
            {
                for (var i = 0; i < MaxBodies; i += 2)
                {
                    if (_bodies[i] != null)
                    {
                        var isEnabled = _bodies[i].IsEnabled;
                        _bodies[i].IsEnabled = !isEnabled;
                    }
                }
            }

            if (keyInput.Key == KeyCodes.D)
            {
                DestroyBody();
            }
        }
Exemplo n.º 25
0
        /// <inheritdoc />
        public override void OnKeyDown(KeyInputEventArgs keyInput)
        {
            if (keyInput.Key == KeyCodes.A)
            {
                Body1.ApplyForceToCenter(new Vector2(-10.0f, 0.0f), true);
                Body2.ApplyForceToCenter(new Vector2(-10.0f, 0.0f), true);
            }

            if (keyInput.Key == KeyCodes.D)
            {
                Body1.ApplyForceToCenter(new Vector2(10.0f, 0.0f), true);
                Body2.ApplyForceToCenter(new Vector2(10.0f, 0.0f), true);
            }
        }
Exemplo n.º 26
0
        /// <inheritdoc />
        /// <inheritdoc />
        public override void OnKeyDown(KeyInputEventArgs keyInput)
        {
            if (keyInput.Key == KeyCodes.F)
            {
                _joint2.EnableMotor(!_joint2.IsMotorEnabled());
                _joint2.BodyB.IsAwake = true;
            }

            if (keyInput.Key == KeyCodes.M)
            {
                _joint1.EnableMotor(!_joint1.IsMotorEnabled());
                _joint1.BodyB.IsAwake = true;
            }
        }
Exemplo n.º 27
0
        /// <inheritdoc />
        public override void OnKeyDown(KeyInputEventArgs keyInput)
        {
            switch (keyInput.Key)
            {
            case KeyCodes.C:
                FixedCamera = !FixedCamera;
                if (FixedCamera)
                {
                    Global.Camera.Center = new Vector2(PlatformWidth / 2.0f, 0.0f);
                }

                break;
            }
        }
Exemplo n.º 28
0
 /// <inheritdoc />
 /// <inheritdoc />
 public override void OnKeyDown(KeyInputEventArgs keyInput)
 {
     if (keyInput.Key == KeyCodes.J)
     {
         if (_rope != null)
         {
             World.DestroyJoint(_rope);
             _rope = null;
         }
         else
         {
             _rope = World.CreateJoint(_ropeDef);
         }
     }
 }
Exemplo n.º 29
0
        /// <inheritdoc />
        public override void OnKeyDown(KeyInputEventArgs keyInput)
        {
            if (keyInput.Key == KeyCodes.L)
            {
                Joint.EnableLimit(!Joint.IsLimitEnabled());
            }

            if (keyInput.Key == KeyCodes.L)
            {
                Joint.EnableMotor(!Joint.IsMotorEnabled());
            }

            if (keyInput.Key == KeyCodes.L)
            {
                Joint.SetMotorSpeed(-Joint.GetMotorSpeed());
            }
        }
Exemplo n.º 30
0
        /// <inheritdoc />
        public override void OnKeyDown(KeyInputEventArgs keyInput)
        {
            switch (keyInput.Key)
            {
            case KeyCodes.A:
                _spring1.SetMotorSpeed(_speed);
                break;

            case KeyCodes.S:
                _spring1.SetMotorSpeed(0.0f);
                break;

            case KeyCodes.D:
                _spring1.SetMotorSpeed(-_speed);
                break;
            }
        }
Exemplo n.º 31
0
            private void OnKeyInputBuffered(object sender, KeyInputEventArgs args)
            {
                try
                {
                    var globalSettings = _vimBuffer.GlobalSettings;

                    // If 'timeout' is not enabled then ensure the timer is disabled and return.  Ensuring
                    // it's disabled is necessary because the 'timeout' could be disabled in the middle
                    // of processing a key mapping
                    if (!globalSettings.Timeout)
                    {
                        _timer.Stop();
                    }

                    if (_timer.IsEnabled)
                    {
                        _timer.Stop();
                    }

                    _timer.Interval = TimeSpan.FromMilliseconds(globalSettings.TimeoutLength);
                    _timer.Start();
                }
                catch (Exception ex)
                {
                    // Several DispatcherTimer operations including setting the Interval can throw
                    // so catch them all here
                    _protectedOperations.Report(ex);
                }
            }
Exemplo n.º 32
0
 private void OnKeyInputEnd(object sender, KeyInputEventArgs args)
 {
     KeyInputEventComplete();
 }
Exemplo n.º 33
0
 private void OnKeyInputStart(object sender, KeyInputEventArgs args)
 {
     _inKeyInputEvent = true;
 }