Exemple #1
0
        /// <summary>
        /// Transforms the given coordinate from pixel to dip (device independent pixel).
        /// </summary>
        public static double TransformYCoordinateFromPixelToDip(
            this IDpiScalingProvider dpiScalingProvider,
            double yCoordinate)
        {
            var currentDpiScaling = dpiScalingProvider.GetCurrentDpiScaling();

            return(yCoordinate / Math.Max(currentDpiScaling.ScaleFactorY, 1f));
        }
Exemple #2
0
        /// <summary>
        /// Transforms the given coordinate from dip (device independent pixel) to pixel.
        /// </summary>
        public static double TransformYCoordinateFromDipToPixel(
            this IDpiScalingProvider dpiScalingProvider,
            double yCoordinate)
        {
            var currentDpiScaling = dpiScalingProvider.GetCurrentDpiScaling();

            return(yCoordinate * currentDpiScaling.ScaleFactorY);
        }
Exemple #3
0
 /// <summary>
 /// Transforms the given size from dip (device independent pixel) to pixel.
 /// </summary>
 public static Vector2 TransformVector2FromDipToPixel(
     this IDpiScalingProvider dpiScalingProvider,
     Vector2 vector)
 {
     return(new Vector2(
                dpiScalingProvider.TransformXCoordinateFromDipToPixel(vector.X),
                dpiScalingProvider.TransformYCoordinateFromDipToPixel(vector.Y)));
 }
Exemple #4
0
        /// <summary>
        /// Transforms the given coordinate from dip (device independent pixel) to pixel.
        /// </summary>
        public static float TransformXCoordinateFromDipToPixel(
            this IDpiScalingProvider dpiScalingProvider,
            float xCoordinate)
        {
            var currentDpiScaling = dpiScalingProvider.GetCurrentDpiScaling();

            return(xCoordinate * currentDpiScaling.ScaleFactorX);
        }
Exemple #5
0
 /// <summary>
 /// Transforms the given size from dip (device independent pixel) to pixel.
 /// </summary>
 public static SizeF TransformSizeFromDipToPixel(
     this IDpiScalingProvider dpiScalingProvider,
     SizeF size)
 {
     return(new SizeF(
                dpiScalingProvider.TransformXCoordinateFromDipToPixel(size.Width),
                dpiScalingProvider.TransformYCoordinateFromDipToPixel(size.Height)));
 }
Exemple #6
0
 /// <summary>
 /// Transforms the given size from pixel to dip (device independent pixel).
 /// </summary>
 public static Size TransformSizeFromPixelToDip(
     this IDpiScalingProvider dpiScalingProvider,
     Size size)
 {
     return(new Size(
                (int)dpiScalingProvider.TransformXCoordinateFromPixelToDip(size.Width),
                (int)dpiScalingProvider.TransformYCoordinateFromPixelToDip(size.Height)));
 }
Exemple #7
0
 /// <summary>
 /// Transforms the given point from dip (device independent pixel) to pixel.
 /// </summary>
 public static PointF TransformPointFromDipToPixel(
     this IDpiScalingProvider dpiScalingProvider,
     PointF point)
 {
     return(new PointF(
                dpiScalingProvider.TransformXCoordinateFromDipToPixel(point.X),
                dpiScalingProvider.TransformYCoordinateFromDipToPixel(point.Y)));
 }
Exemple #8
0
        /// <summary>
        /// Transforms the given coordinate from pixel to dip (device independent pixel).
        /// </summary>
        public static float TransformXCoordinateFromPixelToDip(
            this IDpiScalingProvider dpiScalingProvider,
            float xCoordinate)
        {
            var currentDpiScaling = dpiScalingProvider.GetCurrentDpiScaling();

            return(xCoordinate / Math.Max(currentDpiScaling.ScaleFactorX, 1f));
        }
Exemple #9
0
 /// <summary>
 /// Transforms the given point from pixel to dip (device independent pixel).
 /// </summary>
 public static Point TransformPointFromPixelToDip(
     this IDpiScalingProvider dpiScalingProvider,
     Point point)
 {
     return(new Point(
                (int)dpiScalingProvider.TransformXCoordinateFromPixelToDip(point.X),
                (int)dpiScalingProvider.TransformYCoordinateFromPixelToDip(point.Y)));
 }