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); }
/// <summary> /// return the direction from a point to the shape. /// </summary> /// <param name="Shape"></param> /// <param name="FromPoint"></param> /// <returns></returns> public static PointToShapeInfo DirectionToShape(this Shape Shape, Point Point) { var info = new PointToShapeInfo(Shape, Point); return info; }