/// <summary> /// We use the left mouse button to do exclusive capture of the mouse so we can drag and drag /// to rotate the cube without ever leaving the control /// </summary> /// <param name="args"></param> protected override void RaiseHwndLButtonDown(HwndMouseEventArgs args) { _originalPosition = HwndMouse.GetCursorPosition(); CaptureMouse(); HwndMouse.HideCursor(); base.RaiseHwndLButtonDown(args); }
protected virtual void RaiseHwndMouseEnter(HwndMouseEventArgs args) { var handler = HwndMouseEnter; if (handler != null) { handler(this, args); } }
protected virtual void RaiseHwndMButtonDblClick(HwndMouseEventArgs args) { var handler = HwndMButtonDblClick; if (handler != null) { handler(this, args); } }
protected virtual void RaiseHwndRButtonDown(HwndMouseEventArgs args) { var handler = HwndRButtonDown; if (handler != null) { handler(this, args); } }
private void HandleMouseEvent(object sender, HwndMouseEventArgs e) { _mouseEventSinceLastUpdate = true; var position = e.GetPosition(_hwndHost); _currentState = new MouseState( (int) position.X, (int) position.Y, e.WheelDelta, MapButtonState(e.LeftButton), MapButtonState(e.MiddleButton), MapButtonState(e.RightButton), MapButtonState(e.X1Button), MapButtonState(e.X2Button)); }
/// <summary> /// Invoked when the mouse moves over the second viewport /// </summary> /// <param name="args"></param> protected override void RaiseHwndMouseMove(HwndMouseEventArgs args) { // If the left or right buttons are down, we adjust the yaw and pitch of the cube if (IsMouseCaptured) { var position = HwndMouse.GetCursorPosition(); _yaw += (float) (position.X - _originalPosition.X) * .01f; _pitch += (float) (position.Y - _originalPosition.Y) * .01f; HwndMouse.SetCursorPosition(_originalPosition); } base.RaiseHwndMouseMove(args); }
private void ResetMouseState() { // We need to invoke events for any buttons that were pressed bool fireL = _mouseState.LeftButton == MouseButtonState.Pressed; bool fireM = _mouseState.MiddleButton == MouseButtonState.Pressed; bool fireR = _mouseState.RightButton == MouseButtonState.Pressed; bool fireX1 = _mouseState.X1Button == MouseButtonState.Pressed; bool fireX2 = _mouseState.X2Button == MouseButtonState.Pressed; // Update the state of all of the buttons _mouseState.LeftButton = MouseButtonState.Released; _mouseState.MiddleButton = MouseButtonState.Released; _mouseState.RightButton = MouseButtonState.Released; _mouseState.X1Button = MouseButtonState.Released; _mouseState.X2Button = MouseButtonState.Released; // Fire any events var args = new HwndMouseEventArgs(_mouseState); if (fireL) { RaiseHwndLButtonUp(args); } if (fireM) { RaiseHwndMButtonUp(args); } if (fireR) { RaiseHwndRButtonUp(args); } if (fireX1) { RaiseHwndX1ButtonUp(args); } if (fireX2) { RaiseHwndX2ButtonUp(args); } // The mouse is no longer considered to be in our window _mouseInWindow = false; }
protected override void RaiseHwndLButtonUp(HwndMouseEventArgs args) { HwndMouse.ShowCursor(); ReleaseMouseCapture(); base.RaiseHwndLButtonUp(args); }
private void ResetMouseState() { // We need to invoke events for any buttons that were pressed bool fireL = _mouseState.LeftButton == MouseButtonState.Pressed; bool fireM = _mouseState.MiddleButton == MouseButtonState.Pressed; bool fireR = _mouseState.RightButton == MouseButtonState.Pressed; bool fireX1 = _mouseState.X1Button == MouseButtonState.Pressed; bool fireX2 = _mouseState.X2Button == MouseButtonState.Pressed; // Update the state of all of the buttons _mouseState.LeftButton = MouseButtonState.Released; _mouseState.MiddleButton = MouseButtonState.Released; _mouseState.RightButton = MouseButtonState.Released; _mouseState.X1Button = MouseButtonState.Released; _mouseState.X2Button = MouseButtonState.Released; // Fire any events var args = new HwndMouseEventArgs(_mouseState); if (fireL) RaiseHwndLButtonUp(args); if (fireM) RaiseHwndMButtonUp(args); if (fireR) RaiseHwndRButtonUp(args); if (fireX1) RaiseHwndX1ButtonUp(args); if (fireX2) RaiseHwndX2ButtonUp(args); // The mouse is no longer considered to be in our window _mouseInWindow = false; }
protected virtual void RaiseHwndX2ButtonUp(HwndMouseEventArgs args) { var handler = HwndX2ButtonUp; if (handler != null) handler(this, args); }
protected virtual void RaiseHwndX1ButtonDblClick(HwndMouseEventArgs args) { var handler = HwndX1ButtonDblClick; if (handler != null) handler(this, args); }
protected virtual void RaiseHwndMouseWheel(HwndMouseEventArgs args) { var handler = HwndMouseWheel; if (handler != null) handler(this, args); }