public override void MouseHold(SketchControl s, Point p) { base.MouseHold(s, p); if (penAction == null) penAction = new penAction(new List<Point>(), width, p, brush, 0); penAction.points.Add(startpoint); }
/// <summary> /// penAction saves a list of points, but when the mouse moves fast these are often not close enough to eachother. /// In drawPen we draw a line from each point to the next, as well as a circle around each point. This makes the line appear smooth. /// </summary> /// <param name="action"></param> /// <param name="gr"></param> public void drawPen(penAction action, Graphics gr) { for (int i = 0; i < action.points.Count - 1; i++) { gr.DrawLine(new Pen(((SolidBrush)action.brush).Color, action.width), action.points[i], action.points[i + 1]); gr.FillEllipse(action.brush, action.points[i].X - action.width / 2, action.points[i].Y - action.width / 2, action.width, action.width); } gr.FillEllipse(action.brush, action.points[action.points.Count - 1].X - action.width / 2, action.points[action.points.Count - 1].Y - action.width / 2, action.width, action.width); }
public override void Complete(SketchControl s, Point p1, Point p2) { penAction.brush = brush; s.sketch.stuff.Add(penAction); s.sketch.undo.Push(penAction); s.sketch.redo.Clear(); penAction = null; }