/// <summary> /// Raises the MouseEvent event. /// </summary> /// <param name="e">An instance of MouseRawEventArgs</param> public void OnMouseEvent(MouseRawEventArgs e) { if (MouseEvent != null) { MouseEvent(e); } }
void m_MouseEvent(MouseRawEventArgs raw_e) { cursorPosition = raw_e.Position; switch (raw_e.Action) { case MouseAction.Up: HideButton(raw_e); break; case MouseAction.Down: ShowButton(raw_e.Button); break; case MouseAction.DblClk: lastDblClk = raw_e; IndicateDoubleClick(raw_e.Button); break; case MouseAction.Move: UpdatePosition(); break; case MouseAction.Wheel: IndicateWheel(raw_e); break; default: break; } }
void m_MouseEvent(MouseRawEventArgs raw_e) { cursorPosition = raw_e.Position; if (raw_e.Action == MouseAction.Move) { UpdatePosition(); } }
private void IndicateWheel(MouseRawEventArgs raw_e) { panel_mouse.Visible = true; Log.e("WHEEL", "Display " + raw_e.wheelDelta.ToString()); WheelIconTimer.Stop(); WheelIconTimer.Start(); if (raw_e.wheelDelta < 0) { pb_wheel_down.Visible = true; pb_wheel_up.Visible = false; } else if (raw_e.wheelDelta > 0) { pb_wheel_up.Visible = true; pb_wheel_down.Visible = false; } }
/// <summary> /// Processes the key event captured by the hook. /// </summary> private IntPtr HookCallback(int nCode, UIntPtr wParam, ref NativeMethodsMouse.MSLLHOOKSTRUCT lParam) { if (nCode == NativeMethodsMouse.HC_ACTION) { MouseRawEventArgs args = new MouseRawEventArgs(lParam); args.ParseWparam(wParam); CheckDoubleClick(args); Log.e("ME", String.Format("MOUSE: Button:{0} Action:{1} Orig:{2}", args.Button.ToString(), args.Action.ToString(), args.Event.ToString())); OnMouseEvent(args); } return(NativeMethodsMouse.CallNextHookEx(hookID, nCode, wParam, ref lParam)); }
private void CheckDoubleClick(MouseRawEventArgs args) { if (lastDownEvent != null && args.Action == MouseAction.Down) { if (args.Button == lastDownEvent.Button && args.Msllhookstruct.time <= lastDownEvent.Msllhookstruct.time + doubleClickTime && args.Msllhookstruct.pt.Equals(lastDownEvent.Msllhookstruct.pt)) { args.Action = MouseAction.DblClk; Log.e("ME", "DBLCLK"); } } if (args.Action == MouseAction.Down) { lastDownEvent = args; } }
private void HideButton(MouseRawEventArgs raw_e) { switch (raw_e.Button) { case MouseButton.LButton: pb_left.Visible = false; doubleClickReleased = true; if (pb_left_double.Visible) { if (raw_e.Msllhookstruct.time - lastDblClk.Msllhookstruct.time > DoubleClickIconTimer.Interval) { pb_left_double.Visible = false; } else { DoubleClickIconTimer.Stop(); DoubleClickIconTimer.Start(); } } break; case MouseButton.RButton: pb_right.Visible = false; break; case MouseButton.MButton: pb_middle.Visible = false; break; case MouseButton.XButton: break; case MouseButton.None: break; default: break; } HideMouseIfNoButtonPressed(); }