// This will draw a circle on the canvas wherever the user clicks the mouse. private void HandleMouseDown(object sender, MouseEventArgs e) { // Since we want to actually draw a circle here, we're going to make a new DrawCircleAction and // add it to the list of actions. We get the center of the circle from the mouse event "e", // set the radius to 20, and use our standard pen "_pen" to draw the circle. _actions.Add(new DrawCircleAction(_pen, e.Location.X, e.Location.Y, 20)); }
private void HandleMouseUp(object sender, MouseEventArgs e) { // Here's where we actually draw the shape. We also hide the cursor (by setting it to // null) and turn off the "_isDrawing" flag value. if (DrawLinesButton.Checked) { _actions.Add(new DrawLineAction(_pen, _startPoint.X, _startPoint.Y, e.Location.X, e.Location.Y)); } else if (DrawCirclesButton.Checked) { int radius = MathHelpers.GetRadius(_startPoint, new Point(e.Location.X, e.Location.Y)); if (radius > 0) { _actions.Add(new DrawCircleAction(_pen, _startPoint.X, _startPoint.Y, radius)); } } _canvasModel.Cursor = null; _isDrawing = false; }
private void HandleMouseUp(object sender, MouseEventArgs e) { if (_isDrawing) { // Here's where we actually draw the shape. var drawAction = GetAction(e, _drawingPen); // dsh capture all possible values needed to recreate objects //how to sync with redo and undo - possibly add an ID to both list // don't need to pass everthing if it's already defined like color etc //StoreValuesInObjectforPersistance(drawAction); if (drawAction != null) { _actions.Add(drawAction); StoreValuesInObjectforPersistance(drawAction); } } // We also hide the cursor (by setting it to null). _canvasModel.Cursor = null; _isDrawing = false; }
private void HandleMouseUp(object sender, MouseEventArgs e) { if (_isDrawing) { // Here's where we actually draw the shape. var drawAction = GetAction(e, _drawingPen); if (drawAction != null) { _actions.Add(drawAction); } } // We also hide the cursor (by setting it to null). _canvasModel.Cursor = null; _isDrawing = false; }