Class UnitConverter
Represents the unit converter class used by the spreadsheet model.
Inherited Members
Namespace: DRIT.Spreadsheet
Assembly: DRIT.Spreadsheet.dll
Syntax
public static class UnitConverter
Fields
CentimeterPerInch
Exposes the double associated with UnitConverter.
Declaration
public const double CentimeterPerInch = 2.54
Field Value
| Type | Description |
|---|---|
| double | The double returned by the operation. |
DefaultDpi
Exposes the int associated with UnitConverter.
Declaration
public const int DefaultDpi = 96
Field Value
| Type | Description |
|---|---|
| int | The int returned by the operation. |
MillimeterPerCentimeter
Exposes the double associated with UnitConverter.
Declaration
public const double MillimeterPerCentimeter = 10
Field Value
| Type | Description |
|---|---|
| double | The double returned by the operation. |
OpenXmlAngleConversionFactor
Exposes the double associated with UnitConverter.
Declaration
public const double OpenXmlAngleConversionFactor = 60000
Field Value
| Type | Description |
|---|---|
| double | The double returned by the operation. |
PointPerPica
Exposes the double associated with UnitConverter.
Declaration
public const double PointPerPica = 12
Field Value
| Type | Description |
|---|---|
| double | The double returned by the operation. |
Methods
CanConvert(ScreenMeasurementUnit, ScreenMeasurementUnit)
Indicates whether the can convert condition is true for UnitConverter.
Declaration
public static bool CanConvert(ScreenMeasurementUnit from, ScreenMeasurementUnit to)
Parameters
| Type | Name | Description |
|---|---|---|
| ScreenMeasurementUnit | from | The from used by the operation. |
| ScreenMeasurementUnit | to | The to used by the operation. |
Returns
| Type | Description |
|---|---|
| bool | The can convert returned by the operation. |
Convert(ScreenMeasurementUnit, ScreenMeasurementUnit, double)
Converts the supplied data for use with UnitConverter.
Declaration
public static double Convert(ScreenMeasurementUnit from, ScreenMeasurementUnit to, double value)
Parameters
| Type | Name | Description |
|---|---|---|
| ScreenMeasurementUnit | from | The from used by the operation. |
| ScreenMeasurementUnit | to | The to used by the operation. |
| double | value | The value used by the operation. |
Returns
| Type | Description |
|---|---|
| double | The convert returned by the operation. |
Convert(ScreenMeasurementUnit, ScreenMeasurementUnit, double, UnitConversionOptions)
Converts the supplied data for use with UnitConverter.
Declaration
public static double Convert(ScreenMeasurementUnit from, ScreenMeasurementUnit to, double value, UnitConversionOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| ScreenMeasurementUnit | from | The from used by the operation. |
| ScreenMeasurementUnit | to | The to used by the operation. |
| double | value | The value used by the operation. |
| UnitConversionOptions | options | The options used by the operation. |
Returns
| Type | Description |
|---|---|
| double | The convert returned by the operation. |
Convert(ScreenMeasurementUnit, ScreenMeasurementUnit, double, int)
Converts the supplied data for use with UnitConverter.
Declaration
public static double Convert(ScreenMeasurementUnit from, ScreenMeasurementUnit to, double value, int dpi)
Parameters
| Type | Name | Description |
|---|---|---|
| ScreenMeasurementUnit | from | The from used by the operation. |
| ScreenMeasurementUnit | to | The to used by the operation. |
| double | value | The value used by the operation. |
| int | dpi | The dpi used by the operation. |
Returns
| Type | Description |
|---|---|
| double | The convert returned by the operation. |
FromHiMetricToPoint(double)
Converts the supplied data for use with UnitConverter.
Declaration
public static double FromHiMetricToPoint(double himetricValue)
Parameters
| Type | Name | Description |
|---|---|---|
| double | himetricValue | The himetric value used by the operation. |
Returns
| Type | Description |
|---|---|
| double | The from hi metric to point returned by the operation. |
GetPointSizeWithWholePixels(double)
Retrieves the requested point size with whole pixels from UnitConverter.
Declaration
public static double GetPointSizeWithWholePixels(double value)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The value used by the operation. |
Returns
| Type | Description |
|---|---|
| double | The get point size with whole pixels returned by the operation. |
ToEmuFromInches(double)
Converts the supplied data for use with UnitConverter.
Declaration
public static long ToEmuFromInches(double value)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The value used by the operation. |
Returns
| Type | Description |
|---|---|
| long | The to emu from inches returned by the operation. |
ToEmuFromPixel(double)
Converts the supplied data for use with UnitConverter.
Declaration
public static long ToEmuFromPixel(double value)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The value used by the operation. |
Returns
| Type | Description |
|---|---|
| long | The to emu from pixel returned by the operation. |
ToEmuFromPixel(double, UnitConversionOptions)
Converts the supplied data for use with UnitConverter.
Declaration
public static long ToEmuFromPixel(double value, UnitConversionOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The value used by the operation. |
| UnitConversionOptions | options | The options used by the operation. |
Returns
| Type | Description |
|---|---|
| long | The to emu from pixel returned by the operation. |
ToEmuFromPixel(double, int)
Converts the supplied data for use with UnitConverter.
Declaration
public static long ToEmuFromPixel(double value, int dpi)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The value used by the operation. |
| int | dpi | The dpi used by the operation. |
Returns
| Type | Description |
|---|---|
| long | The to emu from pixel returned by the operation. |
ToEmuFromPixel(double?)
Converts the supplied data for use with UnitConverter.
Declaration
public static long? ToEmuFromPixel(double? value)
Parameters
| Type | Name | Description |
|---|---|---|
| double? | value | The value used by the operation. |
Returns
| Type | Description |
|---|---|
| long? | The to emu from pixel returned by the operation. |
ToEmuFromPixel(double?, UnitConversionOptions)
Converts the supplied data for use with UnitConverter.
Declaration
public static long? ToEmuFromPixel(double? value, UnitConversionOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| double? | value | The value used by the operation. |
| UnitConversionOptions | options | The options used by the operation. |
Returns
| Type | Description |
|---|---|
| long? | The to emu from pixel returned by the operation. |
ToEmuFromPixel(double?, int)
Converts the supplied data for use with UnitConverter.
Declaration
public static long? ToEmuFromPixel(double? value, int dpi)
Parameters
| Type | Name | Description |
|---|---|---|
| double? | value | The value used by the operation. |
| int | dpi | The dpi used by the operation. |
Returns
| Type | Description |
|---|---|
| long? | The to emu from pixel returned by the operation. |
ToEmuFromPoint(double)
Converts the supplied data for use with UnitConverter.
Declaration
public static long ToEmuFromPoint(double value)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The value used by the operation. |
Returns
| Type | Description |
|---|---|
| long | The to emu from point returned by the operation. |
ToInchesFromEmu(long)
Converts the supplied data for use with UnitConverter.
Declaration
public static double ToInchesFromEmu(long value)
Parameters
| Type | Name | Description |
|---|---|---|
| long | value | The value used by the operation. |
Returns
| Type | Description |
|---|---|
| double | The to inches from emu returned by the operation. |
ToPixelFromEmu(double)
Converts the supplied data for use with UnitConverter.
Declaration
public static double ToPixelFromEmu(double value)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The value used by the operation. |
Returns
| Type | Description |
|---|---|
| double | The to pixel from emu returned by the operation. |
ToPixelFromEmu(double, UnitConversionOptions)
Converts the supplied data for use with UnitConverter.
Declaration
public static double ToPixelFromEmu(double value, UnitConversionOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The value used by the operation. |
| UnitConversionOptions | options | The options used by the operation. |
Returns
| Type | Description |
|---|---|
| double | The to pixel from emu returned by the operation. |
ToPixelFromEmu(double, int)
Converts the supplied data for use with UnitConverter.
Declaration
public static double ToPixelFromEmu(double value, int dpi)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The value used by the operation. |
| int | dpi | The dpi used by the operation. |
Returns
| Type | Description |
|---|---|
| double | The to pixel from emu returned by the operation. |
ToPixelFromEmu(long)
Converts the supplied data for use with UnitConverter.
Declaration
public static double ToPixelFromEmu(long value)
Parameters
| Type | Name | Description |
|---|---|---|
| long | value | The value used by the operation. |
Returns
| Type | Description |
|---|---|
| double | The to pixel from emu returned by the operation. |
ToPixelFromEmu(long, UnitConversionOptions)
Converts the supplied data for use with UnitConverter.
Declaration
public static double ToPixelFromEmu(long value, UnitConversionOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| long | value | The value used by the operation. |
| UnitConversionOptions | options | The options used by the operation. |
Returns
| Type | Description |
|---|---|
| double | The to pixel from emu returned by the operation. |
ToPixelFromEmu(long, int)
Converts the supplied data for use with UnitConverter.
Declaration
public static double ToPixelFromEmu(long value, int dpi)
Parameters
| Type | Name | Description |
|---|---|---|
| long | value | The value used by the operation. |
| int | dpi | The dpi used by the operation. |
Returns
| Type | Description |
|---|---|
| double | The to pixel from emu returned by the operation. |
ToPixelFromEmu(long?)
Converts the supplied data for use with UnitConverter.
Declaration
public static double? ToPixelFromEmu(long? value)
Parameters
| Type | Name | Description |
|---|---|---|
| long? | value | The value used by the operation. |
Returns
| Type | Description |
|---|---|
| double? | The to pixel from emu returned by the operation. |
ToPixelFromEmu(long?, UnitConversionOptions)
Converts the supplied data for use with UnitConverter.
Declaration
public static double? ToPixelFromEmu(long? value, UnitConversionOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| long? | value | The value used by the operation. |
| UnitConversionOptions | options | The options used by the operation. |
Returns
| Type | Description |
|---|---|
| double? | The to pixel from emu returned by the operation. |
ToPixelFromEmu(long?, int)
Converts the supplied data for use with UnitConverter.
Declaration
public static double? ToPixelFromEmu(long? value, int dpi)
Parameters
| Type | Name | Description |
|---|---|---|
| long? | value | The value used by the operation. |
| int | dpi | The dpi used by the operation. |
Returns
| Type | Description |
|---|---|
| double? | The to pixel from emu returned by the operation. |
ToPixelFromPoint(double)
Converts the supplied data for use with UnitConverter.
Declaration
public static double ToPixelFromPoint(double value)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The value used by the operation. |
Returns
| Type | Description |
|---|---|
| double | The to pixel from point returned by the operation. |
ToPixelFromPoint(double, UnitConversionOptions)
Converts the supplied data for use with UnitConverter.
Declaration
public static double ToPixelFromPoint(double value, UnitConversionOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The value used by the operation. |
| UnitConversionOptions | options | The options used by the operation. |
Returns
| Type | Description |
|---|---|
| double | The to pixel from point returned by the operation. |
ToPixelFromPoint(double, int)
Converts the supplied data for use with UnitConverter.
Declaration
public static double ToPixelFromPoint(double value, int dpi)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The value used by the operation. |
| int | dpi | The dpi used by the operation. |
Returns
| Type | Description |
|---|---|
| double | The to pixel from point returned by the operation. |
ToPixelsFromTwips(int)
Converts the supplied data for use with UnitConverter.
Declaration
public static double ToPixelsFromTwips(int twips)
Parameters
| Type | Name | Description |
|---|---|---|
| int | twips | The twips used by the operation. |
Returns
| Type | Description |
|---|---|
| double | The to pixels from twips returned by the operation. |
ToPointFromEmu(double)
Converts the supplied data for use with UnitConverter.
Declaration
public static double ToPointFromEmu(double value)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The value used by the operation. |
Returns
| Type | Description |
|---|---|
| double | The to point from emu returned by the operation. |
ToPointFromEmu(long)
Converts the supplied data for use with UnitConverter.
Declaration
public static double ToPointFromEmu(long value)
Parameters
| Type | Name | Description |
|---|---|---|
| long | value | The value used by the operation. |
Returns
| Type | Description |
|---|---|
| double | The to point from emu returned by the operation. |
ToPointFromPixel(double)
Converts the supplied data for use with UnitConverter.
Declaration
public static double ToPointFromPixel(double value)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The value used by the operation. |
Returns
| Type | Description |
|---|---|
| double | The to point from pixel returned by the operation. |
ToPointFromPixel(double, UnitConversionOptions)
Converts the supplied data for use with UnitConverter.
Declaration
public static double ToPointFromPixel(double value, UnitConversionOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The value used by the operation. |
| UnitConversionOptions | options | The options used by the operation. |
Returns
| Type | Description |
|---|---|
| double | The to point from pixel returned by the operation. |
ToPointFromPixel(double, int)
Converts the supplied data for use with UnitConverter.
Declaration
public static double ToPointFromPixel(double value, int dpi)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The value used by the operation. |
| int | dpi | The dpi used by the operation. |
Returns
| Type | Description |
|---|---|
| double | The to point from pixel returned by the operation. |
ToPointFromTwips(int)
Converts twips to points using the standard 20-to-1 conversion.
Declaration
public static double ToPointFromTwips(int value)
Parameters
| Type | Name | Description |
|---|---|---|
| int | value | The twip value to convert. |
Returns
| Type | Description |
|---|---|
| double | The corresponding point value. |
ToTwipsFromPointsClamped(double)
Converts font size from points to twips with proper clamping for XLSB BrtFont records.
Declaration
public static ushort ToTwipsFromPointsClamped(double pointSize)
Parameters
| Type | Name | Description |
|---|---|---|
| double | pointSize | Font size in points |
Returns
| Type | Description |
|---|---|
| ushort | Font size in twips, clamped to valid range (0x0014 to 0x1FFF) |
Remarks
BrtFont dyHeight field must be between 0x0014 (20 twips = 1 point) and 0x1FFF (8191 twips = 409.55 points).
TryConvert(ScreenMeasurementUnit, ScreenMeasurementUnit, double, UnitConversionOptions, out double)
Retrieves the requested convert from UnitConverter.
Declaration
public static bool TryConvert(ScreenMeasurementUnit from, ScreenMeasurementUnit to, double value, UnitConversionOptions options, out double result)
Parameters
| Type | Name | Description |
|---|---|---|
| ScreenMeasurementUnit | from | The from used by the operation. |
| ScreenMeasurementUnit | to | The to used by the operation. |
| double | value | The value used by the operation. |
| UnitConversionOptions | options | The options used by the operation. |
| double | result | The result used by the operation. |
Returns
| Type | Description |
|---|---|
| bool | The try convert returned by the operation. |
TryConvert(ScreenMeasurementUnit, ScreenMeasurementUnit, double, out double)
Retrieves the requested convert from UnitConverter.
Declaration
public static bool TryConvert(ScreenMeasurementUnit from, ScreenMeasurementUnit to, double value, out double result)
Parameters
| Type | Name | Description |
|---|---|---|
| ScreenMeasurementUnit | from | The from used by the operation. |
| ScreenMeasurementUnit | to | The to used by the operation. |
| double | value | The value used by the operation. |
| double | result | The result used by the operation. |
Returns
| Type | Description |
|---|---|
| bool | The try convert returned by the operation. |
TryConvert(ScreenMeasurementUnit, ScreenMeasurementUnit, double, int, out double)
Retrieves the requested convert from UnitConverter.
Declaration
public static bool TryConvert(ScreenMeasurementUnit from, ScreenMeasurementUnit to, double value, int dpi, out double result)
Parameters
| Type | Name | Description |
|---|---|---|
| ScreenMeasurementUnit | from | The from used by the operation. |
| ScreenMeasurementUnit | to | The to used by the operation. |
| double | value | The value used by the operation. |
| int | dpi | The dpi used by the operation. |
| double | result | The result used by the operation. |
Returns
| Type | Description |
|---|---|
| bool | The try convert returned by the operation. |