protected override void ProcessUp(ref MouseEventExtArgs e) { base.ProcessUp(ref e); if (e.Clicks == 2) { StopDoubleClickWaiting(); } if (e.Clicks == 1) { StartDoubleClickWaiting(e); } }
/// <summary> /// Creates <see cref="MouseEventExtArgs" /> from relevant mouse data. /// </summary> /// <param name="wParam">First Windows Message parameter.</param> /// <param name="mouseInfo">A MouseStruct containing information from which to construct MouseEventExtArgs.</param> /// <returns>A new MouseEventExtArgs object.</returns> private static MouseEventExtArgs FromRawDataUniversal(IntPtr wParam, MouseStruct mouseInfo) { MouseButtons button = MouseButtons.None; short mouseDelta = 0; int clickCount = 0; bool isMouseButtonDown = false; bool isMouseButtonUp = false; switch ((long)wParam) { case Messages.WM_LBUTTONDOWN: isMouseButtonDown = true; button = MouseButtons.Left; clickCount = 1; break; case Messages.WM_LBUTTONUP: isMouseButtonUp = true; button = MouseButtons.Left; clickCount = 1; break; case Messages.WM_LBUTTONDBLCLK: isMouseButtonDown = true; button = MouseButtons.Left; clickCount = 2; break; case Messages.WM_RBUTTONDOWN: isMouseButtonDown = true; button = MouseButtons.Right; clickCount = 1; break; case Messages.WM_RBUTTONUP: isMouseButtonUp = true; button = MouseButtons.Right; clickCount = 1; break; case Messages.WM_RBUTTONDBLCLK: isMouseButtonDown = true; button = MouseButtons.Right; clickCount = 2; break; case Messages.WM_MBUTTONDOWN: isMouseButtonDown = true; button = MouseButtons.Middle; clickCount = 1; break; case Messages.WM_MBUTTONUP: isMouseButtonUp = true; button = MouseButtons.Middle; clickCount = 1; break; case Messages.WM_MBUTTONDBLCLK: isMouseButtonDown = true; button = MouseButtons.Middle; clickCount = 2; break; case Messages.WM_MOUSEWHEEL: mouseDelta = mouseInfo.MouseData; break; case Messages.WM_XBUTTONDOWN: button = mouseInfo.MouseData == 1 ? MouseButtons.XButton1 : MouseButtons.XButton2; isMouseButtonDown = true; clickCount = 1; break; case Messages.WM_XBUTTONUP: button = mouseInfo.MouseData == 1 ? MouseButtons.XButton1 : MouseButtons.XButton2; isMouseButtonUp = true; clickCount = 1; break; case Messages.WM_XBUTTONDBLCLK: isMouseButtonDown = true; button = mouseInfo.MouseData == 1 ? MouseButtons.XButton1 : MouseButtons.XButton2; clickCount = 2; break; case Messages.WM_MOUSEHWHEEL: mouseDelta = mouseInfo.MouseData; break; } var e = new MouseEventExtArgs( button, clickCount, mouseInfo.Point, mouseDelta, mouseInfo.Timestamp, isMouseButtonDown, isMouseButtonUp); return(e); }
protected override MouseEventExtArgs GetEventArgs(CallbackData data) { return(MouseEventExtArgs.FromRawDataGlobal(data)); }
private void StartDoubleClickWaiting(MouseEventExtArgs e) { m_PreviousClicked = e.Button; m_PreviousClickedTime = e.Timestamp; m_PreviousClickedPosition = e.Point; }