/// <summary> /// Trigger for our "Custom" canvas event, since for some mind-boggling /// reason the WPF canvas doesn't support a double-click event by default /// </summary> private void PollDoubleClick(object sender, MouseButtonEventArgs e) { if (e.ChangedButton == MouseButton.Left && e.ClickCount == 2) { MouseDoubleClickEvent?.Invoke(sender, e); } }
public void MouseClick(Vector2Int position, MouseButton button) { var x = position.x - X - ParentX; var y = position.y - Y - ParentY; var totalMS = (float)Service.Get <UltimaGame>().TotalMS; var doubleClick = false; if (_maxTimeForDoubleClick != 0f) { if (totalMS <= _maxTimeForDoubleClick) { _maxTimeForDoubleClick = 0f; doubleClick = true; } } else { _maxTimeForDoubleClick = totalMS + UltimaGameSettings.UserInterface.Mouse.DoubleClickMS; } if (button == MouseButton.Right && !IsUncloseableWithRMB) { CloseWithRightMouseButton(); return; } if (doubleClick) { OnMouseDoubleClick(x, y, button); MouseDoubleClickEvent?.Invoke(this, x, y, button); } else { OnMouseClick(x, y, button); MouseClickEvent?.Invoke(this, x, y, button); } }
private void MouseDoubleClickHandler(object sender, MouseButtonEventArgs e) { e.Handled = true; Point mousePosition = e.GetPosition(_mapV); Location polygonPointLocation = _mapV.ViewportPointToLocation(mousePosition); MouseDoubleClickEvent?.Invoke(polygonPointLocation); }
public void OnMouseDoubleClickEvent() { if (!IsGroupContact) { if (User.userId == AntSdkService.AntSdkLoginOutput.userId) { return; } MouseDoubleClickEvent?.Invoke(User.userId, EventArgs.Empty); } else { MouseDoubleClickEvent?.Invoke(GroupInfoVM, EventArgs.Empty); } }
/// <summary> /// </summary> private void OnMouseUp(object sender, MouseEventArgs e) { if (e.Clicks < 1) { return; } if (e.Button.Equals(mouseButton)) { if (MouseDoubleClickEvent != null) { MouseDoubleClickEvent.Invoke(null, new MouseEventExtArgs(e)); } // 停止计时器 doubleClickTimer.Enabled = false; mouseButton = MouseButtons.None; } else { doubleClickTimer.Enabled = true; mouseButton = e.Button; } }
public void MouseClick(Point position, MouseButton button) { int x = position.X - X - ParentX; int y = position.Y - Y - ParentY; float totalMS = (float)Service.Get <UltimaGame>().TotalMS; bool doubleClick = false; if (m_MaxTimeForDoubleClick != 0f) { if (totalMS <= m_MaxTimeForDoubleClick) { m_MaxTimeForDoubleClick = 0f; doubleClick = true; } } else { m_MaxTimeForDoubleClick = totalMS + Settings.UserInterface.Mouse.DoubleClickMS; } if (button == MouseButton.Right && !IsUncloseableWithRMB) { CloseWithRightMouseButton(); return; } if (doubleClick) { OnMouseDoubleClick(x, y, button); MouseDoubleClickEvent?.Invoke(this, x, y, button); } else { OnMouseClick(x, y, button); MouseClickEvent?.Invoke(this, x, y, button); } }
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)); }