Example #1
0
        public void OnControl(object s, CharacterEventArgs args)
        {
            switch (args.Character)
            {
            case ControlCharacters.CtrlV:
                string c = KeyboardEventDispatcher.GetNewClipboard();
                Insert(c);
                return;

            case ControlCharacters.CtrlC:
                if (text.Length > 0)
                {
                    KeyboardEventDispatcher.SetToClipboard(Text);
                }
                return;
            }
        }
Example #2
0
        static IntPtr HookProc(IntPtr hWnd, WM_EVENT msg, IntPtr wParam, IntPtr lParam)
        {
            IntPtr returnCode = CallWindowProc(prevWndProc, hWnd, msg, wParam, lParam);

            switch (msg)
            {
            case WM_EVENT.GETDLGCODE:
                returnCode = (IntPtr)(returnCode.ToInt32() | DLGC_WANTALLKEYS);
                break;

            case WM_EVENT.IME_SETCONTEXT:
                if (wParam.ToInt32() == 1)
                {
                    ImmAssociateContext(hWnd, hIMC);
                }
                break;

            case WM_EVENT.INPUTLANGCHANGE:
                ImmAssociateContext(hWnd, hIMC);
                returnCode = (IntPtr)1;
                break;

            // Key Events
            case WM_EVENT.KEY_DOWN:
                KeyboardEventDispatcher.EventInput_KeyDown(null, (Keys)wParam);
                break;

            case WM_EVENT.KEY_UP:
                KeyboardEventDispatcher.EventInput_KeyUp(null, (Keys)wParam);
                break;

            case WM_EVENT.KEY_CHAR:
                KeyboardEventDispatcher.EventInput_CharEntered(null, (char)wParam, lParam.ToInt32());
                break;

            // Mouse Events
            case WM_EVENT.MOUSE_MOVE:
                if (OnMouseMotion != null)
                {
                    OnMouseMotion(null, new MouseMotionEventArgs(lParam.ToInt64()));
                }
                break;

            case WM_EVENT.MOUSE_LBUTTONDOWN:
                if (OnMouseButton != null)
                {
                    OnMouseButton(null, new MouseButtonEventArgs(lParam.ToInt64(), MouseButton.Left, ButtonState.Pressed));
                }
                break;

            case WM_EVENT.MOUSE_LBUTTONUP:
                if (OnMouseButton != null)
                {
                    OnMouseButton(null, new MouseButtonEventArgs(lParam.ToInt64(), MouseButton.Left, ButtonState.Released));
                }
                break;

            case WM_EVENT.MOUSE_MBUTTONDOWN:
                if (OnMouseButton != null)
                {
                    OnMouseButton(null, new MouseButtonEventArgs(lParam.ToInt64(), MouseButton.Middle, ButtonState.Pressed));
                }
                break;

            case WM_EVENT.MOUSE_MBUTTONUP:
                if (OnMouseButton != null)
                {
                    OnMouseButton(null, new MouseButtonEventArgs(lParam.ToInt64(), MouseButton.Middle, ButtonState.Released));
                }
                break;

            case WM_EVENT.MOUSE_RBUTTONDOWN:
                if (OnMouseButton != null)
                {
                    OnMouseButton(null, new MouseButtonEventArgs(lParam.ToInt64(), MouseButton.Right, ButtonState.Pressed));
                }
                break;

            case WM_EVENT.MOUSE_RBUTTONUP:
                if (OnMouseButton != null)
                {
                    OnMouseButton(null, new MouseButtonEventArgs(lParam.ToInt64(), MouseButton.Right, ButtonState.Released));
                }
                break;

            case WM_EVENT.MOUSE_WHEEL:
                if (OnMouseWheel != null)
                {
                    OnMouseWheel(null, new MouseWheelEventArgs(wParam.ToInt32()));
                }
                break;
            }
            return(returnCode);
        }