Exemplo n.º 1
0
    public static bool IsOppositeDirection(
      this Shape FromShape, WhichDirection Direction, Shape ToShape)
    {
      WhichSide side = Direction.ToSide();


      if (side == WhichSide.Left)
      {
        if ( FromShape
      }

      switch (side)
      {
        case WhichDirection.Down:

          break;

        case WhichDirection.Up:
          break;

        case WhichDirection.Left:
          break;

        case WhichDirection.Right:
          break;

        default:
          throw new ApplicationException("unexpected direction");
      }

      return side;
    }
Exemplo n.º 2
0
        public static LineCoordinates TryDrawDirectLineToShape(
            PointToShapeInfo ToShapeInfo, LineCoordinates FromSide, WhichDirection Direction)
        {
            LineCoordinates lineCoor = null;

#if skip
            Point?toPoint = null;
            // The vertical direction to the shape matches the requested draw direction.
            // And a straight line can be drawn from the point to the shape.
            if ((ToShapeInfo.VertDirection != null) &&
                (ToShapeInfo.VertDirection.Value == Direction) &&
                (ToShapeInfo.HorizSide.WithinHorizontalRange(FromPoint.X)))
            {
                toPoint = new Point(FromPoint.X, ToShapeInfo.HorizSide.Start.Y);
            }

            // same as above, only in the horizontal direction.
            else if ((ToShapeInfo.HorizDirection != null) &&
                     (ToShapeInfo.HorizDirection.Value == Direction) &&
                     (ToShapeInfo.VertSide.WithinVerticalRange(FromPoint.Y)))
            {
                toPoint = new Point(ToShapeInfo.VertSide.Start.X, FromPoint.Y);
            }

            // build the coordinates of the direct line.
            if (toPoint != null)
            {
                lineCoor = new LineCoordinates(FromPoint, toPoint.Value);
            }
#endif

            return(lineCoor);
        }
Exemplo n.º 3
0
    public static WhichSide? GetSide(
      this Shape FromShape, WhichDirection Direction, Shape ToShape)
    {
      WhichSide? side = null;

      switch (Direction)
      {
        case WhichDirection.Down:

          break;

        case WhichDirection.Up:
          break;

        case WhichDirection.Left:
          break;

        case WhichDirection.Right:
          break;

        default:
          throw new ApplicationException("unexpected direction");
      }

      return side;
    }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        public override LineCoordinates DrawLineToOrbitCorner(
            Point Start, WhichDirection Direction)
        {
            double          lgthToOrbit = 30;
            LineCoordinates lineCoor    = null;

            switch (Direction)
            {
            case WhichDirection.Left:
            {
                var rect       = this.BoundedRect.Value;
                var toX        = rect.Left - lgthToOrbit + 1.00;
                var orbitPoint = new Point(toX, Start.Y);
                lineCoor = new LineCoordinates(orbitPoint, Start);
                break;
            }

            case WhichDirection.Right:
            {
                var rect       = this.BoundedRect.Value;
                var toX        = rect.Right + lgthToOrbit - 1.00;
                var orbitPoint = new Point(toX, Start.Y);
                lineCoor = new LineCoordinates(orbitPoint, Start);
                break;
            }

            case WhichDirection.Up:
            {
                var rect       = this.BoundedRect.Value;
                var toY        = rect.Top - lgthToOrbit + 1.00;
                var orbitPoint = new Point(Start.X, toY);
                lineCoor = new LineCoordinates(orbitPoint, Start);
                break;
            }

            case WhichDirection.Down:
            {
                var rect       = this.BoundedRect.Value;
                var toY        = rect.Bottom + lgthToOrbit - 1.00;
                var orbitPoint = new Point(Start.X, toY);
                lineCoor = new LineCoordinates(orbitPoint, Start);
                break;
            }

            default:
                throw new ApplicationException("unhandled direction");
            }

            return(lineCoor);
        }
Exemplo n.º 6
0
 public static bool IsVertical(this WhichDirection Direction)
 {
     if (Direction == WhichDirection.Up)
     {
         return(true);
     }
     else if (Direction == WhichDirection.Down)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 7
0
 public static bool IsHorizontal(this WhichDirection Direction)
 {
     if (Direction == WhichDirection.Left)
     {
         return(true);
     }
     else if (Direction == WhichDirection.Right)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 8
0
 public static bool Equals(this Nullable <WhichDirection> Value1, WhichDirection Value2)
 {
     if (Value1 == null)
     {
         return(false);
     }
     else if (Value1.Value == Value2)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 9
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);
     }
 }
Exemplo n.º 10
0
        public static WhichSide ToSide(this WhichDirection Direction)
        {
            switch (Direction)
            {
            case WhichDirection.Down:
                return(WhichSide.Bottom);

            case WhichDirection.Up:
                return(WhichSide.Top);

            case WhichDirection.Left:
                return(WhichSide.Left);

            case WhichDirection.Right:
                return(WhichSide.Right);

            default:
                throw new ApplicationException("unexpected direction");
            }
        }
Exemplo n.º 11
0
 public virtual LineCoordinates DrawLineToOrbitCorner(
     Point Start, WhichDirection Direction)
 {
     throw new ApplicationException(
               "abstract method. should be implemented by derived class.");
 }
Exemplo n.º 12
0
 public LineVector(double Length, WhichDirection Direction)
 {
     this.Length    = Length;
     this.Direction = Direction;
 }