public void FinishAddingShape(float mass, float radius, GravityShapeType type) { var vel = this._endPoint - this._startPoint; GravityShape gs = null; switch (type) { case GravityShapeType.Asteroid: gs = new GravityAsteroid(this._startPoint, mass) { Velocity = vel }; break; case GravityShapeType.Circle: var circle = new CircleShape(radius) { FillColor = Color.Cyan, Position = this._startPoint }; gs = new GravityShape(circle, mass) { Velocity = vel }; break; } if (gs != null) { this.GravityShapes.Add(gs); } this._addingShape = false; }
/// <summary> /// Event handler for the RenderWindow MouseButtonReleased event /// </summary> public void MouseButtonReleased(object sender, MouseButtonEventArgs e) { GravityShapeType gst = GravityShapeType.Circle; switch (e.Button) { case Mouse.Button.Left: gst = GravityShapeType.Circle; break; case Mouse.Button.Right: gst = GravityShapeType.Asteroid; break; } this._gsController.FinishAddingShape(this.NewShapeMass, this.NewRadius, gst); this.NotifyPropertyChanged(() => this.ShapeCount); }