Exemple #1
0
        /// <summary>
        /// Converts the given RectangleF from one unit of measure to another.
        /// </summary>
        /// <param name="fromUnits">Units to convert from</param>
        /// <param name="toUnits">Units to convert to</param>
        /// <param name="grfx">Graphics context object for converting device units</param>
        /// <param name="value">RectangleF to convert</param>
        /// <returns>Converted value</returns>
        public static System.Drawing.RectangleF Convert(GraphicsUnit fromUnits, GraphicsUnit toUnits, Graphics grfx, System.Drawing.RectangleF value)
        {
            float dpiX = Measurements.screenDpiX;
            float dpiY = Measurements.screenDpiY;

            if (grfx != null)
            {
                dpiX = grfx.DpiX;
                dpiY = grfx.DpiY;
            }
            float x      = Measurements.Convert(fromUnits, toUnits, dpiX, value.X);
            float y      = Measurements.Convert(fromUnits, toUnits, dpiY, value.Y);
            float width  = Measurements.Convert(fromUnits, toUnits, dpiX, value.Width);
            float height = Measurements.Convert(fromUnits, toUnits, dpiY, value.Height);

            return(new System.Drawing.RectangleF(x, y, width, height));
        }
Exemple #2
0
 /// <summary>
 /// Converts the given value from one unit of measure to another.
 /// </summary>
 /// <param name="fromUnits">Units to convert from</param>
 /// <param name="toUnits">Units to convert to</param>
 /// <param name="value">Value to convert</param>
 /// <returns>Converted value</returns>
 public static float Convert(GraphicsUnit fromUnits, GraphicsUnit toUnits, float value)
 {
     return(Measurements.Convert(fromUnits, toUnits, Measurements.screenDpiX, value));
 }