private void AddNewPoint(ImageEditor imgEd, MouseEventArgs e, Polygon polyg) { int pos = Math.Max(imgEd.CurPoints[0], imgEd.CurPoints[1]); if (pos == polyg.VertexCount-1) pos++; Point E = imgEd.ShiftPointIfNotEmpty(new Point(e.X, e.Y)); Graphics g = imgEd.GetGraphics(); polyg.Paint(g, new Pen(Brushes.White, 2)); polyg.AddVertexAt(pos, E); imgEd.ReDraw(); g = imgEd.GetGraphics(); polyg.Paint(g); imgEd.ReDraw(); imgEd.CurPoints.Clear(); }
public override void MouseDown(MouseEventArgs e, ImageEditor imgEd) { Point E = imgEd.ShiftPointIfNotEmpty(new Point(e.X, e.Y)); Graphics g = imgEd.GetGraphics(); imgEd.CurPolygon.AddVertex(E); if (imgEd.CurPolygon.VertexCount > 1) g.DrawLine(new Pen(Brushes.Black, 2), E, new Point(imgEd.CurPolygon.GetVertex(imgEd.CurPolygon.VertexCount - 2).X, imgEd.CurPolygon.GetVertex(imgEd.CurPolygon.VertexCount - 2).Y)); else g.DrawRectangle(new Pen(Brushes.Black, 2), E.X, E.Y, 1, 1); imgEd.ReDraw(); }