private bool _drawingInProcess = false; // Set to true when drawing /// <summary> /// Left nouse button is pressed /// </summary> /// <param name="drawArea"></param> /// <param name="e"></param> public override void OnMouseDown(DrawArea drawArea, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { _drawingInProcess = false; newPolyLine = null; } else { Point p = drawArea.BackTrackMouse(new Point(e.X, e.Y)); if (_drawingInProcess == false) { newPolyLine = new DrawPolyLine(p.X, p.Y, p.X + 1, p.Y + 1, drawArea.LineColor, drawArea.LineWidth, drawArea.PenType); newPolyLine.EndPoint = new Point(p.X + 1, p.Y + 1); AddNewObject(drawArea, newPolyLine); _drawingInProcess = true; } else { // Drawing is in process, so simply add a new point newPolyLine.AddPoint(p); newPolyLine.EndPoint = p; } } }
/// <summary> /// Clone this instance /// </summary> public override DrawObject Clone() { DrawPolyLine drawPolyLine = new DrawPolyLine(); drawPolyLine.startPoint = startPoint; drawPolyLine.endPoint = endPoint; drawPolyLine.pointArray = pointArray; FillDrawObjectFields(drawPolyLine); return(drawPolyLine); }