Exemplo n.º 1
0
 public void OnMouseUp(object sender, MouseButtonEventArgs e)
 {
     if (MouseUpEvent != null)
     {
         MouseUpEvent.Invoke(sender, e);
     }
 }
Exemplo n.º 2
0
        private int MouseHookProc(int nCode, IntPtr wParam, IntPtr lParam)
        {
            Win32Api.MouseHookStruct MyMouseHookStruct = (Win32Api.MouseHookStruct)Marshal.PtrToStructure(lParam, typeof(Win32Api.MouseHookStruct));
            if (nCode < 0)
            {
                return(Win32Api.CallNextHookEx(hHook, nCode, wParam, lParam));
            }
            else
            {
                if (MouseClickEvent != null)
                {
                    MouseButtons button     = MouseButtons.None;
                    int          clickCount = 0;
                    switch ((Int32)wParam)
                    {
                    case WM_LBUTTONDOWN:
                        button     = MouseButtons.Left;
                        clickCount = 1;
                        MouseDownEvent?.Invoke(this, new MouseEventArgs(button, clickCount, point.X, point.Y, 0));
                        break;

                    case WM_RBUTTONDOWN:
                        button     = MouseButtons.Right;
                        clickCount = 1;
                        MouseDownEvent?.Invoke(this, new MouseEventArgs(button, clickCount, point.X, point.Y, 0));
                        break;

                    case WM_MBUTTONDOWN:
                        button     = MouseButtons.Middle;
                        clickCount = 1;
                        MouseDownEvent?.Invoke(this, new MouseEventArgs(button, clickCount, point.X, point.Y, 0));
                        break;

                    case WM_LBUTTONUP:
                        button     = MouseButtons.Left;
                        clickCount = 1;
                        MouseUpEvent?.Invoke(this, new MouseEventArgs(button, clickCount, point.X, point.Y, 0));
                        break;

                    case WM_RBUTTONUP:
                        button     = MouseButtons.Right;
                        clickCount = 1;
                        MouseUpEvent?.Invoke(this, new MouseEventArgs(button, clickCount, point.X, point.Y, 0));
                        break;

                    case WM_MBUTTONUP:
                        button     = MouseButtons.Middle;
                        clickCount = 1;
                        MouseUpEvent?.Invoke(this, new MouseEventArgs(button, clickCount, point.X, point.Y, 0));
                        break;
                    }

                    var e = new MouseEventArgs(button, clickCount, point.X, point.Y, 0);
                    MouseClickEvent(this, e);
                }
                this.Point = new Point(MyMouseHookStruct.pt.x, MyMouseHookStruct.pt.y);
                return(Win32Api.CallNextHookEx(hHook, nCode, wParam, lParam));
            }
        }
Exemplo n.º 3
0
        public void MouseUp(Point position, MouseButton button)
        {
            int x = (int)position.X - X - ParentX;
            int y = (int)position.Y - Y - ParentY;

            OnMouseUp(x, y, button);
            MouseUpEvent?.Invoke(this, x, y, button);
        }
Exemplo n.º 4
0
        public void MouseUp(Vector2Int position, MouseButton button)
        {
            var x = (int)position.x - X - ParentX;
            var y = (int)position.y - Y - ParentY;

            OnMouseUp(x, y, button);
            MouseUpEvent?.Invoke(this, x, y, button);
        }
Exemplo n.º 5
0
        private int MouseHookProc(int nCode, IntPtr wParam, IntPtr lParam)
        {
            var myMouseHookStruct = (Win32Api.MouseHookStruct)Marshal.PtrToStructure(lParam, typeof(Win32Api.MouseHookStruct));

            if (nCode < 0)
            {
                return(Win32Api.CallNextHookEx(_hHook, nCode, wParam, lParam));
            }

            MouseButtons button;

            int clickCount;

            switch ((int)wParam)
            {
            case WmLbuttondown:
                button     = MouseButtons.Left;
                clickCount = 1;
                MouseDownEvent?.Invoke(this, new MouseEventArgs(button, clickCount, _point.X, _point.Y, 0));
                break;

            case WmRbuttondown:
                button     = MouseButtons.Right;
                clickCount = 1;
                MouseDownEvent?.Invoke(this, new MouseEventArgs(button, clickCount, _point.X, _point.Y, 0));
                break;

            case WmMbuttondown:
                button     = MouseButtons.Middle;
                clickCount = 1;
                MouseDownEvent?.Invoke(this, new MouseEventArgs(button, clickCount, _point.X, _point.Y, 0));
                break;

            case WmLbuttonup:
                button     = MouseButtons.Left;
                clickCount = 1;
                MouseUpEvent?.Invoke(this, new MouseEventArgs(button, clickCount, _point.X, _point.Y, 0));
                break;

            case WmRbuttonup:
                button     = MouseButtons.Right;
                clickCount = 1;
                MouseUpEvent?.Invoke(this, new MouseEventArgs(button, clickCount, _point.X, _point.Y, 0));
                break;

            case WmMbuttonup:
                button     = MouseButtons.Middle;
                clickCount = 1;
                MouseUpEvent?.Invoke(this, new MouseEventArgs(button, clickCount, _point.X, _point.Y, 0));
                break;
            }

            if (myMouseHookStruct != null)
            {
                Point = new Point(myMouseHookStruct.pt.x, myMouseHookStruct.pt.y);
            }
            return(Win32Api.CallNextHookEx(_hHook, nCode, wParam, lParam));
        }
Exemplo n.º 6
0
        //地图控件鼠标左键弹起事件
        private void axMapControl_eventLButtonUp(object sender, _DHOSOFTMapControlEvents_eventLButtonUpEvent e)
        {
            if (Utils.bPublishEvent == false)
            {
                return;
            }
            MapLngLat        lnglat = new MapLngLat(e.dLong, e.dLat);
            MFMouseEventArgs args   = new MFMouseEventArgs(lnglat, MouseButtons.Left, e.x, e.y);

            if (MouseUpEvent != null)
            {
                MouseUpEvent.Invoke(this, args);
            }
        }
Exemplo n.º 7
0
    private void HandleMouseUp()
    {
        foreach (GameObject gameObject in _selectedObjects.ToArray())
        {
            if (_clickTimeout > DateTime.Now)
            {
                OnClick?.Invoke(this, gameObject.name, gameObject);
            }
            OnMouseUp?.Invoke(this, gameObject.name, gameObject);

            _selectedObjects.Remove(gameObject);
        }

        isDown = false;
    }
Exemplo n.º 8
0
        // 鼠标弹起事件
        private void mapControl_MouseUp(object sender, MouseEventArgs e)
        {
            if (MapFrame.GMap.Common.Utils.bPublishEvent == false)
            {
                return;
            }

            var p = FromLocalToLngLat(e.X, e.Y);
            MFMouseEventArgs args = new MFMouseEventArgs(p, e.Button, e.X, e.Y);

            if (MouseUpEvent != null)
            {
                MouseUpEvent.Invoke(this, args);
            }
        }
Exemplo n.º 9
0
    private void OnMouseUp()
    {
        if (_stop)
        {
            return;
        }

        if (IsRotation && !_isMoving)
        {
            RotateBrick();
        }

        if (_isMoving)
        {
            _isMoving = false;
            var newPosition = SnapToGrid();
            gridManager.MoveBrickToPosition(transform, newPosition, _lastPosition);
        }

        MouseUpEvent?.Invoke();
    }
Exemplo n.º 10
0
        protected override IntPtr CustomHookProc(IntPtr wParam, IntPtr lParam)
        {
            MSLLHOOKSTRUCT ms =
                (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
            bool injected = (ms.flags & (uint)LLMHF.INJECTED) != 0;

            switch ((WM)wParam)
            {
            case WM.LBUTTONDOWN:
                if (MouseDownEvent?.Invoke(this, (uint)VK.LBUTTON, ms.pt.x, ms.pt.y, 0, injected) == true)
                {
                    return((IntPtr)(-1));
                }
                break;

            case WM.LBUTTONUP:
                if (MouseUpEvent?.Invoke(this, (uint)VK.LBUTTON, ms.pt.x, ms.pt.y, 0, injected) == true)
                {
                    return((IntPtr)(-1));
                }
                break;

            case WM.MOUSEMOVE:
                if (MouseMoveEvent?.Invoke(this, 0, ms.pt.x, ms.pt.y, 0, injected) == true)
                {
                    return((IntPtr)(-1));
                }
                break;

            case WM.MOUSEWHEEL:
                if (MouseWheelEvent?.Invoke(this, 0, ms.pt.x, ms.pt.y, HighWord(ms.mouseData), injected) == true)
                {
                    return((IntPtr)(-1));
                }
                break;

            case WM.MOUSEHWHEEL:
                if (MouseHWheelEvent?.Invoke(this, 0, ms.pt.x, ms.pt.y, HighWord(ms.mouseData), injected) == true)
                {
                    return((IntPtr)(-1));
                }
                break;

            case WM.RBUTTONDOWN:
                if (MouseDownEvent?.Invoke(this, (uint)VK.RBUTTON, ms.pt.x, ms.pt.y, 0, injected) == true)
                {
                    return((IntPtr)(-1));
                }
                break;

            case WM.RBUTTONUP:
                if (MouseUpEvent?.Invoke(this, (uint)VK.RBUTTON, ms.pt.x, ms.pt.y, 0, injected) == true)
                {
                    return((IntPtr)(-1));
                }
                break;

            case WM.MBUTTONDOWN:
                if (MouseDownEvent?.Invoke(this, (uint)VK.MBUTTON, ms.pt.x, ms.pt.y, 0, injected) == true)
                {
                    return((IntPtr)(-1));
                }
                break;

            case WM.MBUTTONUP:
                if (MouseUpEvent?.Invoke(this, (uint)VK.MBUTTON, ms.pt.x, ms.pt.y, 0, injected) == true)
                {
                    return((IntPtr)(-1));
                }
                break;

            case WM.XBUTTONDOWN:
                if (HighWord(ms.mouseData) == (int)MOUSEDATA.XBUTTON1)
                {
                    if (MouseDownEvent?.Invoke(this, (uint)VK.XBUTTON1, ms.pt.x, ms.pt.y, 0, injected) == true)
                    {
                        return((IntPtr)(-1));
                    }
                }
                else if (HighWord(ms.mouseData) == (int)MOUSEDATA.XBUTTON2)
                {
                    if (MouseDownEvent?.Invoke(this, (uint)VK.XBUTTON2, ms.pt.x, ms.pt.y, 0, injected) == true)
                    {
                        return((IntPtr)(-1));
                    }
                }
                break;

            case WM.XBUTTONUP:
                if (HighWord(ms.mouseData) == (int)MOUSEDATA.XBUTTON1)
                {
                    if (MouseUpEvent?.Invoke(this, (uint)VK.XBUTTON1, ms.pt.x, ms.pt.y, 0, injected) == true)
                    {
                        return((IntPtr)(-1));
                    }
                }
                else if (HighWord(ms.mouseData) == (int)MOUSEDATA.XBUTTON2)
                {
                    if (MouseUpEvent?.Invoke(this, (uint)VK.XBUTTON2, ms.pt.x, ms.pt.y, 0, injected) == true)
                    {
                        return((IntPtr)(-1));
                    }
                }
                break;
            }
            return(IntPtr.Zero);
        }
Exemplo n.º 11
0
 private void OnMouseUp()
 {
     MouseUpEvent.Invoke();
 }
Exemplo n.º 12
0
        public override bool Poll()
        {
            bool returnStatus = false;



            MouseStateEventData[] eventDataArray;

            lock (_mouseEventData)
            {
                eventDataArray = _mouseEventData.ToArray();
                _mouseEventData.Clear();
            }

            if (eventDataArray.Length == 0)
            {
                return(returnStatus);
            }


            MouseButtons[] currentState = _getButtonState(eventDataArray);

            Point currentPoint = eventDataArray[0].Data.Position;


            MouseButtons[] pressedButtons  = GetNewItems(_mouseStateArray, currentState);
            MouseButtons[] releasedButtons = GetMissingItems(_mouseStateArray, currentState);

            //Subtract current values so positive values result in a positive delta.
            Point relativePoint = currentPoint - _mouseStatePoint;
            int   wheelDelta    = eventDataArray[0].Data.WheelDelta;

            _mouseStateWheel = _mouseStateWheel + wheelDelta;


            MouseEventData eventData = new MouseEventData(pressedButtons, releasedButtons, currentState, currentPoint, relativePoint, _mouseStateWheel, wheelDelta);

            //System.Diagnostics.Trace.WriteLine(eventData.ToString());

            if (pressedButtons.Length != 0 || releasedButtons.Length != 0 || relativePoint != Point.Empty || wheelDelta != 0)
            {
                MouseEvent?.Invoke(new MouseEventArgs(eventData));
                returnStatus = true;
            }

            if (pressedButtons.Length != 0)
            {
                MouseDownEvent?.Invoke(new MouseEventArgs(eventData));
            }

            if (releasedButtons.Length != 0)
            {
                MouseUpEvent?.Invoke(new MouseEventArgs(eventData));
            }


            if (relativePoint != Point.Empty)
            {
                MouseMoveEvent?.Invoke(new MouseEventArgs(eventData));
            }

            if (wheelDelta != 0)
            {
                MouseWheelEvent?.Invoke(new MouseEventArgs(eventData));
            }

            _mouseStateArray = currentState;
            return(returnStatus);
        }
Exemplo n.º 13
0
 private void OnMouseUp(Keys key) => MouseUpEvent?.Invoke(this, key, DateTime.Now);
Exemplo n.º 14
0
        private int MouseHookProc(int nCode, IntPtr wParam, IntPtr lParam)
        {
            MouseHookStruct mouseHookStruct = (MouseHookStruct)Marshal.PtrToStructure(lParam, typeof(MouseHookStruct));
            bool            flag            = nCode < 0;
            int             result;

            if (flag)
            {
                result = HookFunction.CallNextHookEx(hHook, nCode, wParam, lParam);
            }
            else
            {
                switch ((int)wParam)
                {
                case 513:
                {
                    MouseButtons button = MouseButtons.Left;
                    int          clicks = 1;
                    MouseDownEvent?.Invoke(this, new MouseEventArgs(button, clicks, point.X, point.Y, 0));
                    break;
                }

                case 514:
                {
                    MouseButtons button = MouseButtons.Left;
                    int          clicks = 1;
                    MouseUpEvent?.Invoke(this, new MouseEventArgs(button, clicks, point.X, point.Y, 0));
                    break;
                }

                case 516:
                {
                    MouseButtons button = MouseButtons.Right;
                    int          clicks = 1;
                    MouseDownEvent?.Invoke(this, new MouseEventArgs(button, clicks, point.X, point.Y, 0));
                    break;
                }

                case 517:
                {
                    MouseButtons button = MouseButtons.Right;
                    int          clicks = 1;
                    MouseUpEvent?.Invoke(this, new MouseEventArgs(button, clicks, point.X, point.Y, 0));
                    break;
                }

                case 519:
                {
                    MouseButtons button = MouseButtons.Middle;
                    int          clicks = 1;
                    MouseDownEvent?.Invoke(this, new MouseEventArgs(button, clicks, point.X, point.Y, 0));
                    break;
                }

                case 520:
                {
                    MouseButtons button = MouseButtons.Middle;
                    int          clicks = 1;
                    MouseUpEvent?.Invoke(this, new MouseEventArgs(button, clicks, point.X, point.Y, 0));
                    break;
                }
                }
                this.Point = new Point(mouseHookStruct.pt.x, mouseHookStruct.pt.y);
                result     = HookFunction.CallNextHookEx(hHook, nCode, wParam, lParam);
            }
            return(result);
        }
Exemplo n.º 15
0
        private int MouseHookProc(int nCode, int wParam, IntPtr lParam)
        {
            if (nCode >= 0)
            {
                var   mouseHookStruct = (MouseHookStruct)Marshal.PtrToStructure(lParam, typeof(MouseHookStruct));
                var   button          = MouseButtons.None;
                short mouseDelta      = 0;
                var   clickCount      = 0;
                var   mouseDown       = false;
                var   mouseUp         = false;
                switch ((WindowsMessage)wParam)
                {
                case WindowsMessage.WM_LBUTTONDOWN:
                    mouseDown  = true;
                    button     = MouseButtons.Left;
                    clickCount = 1;
                    break;

                case WindowsMessage.WM_LBUTTONUP:
                    mouseUp    = true;
                    button     = MouseButtons.Left;
                    clickCount = 1;
                    break;

                case WindowsMessage.WM_LBUTTONDBLCLK:
                    button     = MouseButtons.Left;
                    clickCount = 2;
                    break;

                case WindowsMessage.WM_RBUTTONDOWN:
                    mouseDown  = true;
                    button     = MouseButtons.Right;
                    clickCount = 1;
                    break;

                case WindowsMessage.WM_RBUTTONUP:
                    mouseUp    = true;
                    button     = MouseButtons.Right;
                    clickCount = 1;
                    break;

                case WindowsMessage.WM_RBUTTONDBLCLK:
                    button     = MouseButtons.Right;
                    clickCount = 2;
                    break;

                case WindowsMessage.WM_MOUSEWHEEL:
                    mouseDelta = (short)((mouseHookStruct.MouseData >> 16) & 0xffff);
                    break;
                }
                var e = new MouseEventExtArgs(
                    button,
                    clickCount,
                    mouseHookStruct.Point.X,
                    mouseHookStruct.Point.Y,
                    mouseDelta);
                if (MouseEvent != null)
                {
                    MouseEvent.Invoke(null, e);
                }
                if (MouseUpEvent != null && mouseUp)
                {
                    MouseUpEvent.Invoke(null, e);
                }
                if (MouseDownEvent != null && mouseDown)
                {
                    MouseDownEvent.Invoke(null, e);
                }
                if (MouseClickEvent != null && clickCount > 0)
                {
                    MouseClickEvent.Invoke(null, e);
                }
                if (MouseDoubleClickEvent != null && clickCount == 2)//这里不会触发
                {
                    MouseDoubleClickEvent.Invoke(null, e);
                }
                if (MouseWheelEvent != null && mouseDelta != 0)
                {
                    MouseWheelEvent.Invoke(null, e);
                }
                if (MouseMoveEvent != null && (oldX != mouseHookStruct.Point.X || oldY != mouseHookStruct.Point.Y))
                {
                    oldX = mouseHookStruct.Point.X;
                    oldY = mouseHookStruct.Point.Y;
                    if (MouseMoveEvent != null)
                    {
                        MouseMoveEvent.Invoke(null, e);
                    }
                }
                if (e.Handled)
                {
                    return(-1);
                }
            }
            return(NativeMethods.CallNextHookEx(idHook, nCode, wParam, lParam));
        }
Exemplo n.º 16
0
 protected virtual void OnMouseUpEvent(EditorEventArgs e)
 {
     e.ListViewItemCollection = listView1.SelectedItems;
     MouseUpEvent?.Invoke(this, e);
 }