private void AddEditPoints(EditPoint.EditPointTypes editPointType)
 {
     if (editPointType == EditPoint.EditPointTypes.ConnectionEditPoint)
     {
         if ((this.editPoints.Count == 0) || !this.editPoints[0].EditedConnectionPoint.Equals(this.Source))
         {
             this.editPoints.Insert(0, new EditPoint(this, this.Source));
         }
         if ((this.editPoints.Count < 2) || !this.editPoints[this.editPoints.Count - 1].EditedConnectionPoint.Equals(this.Target))
         {
             this.editPoints.Add(new EditPoint(this, this.Target));
         }
     }
     else if (editPointType == EditPoint.EditPointTypes.MidSegmentEditPoint)
     {
         int num = this.Source.Bounds.Width * 4;
         for (int i = 0; i < (this.editPoints.Count - 1); i++)
         {
             if ((this.editPoints[i].Type != EditPoint.EditPointTypes.MidSegmentEditPoint) && (this.editPoints[i + 1].Type != EditPoint.EditPointTypes.MidSegmentEditPoint))
             {
                 Point[] segments = new Point[] { this.editPoints[i].Location, this.editPoints[i + 1].Location };
                 if (DesignerGeometryHelper.DistanceOfLineSegments(segments) > num)
                 {
                     Point point = DesignerGeometryHelper.MidPointOfLineSegment(this.editPoints[i].Location, this.editPoints[i + 1].Location);
                     this.editPoints.Insert(i + 1, new EditPoint(this, EditPoint.EditPointTypes.MidSegmentEditPoint, point));
                 }
             }
         }
     }
     else if ((editPointType == EditPoint.EditPointTypes.MultiSegmentEditPoint) && (this.editPoints.Count == 2))
     {
         List <Point> list = new List <Point>(this.editedConnector.ConnectorSegments);
         if ((list.Count > 0) && (list[0] == this.Source.Location))
         {
             list.RemoveAt(0);
         }
         if ((list.Count > 0) && (list[list.Count - 1] == this.Target.Location))
         {
             list.RemoveAt(list.Count - 1);
         }
         List <EditPoint> list2 = new List <EditPoint>();
         for (int j = 0; j < list.Count; j++)
         {
             list2.Add(new EditPoint(this, EditPoint.EditPointTypes.MultiSegmentEditPoint, list[j]));
         }
         this.editPoints.InsertRange(this.editPoints.Count - 1, list2.ToArray());
     }
 }
 private void RemoveCoincidingEditPoints()
 {
     if (((this.editPoints.Count >= 2) && (this.editPoints[0].Type == EditPoint.EditPointTypes.ConnectionEditPoint)) && ((this.editPoints[this.editPoints.Count - 1].Type == EditPoint.EditPointTypes.ConnectionEditPoint) && ((this.activeEditPoint == null) || (this.activeEditPoint.Type != EditPoint.EditPointTypes.ConnectionEditPoint))))
     {
         this.RemoveEditPoints(EditPoint.EditPointTypes.MidSegmentEditPoint);
         List <EditPoint> list = new List <EditPoint>();
         for (int i = 0; i < this.editPoints.Count; i++)
         {
             if ((((this.editPoints[i].Type != EditPoint.EditPointTypes.MultiSegmentEditPoint) || (this.editPoints[i] == this.activeEditPoint)) || ((i > 0) && (this.editPoints[i - 1].Type == EditPoint.EditPointTypes.MidSegmentEditPoint))) || ((i < (this.editPoints.Count - 1)) && (this.editPoints[i + 1].Type == EditPoint.EditPointTypes.MidSegmentEditPoint)))
             {
                 list.Add(this.editPoints[i]);
             }
         }
         for (int j = 1; j < (this.editPoints.Count - 1); j++)
         {
             EditPoint point  = this.editPoints[j - 1];
             EditPoint item   = this.editPoints[j];
             EditPoint point3 = this.editPoints[j + 1];
             if (!list.Contains(item))
             {
                 Point[] segments = new Point[] { point.Location, item.Location };
                 double  num3     = DesignerGeometryHelper.DistanceOfLineSegments(segments);
                 if (((num3 < item.Bounds.Width) || (num3 < item.Bounds.Height)) && (point3.Type == EditPoint.EditPointTypes.MultiSegmentEditPoint))
                 {
                     float num4 = DesignerGeometryHelper.SlopeOfLineSegment(item.Location, point3.Location);
                     point3.Location = (num4 < 1f) ? new Point(point3.Location.X, point.Location.Y) : new Point(point.Location.X, point3.Location.Y);
                     this.editPoints.Remove(item);
                     j--;
                 }
                 else
                 {
                     Point[] pointArray2 = new Point[] { item.Location, point3.Location };
                     num3 = DesignerGeometryHelper.DistanceOfLineSegments(pointArray2);
                     if (((num3 < item.Bounds.Width) || (num3 < item.Bounds.Height)) && (point.Type == EditPoint.EditPointTypes.MultiSegmentEditPoint))
                     {
                         float num5 = DesignerGeometryHelper.SlopeOfLineSegment(point.Location, item.Location);
                         point.Location = (num5 < 1f) ? new Point(point.Location.X, point3.Location.Y) : new Point(point3.Location.X, point.Location.Y);
                         this.editPoints.Remove(item);
                         j--;
                     }
                 }
             }
         }
         for (int k = 1; k < (this.editPoints.Count - 1); k++)
         {
             EditPoint point4 = this.editPoints[k];
             EditPoint point5 = this.editPoints[k - 1];
             EditPoint point6 = this.editPoints[k + 1];
             if (!list.Contains(point4))
             {
                 float num7 = DesignerGeometryHelper.SlopeOfLineSegment(point5.Location, point4.Location);
                 float num8 = DesignerGeometryHelper.SlopeOfLineSegment(point4.Location, point6.Location);
                 if (Math.Abs(num7) == Math.Abs(num8))
                 {
                     this.editPoints.Remove(point4);
                     k--;
                 }
             }
         }
         for (int m = 0; m < (this.editPoints.Count - 1); m++)
         {
             EditPoint point7 = this.editPoints[m];
             EditPoint point8 = this.editPoints[m + 1];
             float     num10  = DesignerGeometryHelper.SlopeOfLineSegment(point7.Location, point8.Location);
             if ((num10 != 0f) && (num10 != float.MaxValue))
             {
                 Point point9 = (num10 < 1f) ? new Point(point8.Location.X, point7.Location.Y) : new Point(point7.Location.X, point8.Location.Y);
                 this.editPoints.Insert(m + 1, new EditPoint(this, EditPoint.EditPointTypes.MultiSegmentEditPoint, point9));
             }
         }
     }
 }