Beispiel #1
0
        public virtual void ProcessEvents(Event e)
        {
            if (e.isKey)
            {
                OnKeyDown(this, e);
                return;
            }

            if (!viewRect.Contains(e.mousePosition))
            {
                return;
            }

            switch (e.button)
            {
            case 0:
                switch (e.type)
                {
                case EventType.MouseDown:
                    OnLeftMouseDown?.Invoke(this, e);
                    break;

                case EventType.MouseDrag:
                    OnLeftMouseDrag?.Invoke(this, e);
                    break;

                case EventType.MouseUp:
                    OnLeftMouseUp?.Invoke(this, e);
                    break;
                }
                break;

            case 1:
                switch (e.type)
                {
                case EventType.MouseDown:
                    OnRightMouseDown?.Invoke(this, e);
                    break;

                case EventType.MouseDrag:
                    OnRightMouseDrag?.Invoke(this, e);
                    break;

                case EventType.MouseUp:
                    OnRightMouseUp?.Invoke(this, e);
                    break;
                }
                break;
            }
        }
        private IntPtr MouseHookCallback(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode < 0)
            {
                return(CallNextHookEx(_hookHandle, nCode, wParam, lParam));
            }
            switch ((MouseMessages)wParam)
            {
            case MouseMessages.WM_LBUTTONDOWN:
                OnLeftMouseDown?.Invoke(this, null);
                break;

            case MouseMessages.WM_RBUTTONDOWN:
                OnRightMouseDown?.Invoke(this, null);
                break;
            }
            return(CallNextHookEx(_hookHandle, nCode, wParam, lParam));
        }
 private void MouseHook_OnRightMouseDown(object sender, Point p)
 {
     DisposeMouseHook();
     OnRightMouseDown?.Invoke(this, p);
 }