private void addPoint(object sender, EventArgs e) { MenuItem mi = (MenuItem)sender; Point p = (Point)mi.Tag; ArrayToPointList(); if (_points == null || _points.Count < 2) { ResetDefaultProperties(); } else { double ds2; double ds = DrawingItem.DistanceFromPointToLine(p, _points[0].Point, _points[1].Point); int i2 = 1; int n = _points.Count - 1; for (int i = 1; i < n; i++) { int k = i + 1; if (_points[i].Point.X != _points[k].Point.X || _points[i].Point.Y != _points[k].Point.Y) { ds2 = DrawingItem.DistanceFromPointToLine(p, _points[i].Point, _points[k].Point); if (ds2 < ds) { ds = ds2; i2 = k; } } } ds2 = DrawingItem.DistanceFromPointToLine(p, _points[n].Point, _points[0].Point); if (ds2 < ds) { _points.Add(new CPoint(p)); } else { _points.Insert(i2, new CPoint(p)); } PointListToArray(); if (Page != null) { dlgDrawings designPage = Page as dlgDrawings; if (designPage != null) { designPage.SetItemSelection(this); } Page.Refresh(); } } }