protected internal virtual void OnLayout(ActivityDesignerLayoutEventArgs e)
 {
     if ((this.segments.Count > 0) && ((this.segments[0] != this.Source.Location) || (this.segments[this.segments.Count - 1] != this.Target.Location)))
     {
         this.connectorModified = false;
     }
     if (!this.connectorModified && (this.ParentDesigner != null))
     {
         Point[] collection = ActivityDesignerConnectorRouter.Route(this.Source.AssociatedDesigner.Activity.Site, this.Source, this.Target, this.ExcludedRoutingRectangles);
         this.segments.Clear();
         this.segments.AddRange(collection);
     }
 }
 private void UpdateEditPoints(Point newPoint)
 {
     if (((this.editPoints.Count >= 2) && (this.editPoints[0].Type == EditPoint.EditPointTypes.ConnectionEditPoint)) && (this.editPoints[this.editPoints.Count - 1].Type == EditPoint.EditPointTypes.ConnectionEditPoint))
     {
         this.RemoveEditPoints(EditPoint.EditPointTypes.MidSegmentEditPoint);
         if (this.activeEditPoint != null)
         {
             int       index  = this.editPoints.IndexOf(this.activeEditPoint);
             EditPoint point  = (index > 0) ? this.editPoints[index - 1] : null;
             EditPoint point2 = (index < (this.editPoints.Count - 1)) ? this.editPoints[index + 1] : null;
             if ((point != null) && (point.Type == EditPoint.EditPointTypes.ConnectionEditPoint))
             {
                 Orientation orientation = (Math.Abs(DesignerGeometryHelper.SlopeOfLineSegment(point.Location, this.activeEditPoint.Location)) < 1f) ? Orientation.Horizontal : Orientation.Vertical;
                 int         num3        = Convert.ToInt32(DesignerGeometryHelper.DistanceBetweenPoints(point.Location, (point2 != null) ? point2.Location : this.activeEditPoint.Location)) / 4;
                 if (orientation == Orientation.Horizontal)
                 {
                     num3 *= (point.Location.X < this.activeEditPoint.Location.X) ? 1 : -1;
                 }
                 else
                 {
                     num3 *= (point.Location.Y < this.activeEditPoint.Location.X) ? 1 : -1;
                 }
                 index = this.editPoints.IndexOf(this.activeEditPoint);
                 Point point3 = (orientation == Orientation.Horizontal) ? new Point(point.Location.X + num3, point.Location.Y) : new Point(point.Location.X, point.Location.Y + num3);
                 point = new EditPoint(this, EditPoint.EditPointTypes.MultiSegmentEditPoint, point3);
                 this.editPoints.InsertRange(index, new EditPoint[] { new EditPoint(this, EditPoint.EditPointTypes.MultiSegmentEditPoint, point3), point });
             }
             if ((point2 != null) && (point2.Type == EditPoint.EditPointTypes.ConnectionEditPoint))
             {
                 Orientation orientation2 = (Math.Abs(DesignerGeometryHelper.SlopeOfLineSegment(this.activeEditPoint.Location, point2.Location)) < 1f) ? Orientation.Horizontal : Orientation.Vertical;
                 int         num5         = Convert.ToInt32(DesignerGeometryHelper.DistanceBetweenPoints((point != null) ? point.Location : this.activeEditPoint.Location, point2.Location)) / 4;
                 if (orientation2 == Orientation.Horizontal)
                 {
                     num5 *= (this.activeEditPoint.Location.X < point2.Location.X) ? -1 : 1;
                 }
                 else
                 {
                     num5 *= (this.activeEditPoint.Location.Y < point2.Location.Y) ? -1 : 1;
                 }
                 index = this.editPoints.IndexOf(this.activeEditPoint);
                 Point point4 = (orientation2 == Orientation.Horizontal) ? new Point(point2.Location.X + num5, point2.Location.Y) : new Point(point2.Location.X, point2.Location.Y + num5);
                 point2 = new EditPoint(this, EditPoint.EditPointTypes.MultiSegmentEditPoint, point4);
                 this.editPoints.InsertRange(index + 1, new EditPoint[] { point2, new EditPoint(this, EditPoint.EditPointTypes.MultiSegmentEditPoint, point4) });
             }
             if (this.activeEditPoint.Type == EditPoint.EditPointTypes.ConnectionEditPoint)
             {
                 this.activeEditPoint.Location = newPoint;
                 this.RemoveEditPoints(EditPoint.EditPointTypes.MultiSegmentEditPoint);
                 object source = null;
                 object target = null;
                 if (this.activeEditPoint.EditedConnectionPoint.Equals(this.Target))
                 {
                     target = newPoint;
                     source = this.Source;
                 }
                 else
                 {
                     source = newPoint;
                     target = this.Target;
                 }
                 int num6 = (this.editPoints.Count == 2) ? 1 : 0;
                 List <EditPoint> list       = new List <EditPoint>();
                 Point[]          pointArray = ActivityDesignerConnectorRouter.Route(this.serviceProvider, source, target, this.editedConnector.ExcludedRoutingRectangles);
                 for (int i = num6; i < (pointArray.Length - num6); i++)
                 {
                     list.Add(new EditPoint(this, EditPoint.EditPointTypes.MultiSegmentEditPoint, pointArray[i]));
                 }
                 this.editPoints.InsertRange(1, list.ToArray());
             }
             else if (this.activeEditPoint.Type == EditPoint.EditPointTypes.MultiSegmentEditPoint)
             {
                 if (((point != null) && (point.Type != EditPoint.EditPointTypes.ConnectionEditPoint)) && ((point2 != null) && (point2.Type != EditPoint.EditPointTypes.ConnectionEditPoint)))
                 {
                     Orientation orientation3 = (Math.Abs(DesignerGeometryHelper.SlopeOfLineSegment(point.Location, this.activeEditPoint.Location)) < 1f) ? Orientation.Horizontal : Orientation.Vertical;
                     point.Location  = (orientation3 == Orientation.Horizontal) ? new Point(point.Location.X, newPoint.Y) : new Point(newPoint.X, point.Location.Y);
                     orientation3    = (Math.Abs(DesignerGeometryHelper.SlopeOfLineSegment(this.activeEditPoint.Location, point2.Location)) < 1f) ? Orientation.Horizontal : Orientation.Vertical;
                     point2.Location = (orientation3 == Orientation.Horizontal) ? new Point(point2.Location.X, newPoint.Y) : new Point(newPoint.X, point2.Location.Y);
                     this.activeEditPoint.Location = newPoint;
                 }
             }
             else if ((((this.activeEditPoint.Type == EditPoint.EditPointTypes.MidSegmentEditPoint) && (point != null)) && ((point.Type != EditPoint.EditPointTypes.ConnectionEditPoint) && (point2 != null))) && (point2.Type != EditPoint.EditPointTypes.ConnectionEditPoint))
             {
                 if (((Math.Abs(DesignerGeometryHelper.SlopeOfLineSegment(point.Location, point2.Location)) < 1f) ? 0 : 1) == 0)
                 {
                     point.Location  = new Point(point.Location.X, newPoint.Y);
                     point2.Location = new Point(point2.Location.X, newPoint.Y);
                     this.activeEditPoint.Location = new Point(this.activeEditPoint.Location.X, newPoint.Y);
                 }
                 else
                 {
                     point.Location  = new Point(newPoint.X, point.Location.Y);
                     point2.Location = new Point(newPoint.X, point2.Location.Y);
                     this.activeEditPoint.Location = new Point(newPoint.X, this.activeEditPoint.Location.Y);
                 }
             }
         }
         this.RemoveCoincidingEditPoints();
         this.AddEditPoints(EditPoint.EditPointTypes.MidSegmentEditPoint);
         this.ValidateEditPoints();
     }
 }