Class UnitsConvertor
Class allow to convert differ metrics units. Convert is based on Graphics object DPI settings that is why for differ graphics settings must be created new instance. For example: printers often has 300 and greater dpi resolution, for compare default display screen dpi is 96.
Inheritance
Inherited Members
Namespace: Syncfusion.Layouting
Assembly: Syncfusion.DLS.Base.dll
Syntax
public class UnitsConvertor
Constructors
UnitsConvertor()
Prevent class creation
Declaration
public UnitsConvertor()
UnitsConvertor(Graphics)
Create Units convert class based on specified Graphics units
Declaration
public UnitsConvertor(Graphics g)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Graphics | g | Graphics for measuring |
Properties
EmptyGraphics
Get Empty graphics created on Bitmap
Declaration
public static Graphics EmptyGraphics { get; }
Property Value
Type |
---|
System.Drawing.Graphics |
Methods
ConvertFromPixels(Double, PrintUnits)
Converts value, stored in pixels, to value in "to" units
Declaration
public double ConvertFromPixels(double value, PrintUnits to)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value | Value to convert |
PrintUnits | to | Indicates units to convert to |
Returns
Type | Description |
---|---|
System.Double | Value stored in "to" units |
ConvertFromPixels(PointF, PrintUnits)
Convert rectangle from pixels to specified units
Declaration
public PointF ConvertFromPixels(PointF point, PrintUnits to)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.PointF | point | point in pixels units |
PrintUnits | to | convert to units |
Returns
Type | Description |
---|---|
System.Drawing.PointF | output Point in specified units |
ConvertFromPixels(RectangleF, PrintUnits)
Convert rectangle in Pixels into rectangle with specified measure units
Declaration
public RectangleF ConvertFromPixels(RectangleF rect, PrintUnits to)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.RectangleF | rect | source rectangle in pixels units |
PrintUnits | to | convert to units |
Returns
Type | Description |
---|---|
System.Drawing.RectangleF | output Rectangle in specified units |
ConvertFromPixels(SizeF, PrintUnits)
Convert Size in pixels to size in specified measure units
Declaration
public SizeF ConvertFromPixels(SizeF size, PrintUnits to)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.SizeF | size | source size |
PrintUnits | to | convert to units |
Returns
Type | Description |
---|---|
System.Drawing.SizeF | output size in specified measure units |
ConvertFromPixels(Single, PrintUnits)
Converts value, stored in pixels, to value in "to" units
Declaration
public float ConvertFromPixels(float value, PrintUnits to)
Parameters
Type | Name | Description |
---|---|---|
System.Single | value | Value to convert |
PrintUnits | to | Indicates units to convert to |
Returns
Type | Description |
---|---|
System.Single | Value stored in "to" units |
ConvertToPixels(Double, PrintUnits)
Converts value, stored in "from" units, to pixels
Declaration
public double ConvertToPixels(double value, PrintUnits from)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value | Value to convert |
PrintUnits | from | Indicates units to convert from |
Returns
Type | Description |
---|---|
System.Double | Value stored in pixels |
ConvertToPixels(PointF, PrintUnits)
Convert point from specified measure units to pixels
Declaration
public PointF ConvertToPixels(PointF point, PrintUnits from)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.PointF | point | source point for convert |
PrintUnits | from | measure units |
Returns
Type | Description |
---|---|
System.Drawing.PointF | point in pixels coordinates |
ConvertToPixels(RectangleF, PrintUnits)
Convert rectangle location and size to Pixels from specified measure units
Declaration
public RectangleF ConvertToPixels(RectangleF rect, PrintUnits from)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.RectangleF | rect | source rectangle |
PrintUnits | from | source rectangle measure units |
Returns
Type | Description |
---|---|
System.Drawing.RectangleF | Rectangle with Pixels |
ConvertToPixels(SizeF, PrintUnits)
Convert size from specified measure units to pixels
Declaration
public SizeF ConvertToPixels(SizeF size, PrintUnits from)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.SizeF | size | source size |
PrintUnits | from | measure units |
Returns
Type | Description |
---|---|
System.Drawing.SizeF | size in pixels |
ConvertToPixels(Single, PrintUnits)
Converts value, stored in "from" units, to pixels
Declaration
public float ConvertToPixels(float value, PrintUnits from)
Parameters
Type | Name | Description |
---|---|---|
System.Single | value | Value to convert |
PrintUnits | from | Indicates units to convert from |
Returns
Type | Description |
---|---|
System.Single | Value stored in pixels |
ConvertUnits(Double, PrintUnits, PrintUnits)
Converts value, stored in "from" units, to value in "to" units
Declaration
public double ConvertUnits(double value, PrintUnits from, PrintUnits to)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value | Value to convert |
PrintUnits | from | Indicates units to convert from |
PrintUnits | to | Indicates units to convert to |
Returns
Type | Description |
---|---|
System.Double | Value stored in "to" units |