private void GraphicsBoxMouseMove(object sender, HwndMouseEventArgs e) { Point position = e.Position; if (VM.GridSize > 1) { position = RoundToNearestGridPoint(e.Position); } if (isDragging) { VM.CurrentSelection = new xnaFrameworkAlias.Microsoft.Xna.Framework.Rectangle( (int)(downPosition.X * windowsScalingOffset), (int)(downPosition.Y * windowsScalingOffset), (int)((-downPosition.X + position.X) * windowsScalingOffset), (int)((-downPosition.Y + position.Y) * windowsScalingOffset) ); } }
private void GraphicsBoxMouseLeftDown(object sender, HwndMouseEventArgs e) { if (VM.GridSize > 1) { downPosition = RoundToNearestGridPoint(e.Position); } else { downPosition = e.Position; } isDragging = true; }
private void ResetMouseState() { bool fireL = mouseState.LeftButton == MouseButtonState.Pressed; bool fireM = mouseState.MiddleButton == MouseButtonState.Pressed; bool fireR = mouseState.RightButton == MouseButtonState.Pressed; mouseState.LeftButton = MouseButtonState.Released; mouseState.MiddleButton = MouseButtonState.Released; mouseState.RightButton = MouseButtonState.Released; HwndMouseEventArgs args = new HwndMouseEventArgs(mouseState); if (fireL && HwndLButtonUp != null) HwndLButtonUp(this, args); if (fireM && HwndMButtonUp != null) HwndMButtonUp(this, args); if (fireR && HwndRButtonUp != null) HwndRButtonUp(this, args); mouseInWindow = false; }