Пример #1
0
        /// <summary>
        /// Get key state.
        /// </summary>
        /// <param name="msg">Message.</param>
        /// <param name="k">Keyboard.</param>
        /// <returns>Key state.</returns>
        private static DeviceState GetDeviceState(uint msg, Keyboard k)
        {
            DeviceState state = new DeviceState();
            Keys        key   = (Keys)k.VirtualKey;

            switch (msg)
            {
            case Event.KeyboardKeyDown:       state.SetKeyTarget(DeviceEvent.KeyDown, key); break;

            case Event.KeyboardKeyUp:         state.SetKeyTarget(DeviceEvent.KeyUp, key);   break;

            case Event.KeyboardSystemKeyDown: state.SetKeyTarget(DeviceEvent.KeyDown, key); break;

            case Event.KeyboardSystemKeyUp:   state.SetKeyTarget(DeviceEvent.KeyUp, key);   break;
            }

            return(state);
        }
Пример #2
0
        /// <summary>
        /// Get mouse state.
        /// </summary>
        /// <param name="msg">Message.</param>
        /// <param name="m">Mouse.</param>
        /// <returns>Mouse state.</returns>
        private static DeviceState GetDeviceState(uint msg, Mouse m)
        {
            DeviceState state = new DeviceState();
            Keys        key;

            switch (msg)
            {
            case Event.MouseMove:        state.SetMouseTarget(DeviceEvent.MouseMove, Cursor.Position); break;

            case Event.MouseWheel:       state.SetMouseTarget(DeviceEvent.MouseWheel, new Point(0, GetMousePoint(m.Data))); break;

            case Event.MouseTilt:        state.SetMouseTarget(DeviceEvent.MouseTilt, new Point(GetMousePoint(m.Data), 0)); break;

            case Event.MouseLButtonDown: state.SetKeyTarget(DeviceEvent.KeyDown, Keys.LButton); break;

            case Event.MouseLButtonUp:   state.SetKeyTarget(DeviceEvent.KeyUp, Keys.LButton); break;

            case Event.MouseRButtonDown: state.SetKeyTarget(DeviceEvent.KeyDown, Keys.RButton); break;

            case Event.MouseRButtonUp:   state.SetKeyTarget(DeviceEvent.KeyUp, Keys.RButton); break;

            case Event.MouseMButtonDown: state.SetKeyTarget(DeviceEvent.KeyDown, Keys.MButton); break;

            case Event.MouseMButtonUp:   state.SetKeyTarget(DeviceEvent.KeyUp, Keys.MButton); break;

            case Event.MouseXButtonDown: key = GetMouseXButton(m.Data); if (key != Keys.None)
                {
                    state.SetKeyTarget(DeviceEvent.KeyDown, key);
                }
                break;

            case Event.MouseXButtonUp:   key = GetMouseXButton(m.Data); if (key != Keys.None)
                {
                    state.SetKeyTarget(DeviceEvent.KeyUp, key);
                }
                break;
            }

            return(state);
        }