示例#1
0
        /// <summary>
        /// Converts the logical values contained by the object 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>
        /// <remarks>
        /// <para>
        /// This method converts all logical unit values contained by the object from
        /// one unit of measure to another.
        /// </para>
        /// </remarks>
        void ILogicalUnitContainer.ConvertLogicalUnits(GraphicsUnit fromUnits, GraphicsUnit toUnits, Graphics grfx)
        {
            // Convert line width
            if (this.propertyValues.Contains("LineWidth"))
            {
                float lineWidth = (float)this.propertyValues["LineWidth"];
                lineWidth = Measurements.Convert(fromUnits, toUnits, grfx, lineWidth);
                this.propertyValues["LineWidth"] = lineWidth;
            }

            // Convert the gradient bounds
            if (this.propertyValues.Contains("GradientBounds"))
            {
                System.Drawing.RectangleF gradientBounds = (System.Drawing.RectangleF) this.propertyValues["GradientBounds"];
                gradientBounds = Measurements.Convert(fromUnits, toUnits, grfx, gradientBounds);
                this.propertyValues["GradientBounds"] = gradientBounds;
            }

            // Convert points
            System.Drawing.PointF[] pts = this.GetPoints();
            for (int ptIdx = 0; ptIdx < pts.Length; ptIdx++)
            {
                pts[ptIdx] = Measurements.Convert(fromUnits, toUnits, grfx, pts[ptIdx]);
            }
            this.SetPoints(pts);
        }
示例#2
0
        /// <summary>
        /// Converts the given SizeF 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">SizeF to convert</param>
        /// <returns>Converted value</returns>
        public static System.Drawing.SizeF Convert(GraphicsUnit fromUnits, GraphicsUnit toUnits, System.Drawing.SizeF value)
        {
            float dpiX   = Measurements.screenDpiX;
            float dpiY   = Measurements.screenDpiY;
            float width  = Measurements.Convert(fromUnits, toUnits, dpiX, value.Width);
            float height = Measurements.Convert(fromUnits, toUnits, dpiY, value.Height);

            return(new System.Drawing.SizeF(width, height));
        }
示例#3
0
        /// <summary>
        /// Converts the given PointF 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">PointF to convert</param>
        /// <returns>Converted value</returns>
        public static System.Drawing.PointF Convert(GraphicsUnit fromUnits, GraphicsUnit toUnits, System.Drawing.PointF value)
        {
            float dpiX = Measurements.screenDpiX;
            float dpiY = Measurements.screenDpiY;
            float x    = Measurements.Convert(fromUnits, toUnits, dpiX, value.X);
            float y    = Measurements.Convert(fromUnits, toUnits, dpiY, value.Y);

            return(new System.Drawing.PointF(x, y));
        }
示例#4
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="grfx">Graphics context object for converting device units</param>
        /// <param name="value">Value to convert</param>
        /// <returns>Converted value</returns>
        public static float Convert(GraphicsUnit fromUnits, GraphicsUnit toUnits, Graphics grfx, float value)
        {
            float dpi = Measurements.screenDpiX;

            if (grfx != null)
            {
                dpi = grfx.DpiX;
            }
            return(Measurements.Convert(fromUnits, toUnits, dpi, value));
        }
示例#5
0
        /// <summary>
        /// Converts the logical values contained by the object 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>
        /// <remarks>
        /// <para>
        /// This method converts all logical unit values contained by the object from
        /// one unit of measure to another.
        /// </para>
        /// </remarks>
        void ILogicalUnitContainer.ConvertLogicalUnits(GraphicsUnit fromUnits, GraphicsUnit toUnits, Graphics grfx)
        {
            // Convert line width
            if (this.propertyValues.Contains("LineWidth"))
            {
                float lineWidth = (float)this.propertyValues["LineWidth"];
                lineWidth = Measurements.Convert(fromUnits, toUnits, grfx, lineWidth);
                this.propertyValues["LineWidth"] = lineWidth;
            }

            this.bounds = Measurements.Convert(fromUnits, toUnits, grfx, this.bounds);
        }
示例#6
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));
        }
示例#7
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));
 }