예제 #1
0
        /// <summary>
        /// Transforms rectangle from data coordinates to viewport coordinates.
        /// </summary>
        /// <param name="dataRect">Rectangle in data coordinates</param>
        /// <param name="transform">CoordinateTransform used to perform transformation</param>
        /// <returns>Rectangle in viewport coordinates</returns>
        public static Rect DataToViewport(this Rect dataRect, DataTransform transform)
        {
            Point p1 = transform.DataToViewport(dataRect.BottomLeft);
            Point p2 = transform.DataToViewport(dataRect.TopRight);

            return(new Rect(p1, p2));
        }
예제 #2
0
        /// <summary>
        /// Transforms rectangle from viewport coordinates to data coordinates.
        /// </summary>
        /// <param name="viewportRect">Rectangle in viewport coordinates</param>
        /// <param name="transform">CoordinateTransform used to perform transformation</param>
        /// <returns>Rectangle in data coordinates</returns>
        public static Rect ViewportToData(this Rect viewportRect, DataTransform transform)
        {
            Point p1 = transform.ViewportToData(viewportRect.BottomLeft);
            Point p2 = transform.ViewportToData(viewportRect.TopRight);

            return(new Rect(p1, p2));
        }
예제 #3
0
        /// <summary>
        /// Creates a new instance of CoordinateTransform with the given data transform.
        /// </summary>
        /// <param name="dataTransform">The data transform.</param>
        /// <returns></returns>
        public CoordinateTransform WithDataTransform(DataTransform dataTransform)
        {
            if (dataTransform == null)
            {
                throw new ArgumentNullException("dataTransform");
            }

            CoordinateTransform copy = new CoordinateTransform(visibleRect, screenRect);

            copy.dataTransform = dataTransform;
            return(copy);
        }
예제 #4
0
 /// <summary>
 /// Transforms point in data coordinates to viewport coordinates.
 /// </summary>
 /// <param name="dataPoint">Point in data coordinates</param>
 /// <param name="transform">CoordinateTransform used to perform transformation</param>
 /// <returns>Point in viewport coordinates</returns>
 public static Point DataToViewport(this Point dataPoint, DataTransform transform)
 {
     return(transform.DataToViewport(dataPoint));
 }
예제 #5
0
 /// <summary>
 /// Transforms list of points from data coordinates to viewport coordinates.
 /// </summary>
 /// <param name="dataPoints">Points in data coordinates</param>
 /// <param name="transform">Data transform used to perform transformation</param>
 /// <returns>List of points in viewport coordinates</returns>
 public static IEnumerable <Point> DataToViewport(this IEnumerable <Point> dataPoints, DataTransform transform)
 {
     foreach (Point pt in dataPoints)
     {
         yield return(pt.DataToViewport(transform));
     }
 }
예제 #6
0
 public static Rect GetViewportBounds(IEnumerable <Point> dataPoints, DataTransform transform)
 {
     return(GetDataBounds(dataPoints.DataToViewport(transform)));
 }