public static ConnectionLeg DrawLegToShape(
            Shape FromShape, Shape ToShape, ConnectionLeg LastLeg,
            WhichDirection Direction)
        {
            ConnectionLeg   leg     = null;
            LineCoordinates legCoor = null;

            var toShapeInfo = ToShape.DirectionToShape(LastLeg.End);

            // start point of the leg.
            var legStart = LastLeg.End;

            // attempt to draw a direct line to the shape.
            if (legCoor == null)
            {
                legCoor = ConnectionRoute.TryDrawDirectLineToShape(
                    toShapeInfo, legStart, Direction);
            }

            // drawing a vertical line. draw it to the halfway point of the vertical side
            // of the shape.
            if ((legCoor == null) &&
                Direction.IsVertical() &&
                (toShapeInfo.VertDirection.Equals(Direction)))
            {
                var toPoint = new Point(legStart.X, toShapeInfo.VertSide.MidPoint.Y);
                legCoor = new LineCoordinates(legStart, toPoint);
            }

            // drawing a horizontal line. draw it to the halfway point of the horiz side of
            // the shape.
            if ((legCoor == null) &&
                Direction.IsHorizontal() &&
                (toShapeInfo.HorizDirection.Equals(Direction)))
            {
                var toPoint = new Point(toShapeInfo.HorizSide.MidPoint.X, legStart.Y);
                legCoor = new LineCoordinates(legStart, toPoint);
            }

            // leg not drawn. The current leg is part of an orbit around a shape. Have to draw to
            // the next corner of the orbit.
            if (legCoor == null)
            {
                var rectMore = ShapeMore.Construct(FromShape);
                legCoor = rectMore.DrawLineToOrbitCorner(legStart, Direction);
            }

            leg = new ConnectionLeg()
            {
                Direction = Direction,
                LineCoor  = legCoor,
                Start     = legStart
            };

            return(leg);
        }
Beispiel #2
0
 public bool MatchesDirection(WhichDirection Direction)
 {
     if (Direction.IsVertical() && (VertDirection != null) &&
         (VertDirection.Value == Direction))
     {
         return(true);
     }
     else if (Direction.IsHorizontal( ) && (this.HorizDirection != null) &&
              (this.HorizDirection.Value == Direction))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }