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 RemoveEditPoints(EditPoint.EditPointTypes editPointType)
        {
            List <EditPoint> list = new List <EditPoint>();

            for (int i = 0; i < this.editPoints.Count; i++)
            {
                EditPoint item = this.editPoints[i];
                if (item.Type == editPointType)
                {
                    list.Add(item);
                }
            }
            for (int j = 0; j < list.Count; j++)
            {
                EditPoint point2 = list[j];
                if (point2 != this.activeEditPoint)
                {
                    this.editPoints.Remove(point2);
                }
            }
        }
Example #3
0
        //Remove edit points of specified type
        //This method does not remove this.activeEditPoint.
        void RemoveEditPoints(EditPoint.EditPointTypes editPointType)
        {
            List <EditPoint> editPointsToRemove = new List <EditPoint>();

            for (int i = 0; i < this.editPoints.Count; i++)
            {
                EditPoint editPoint = this.editPoints[i];
                if (editPoint.Type == editPointType)
                {
                    editPointsToRemove.Add(editPoint);
                }
            }

            for (int i = 0; i < editPointsToRemove.Count; i++)
            {
                EditPoint editPoint = editPointsToRemove[i];
                if (editPoint != this.activeEditPoint)
                {
                    this.editPoints.Remove(editPoint);
                }
            }
        }
Example #4
0
        //Add edit points of specified type
        void AddEditPoints(EditPoint.EditPointTypes editPointType)
        {
            if (editPointType == EditPoint.EditPointTypes.ConnectionEditPoint)
            {
                if (this.editPoints.Count == 0 || !this.editPoints[0].Location.Equals(editedConnector.Points[0]))
                {
                    this.editPoints.Insert(0, new EditPoint(EditPoint.EditPointTypes.ConnectionEditPoint, editedConnector.Points[0]));
                }

                if (this.editPoints.Count < 2 || !this.editPoints[this.editPoints.Count - 1].Equals(editedConnector.Points[editedConnector.Points.Count - 1]))
                {
                    editPoints.Add(new EditPoint(EditPoint.EditPointTypes.ConnectionEditPoint, editedConnector.Points[editedConnector.Points.Count - 1]));
                }
            }
            else if (editPointType == EditPoint.EditPointTypes.MultiSegmentEditPoint)
            {
                if (this.editPoints.Count == 2)
                {
                    List <Point> segments = new List <Point>(this.editedConnector.Points);
                    if (segments.Count > 0)
                    {
                        segments.RemoveAt(0);
                        segments.RemoveAt(segments.Count - 1);
                    }

                    for (int i = 0; i < segments.Count; i++)
                    {
                        this.editPoints.Insert(this.editPoints.Count - 1, new EditPoint(EditPoint.EditPointTypes.MultiSegmentEditPoint, segments[i]));
                    }
                }
                else
                {
                    Debug.Assert(false, "EditPoints.Count is not 2.");
                }
            }
        }