/// <summary> /// Clone this instance /// </summary> public override DrawObject Clone() { DrawPolyLine drawPolyLine = new DrawPolyLine(); drawPolyLine.startPoint = this.startPoint; drawPolyLine.endPoint = this.endPoint; drawPolyLine.pointArray = this.pointArray; FillDrawObjectFields(drawPolyLine); return(drawPolyLine); }
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 (drawArea.PenType == DrawingPens.PenType.Generic) { if (_drawingInProcess == false) { newPolyLine = new DrawPolyLine(p.X, p.Y, p.X + 1, p.Y + 1, drawArea.LineColor, drawArea.LineWidth); newPolyLine.EndPoint = new Point(p.X + 1, p.Y + 1); AddNewObject(drawArea, newPolyLine); lastX = e.X; lastY = e.Y; _drawingInProcess = true; } else { // Drawing is in process, so simply add a new point newPolyLine.AddPoint(p); newPolyLine.EndPoint = p; } } else { if (_drawingInProcess == false) { newPolyLine = new DrawPolyLine(p.X, p.Y, p.X + 1, p.Y + 1, drawArea.PenType); newPolyLine.EndPoint = new Point(p.X + 1, p.Y + 1); AddNewObject(drawArea, newPolyLine); lastX = e.X; lastY = e.Y; _drawingInProcess = true; } else { // Drawing is in process, so simply add a new point newPolyLine.AddPoint(p); newPolyLine.EndPoint = p; } } } }