private void HandleMouseInput(InputState input) { Vector2 point = new Vector2(input.CurrentMouseState.X, input.CurrentMouseState.Y); if (input.LastMouseState.LeftButton == ButtonState.Released && input.CurrentMouseState.LeftButton == ButtonState.Pressed) { //create mouse spring _pickedGeom = PhysicsSimulator.Collide(point); if (_pickedGeom != null) { _mousePickSpring = SpringFactory.Instance.CreateFixedLinearSpring(PhysicsSimulator, _pickedGeom.Body, _pickedGeom.Body. GetLocalPosition(point), point, 20, 10); } } else if (input.LastMouseState.LeftButton == ButtonState.Pressed && input.CurrentMouseState.LeftButton == ButtonState.Released) { //destroy mouse spring if (_mousePickSpring != null && _mousePickSpring.IsDisposed == false) { _mousePickSpring.Dispose(); _mousePickSpring = null; } } //move anchor point if (input.CurrentMouseState.LeftButton == ButtonState.Pressed && _mousePickSpring != null) { _mousePickSpring.WorldAttachPoint = point; } }
private void SimulatorView_MouseLeftButtonUp(object sender, MouseEventArgs e) { if (_mousePickSpring != null && _mousePickSpring.IsDisposed == false) { _mousePickSpring.Dispose(); _mousePickSpring = null; RemoveFixedLinearSpringBrush(_mouseSpringBrush); } }
protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e) { base.OnMouseLeftButtonUp(e); if (mousePickSpring != null && mousePickSpring.IsDisposed == false) { mousePickSpring.Dispose(); mousePickSpring = null; RemoveVisual(mouseSpringVisual); } }
void polygon_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (_pickedSprite != null) { _pickedSprite.ReleaseMouseCapture(); } if (_mousePickSpring != null && _mousePickSpring.IsDisposed == false) { _mousePickSpring.Dispose(); _mousePickSpring = null; _lineShowSpring.Visibility = Visibility.Collapsed; e.Handled = true; } if (MouseLeftButtonUp != null && _pickedSprite != null) { MouseLeftButtonUp(_pickedSprite.Name); } _pickedSprite = null; }