• DR-IT Software
  • Products
  • Documentation
  • Product page
  • Examples
  • API reference
  • Support
Show / Hide Table of Contents

Class UnitConverter

Represents the unit converter used by the presentation model.

Inheritance
object
UnitConverter
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: DRIT.Presentation.Office
Assembly: DRIT.Presentation.dll
Syntax
public static class UnitConverter

Fields

CentimeterPerInch

Gets the number of centimeters in one inch.

Declaration
public const double CentimeterPerInch = 2.54
Field Value
Type Description
double

DefaultDpi

Gets the default screen resolution used by conversions that do not specify DPI.

Declaration
public const int DefaultDpi = 96
Field Value
Type Description
int

MillimeterPerCentimeter

Gets the number of millimeters in one centimeter.

Declaration
public const double MillimeterPerCentimeter = 10
Field Value
Type Description
double

OpenXmlAngleConversionFactor

Gets the number of Open XML angle units in one degree.

Declaration
public const double OpenXmlAngleConversionFactor = 60000
Field Value
Type Description
double

PointPerPica

Gets the number of points in one pica.

Declaration
public const double PointPerPica = 12
Field Value
Type Description
double

Methods

CanConvert(ScreenMeasurementUnit, ScreenMeasurementUnit)

Handles can convert for this unit converter.

Declaration
public static bool CanConvert(ScreenMeasurementUnit from, ScreenMeasurementUnit to)
Parameters
Type Name Description
ScreenMeasurementUnit from

The from endpoint of the range.

ScreenMeasurementUnit to

The to endpoint of the range.

Returns
Type Description
bool

true if the operation succeeds; otherwise, false.

Convert(ScreenMeasurementUnit, ScreenMeasurementUnit, double)

Converts the supplied value using the convert conversion.

Declaration
public static double Convert(ScreenMeasurementUnit from, ScreenMeasurementUnit to, double value)
Parameters
Type Name Description
ScreenMeasurementUnit from

The from endpoint of the range.

ScreenMeasurementUnit to

The to endpoint of the range.

double value

The value supplied to this operation.

Returns
Type Description
double

The converted value.

Convert(ScreenMeasurementUnit, ScreenMeasurementUnit, double, UnitConversionOptions)

Converts the supplied value using the convert conversion.

Declaration
public static double Convert(ScreenMeasurementUnit from, ScreenMeasurementUnit to, double value, UnitConversionOptions options)
Parameters
Type Name Description
ScreenMeasurementUnit from

The from endpoint of the range.

ScreenMeasurementUnit to

The to endpoint of the range.

double value

The value supplied to this operation.

UnitConversionOptions options

The options that control the operation.

Returns
Type Description
double

The converted value.

Convert(ScreenMeasurementUnit, ScreenMeasurementUnit, double, int)

Converts the supplied value using the convert conversion.

Declaration
public static double Convert(ScreenMeasurementUnit from, ScreenMeasurementUnit to, double value, int dpi)
Parameters
Type Name Description
ScreenMeasurementUnit from

The from endpoint of the range.

ScreenMeasurementUnit to

The to endpoint of the range.

double value

The value supplied to this operation.

int dpi

The output resolution in dots per inch.

Returns
Type Description
double

The converted value.

FromHiMetricToPoint(double)

Handles from hi metric to point for this unit converter.

Declaration
public static double FromHiMetricToPoint(double himetricValue)
Parameters
Type Name Description
double himetricValue

The himetric value supplied to this operation.

Returns
Type Description
double

The from hi metric to point value produced by the operation.

GetPointSizeWithWholePixels(double)

Represents the unit converter used by the presentation model.

Declaration
public static double GetPointSizeWithWholePixels(double value)
Parameters
Type Name Description
double value
Returns
Type Description
double
Remarks

The font size in pixels should be a whole number. Therefore the point size 8 is changed to 8.25.

ToEmuFromInches(double)

Converts inches to English Metric Units (EMUs).

Declaration
public static long ToEmuFromInches(double value)
Parameters
Type Name Description
double value

The distance in inches.

Returns
Type Description
long

The equivalent distance in EMUs.

ToEmuFromPixel(double)

Converts pixels to EMUs using DefaultDpi.

Declaration
public static long ToEmuFromPixel(double value)
Parameters
Type Name Description
double value

The distance in pixels.

Returns
Type Description
long

The equivalent distance in EMUs.

ToEmuFromPixel(double, UnitConversionOptions)

Converts pixels to EMUs using the resolution in the supplied options.

Declaration
public static long ToEmuFromPixel(double value, UnitConversionOptions options)
Parameters
Type Name Description
double value

The distance in pixels.

UnitConversionOptions options

The conversion options containing the source DPI.

Returns
Type Description
long

The equivalent distance in EMUs.

ToEmuFromPixel(double, int)

Converts pixels to EMUs at the specified resolution.

Declaration
public static long ToEmuFromPixel(double value, int dpi)
Parameters
Type Name Description
double value

The distance in pixels.

int dpi

The source resolution in dots per inch.

Returns
Type Description
long

The equivalent distance in EMUs.

ToEmuFromPixel(double?)

Converts an optional pixel distance to EMUs using DefaultDpi.

Declaration
public static long? ToEmuFromPixel(double? value)
Parameters
Type Name Description
double? value

The optional distance in pixels.

Returns
Type Description
long?

The equivalent distance in EMUs, or null when value is null.

ToEmuFromPixel(double?, UnitConversionOptions)

Converts an optional pixel distance to EMUs using the resolution in the supplied options.

Declaration
public static long? ToEmuFromPixel(double? value, UnitConversionOptions options)
Parameters
Type Name Description
double? value

The optional distance in pixels.

UnitConversionOptions options

The conversion options containing the source DPI.

Returns
Type Description
long?

The equivalent distance in EMUs, or null when value is null.

ToEmuFromPixel(double?, int)

Converts an optional pixel distance to EMUs at the specified resolution.

Declaration
public static long? ToEmuFromPixel(double? value, int dpi)
Parameters
Type Name Description
double? value

The optional distance in pixels.

int dpi

The source resolution in dots per inch.

Returns
Type Description
long?

The equivalent distance in EMUs, or null when value is null.

ToEmuFromPoint(double)

Converts points to EMUs using DefaultDpi.

Declaration
public static long ToEmuFromPoint(double value)
Parameters
Type Name Description
double value

The distance in points.

Returns
Type Description
long

The equivalent distance in EMUs.

ToInchesFromEmu(long)

Converts English Metric Units (EMUs) to inches.

Declaration
public static double ToInchesFromEmu(long value)
Parameters
Type Name Description
long value

The distance in EMUs.

Returns
Type Description
double

The equivalent distance in inches.

ToPixelFromEmu(double)

Converts EMUs to pixels using DefaultDpi.

Declaration
public static double ToPixelFromEmu(double value)
Parameters
Type Name Description
double value

The distance in EMUs.

Returns
Type Description
double

The equivalent distance in pixels.

ToPixelFromEmu(double, UnitConversionOptions)

Converts EMUs to pixels using the resolution in the supplied options.

Declaration
public static double ToPixelFromEmu(double value, UnitConversionOptions options)
Parameters
Type Name Description
double value

The distance in EMUs.

UnitConversionOptions options

The conversion options containing the target DPI.

Returns
Type Description
double

The equivalent distance in pixels.

ToPixelFromEmu(double, int)

Converts EMUs to pixels at the specified resolution.

Declaration
public static double ToPixelFromEmu(double value, int dpi)
Parameters
Type Name Description
double value

The distance in EMUs.

int dpi

The target resolution in dots per inch.

Returns
Type Description
double

The equivalent distance in pixels.

ToPixelFromEmu(long)

Converts EMUs to pixels using DefaultDpi.

Declaration
public static double ToPixelFromEmu(long value)
Parameters
Type Name Description
long value

The distance in EMUs.

Returns
Type Description
double

The equivalent distance in pixels.

ToPixelFromEmu(long, UnitConversionOptions)

Converts EMUs to pixels using the resolution in the supplied options.

Declaration
public static double ToPixelFromEmu(long value, UnitConversionOptions options)
Parameters
Type Name Description
long value

The distance in EMUs.

UnitConversionOptions options

The conversion options containing the target DPI.

Returns
Type Description
double

The equivalent distance in pixels.

ToPixelFromEmu(long, int)

Converts EMUs to pixels at the specified resolution.

Declaration
public static double ToPixelFromEmu(long value, int dpi)
Parameters
Type Name Description
long value

The distance in EMUs.

int dpi

The target resolution in dots per inch.

Returns
Type Description
double

The equivalent distance in pixels.

ToPixelFromEmu(long?)

Converts an optional EMU distance to pixels using DefaultDpi.

Declaration
public static double? ToPixelFromEmu(long? value)
Parameters
Type Name Description
long? value

The optional distance in EMUs.

Returns
Type Description
double?

The equivalent distance in pixels, or null when value is null.

ToPixelFromEmu(long?, UnitConversionOptions)

Converts an optional EMU distance to pixels using the resolution in the supplied options.

Declaration
public static double? ToPixelFromEmu(long? value, UnitConversionOptions options)
Parameters
Type Name Description
long? value

The optional distance in EMUs.

UnitConversionOptions options

The conversion options containing the target DPI.

Returns
Type Description
double?

The equivalent distance in pixels, or null when value is null.

ToPixelFromEmu(long?, int)

Converts an optional EMU distance to pixels at the specified resolution.

Declaration
public static double? ToPixelFromEmu(long? value, int dpi)
Parameters
Type Name Description
long? value

The optional distance in EMUs.

int dpi

The target resolution in dots per inch.

Returns
Type Description
double?

The equivalent distance in pixels, or null when value is null.

ToPixelFromPoint(double)

Converts the supplied value using the to pixel from point conversion.

Declaration
public static double ToPixelFromPoint(double value)
Parameters
Type Name Description
double value

The value supplied to this operation.

Returns
Type Description
double

The converted value.

ToPixelFromPoint(double, UnitConversionOptions)

Converts the supplied value using the to pixel from point conversion.

Declaration
public static double ToPixelFromPoint(double value, UnitConversionOptions options)
Parameters
Type Name Description
double value

The value supplied to this operation.

UnitConversionOptions options

The options that control the operation.

Returns
Type Description
double

The converted value.

ToPixelFromPoint(double, int)

Converts the supplied value using the to pixel from point conversion.

Declaration
public static double ToPixelFromPoint(double value, int dpi)
Parameters
Type Name Description
double value

The value supplied to this operation.

int dpi

The output resolution in dots per inch.

Returns
Type Description
double

The converted value.

ToPixelsFromTwips(int)

Handles to pixels from twips for this unit converter.

Declaration
public static double ToPixelsFromTwips(int twips)
Parameters
Type Name Description
int twips

The twips supplied to this operation.

Returns
Type Description
double

The converted value.

ToPointFromEmu(double)

Converts EMUs to points.

Declaration
public static double ToPointFromEmu(double value)
Parameters
Type Name Description
double value

The distance in EMUs.

Returns
Type Description
double

The equivalent distance in points.

ToPointFromEmu(long)

Converts EMUs to points.

Declaration
public static double ToPointFromEmu(long value)
Parameters
Type Name Description
long value

The distance in EMUs.

Returns
Type Description
double

The equivalent distance in points.

ToPointFromPixel(double)

Converts the supplied value using the to point from pixel conversion.

Declaration
public static double ToPointFromPixel(double value)
Parameters
Type Name Description
double value

The value supplied to this operation.

Returns
Type Description
double

The converted value.

ToPointFromPixel(double, UnitConversionOptions)

Converts the supplied value using the to point from pixel conversion.

Declaration
public static double ToPointFromPixel(double value, UnitConversionOptions options)
Parameters
Type Name Description
double value

The value supplied to this operation.

UnitConversionOptions options

The options that control the operation.

Returns
Type Description
double

The converted value.

ToPointFromPixel(double, int)

Converts the supplied value using the to point from pixel conversion.

Declaration
public static double ToPointFromPixel(double value, int dpi)
Parameters
Type Name Description
double value

The value supplied to this operation.

int dpi

The output resolution in dots per inch.

Returns
Type Description
double

The converted value.

ToPointFromTwips(int)

Handles to point from twips for this unit converter.

Declaration
public static double ToPointFromTwips(int value)
Parameters
Type Name Description
int value

The value supplied to this operation.

Returns
Type Description
double

The converted value.

Remarks

The font size in pixels should be a whole number. Therefore the point size 8 is changed to 8.25.

TryConvert(ScreenMeasurementUnit, ScreenMeasurementUnit, double, UnitConversionOptions?, out double)

Attempts to perform the convert and reports whether it succeeded.

Declaration
public static bool TryConvert(ScreenMeasurementUnit from, ScreenMeasurementUnit to, double value, UnitConversionOptions? options, out double result)
Parameters
Type Name Description
ScreenMeasurementUnit from

The from endpoint of the range.

ScreenMeasurementUnit to

The to endpoint of the range.

double value

The value supplied to this operation.

UnitConversionOptions options

The options that control the operation.

double result

The result supplied to this operation.

Returns
Type Description
bool

true if the operation succeeds; otherwise, false.

TryConvert(ScreenMeasurementUnit, ScreenMeasurementUnit, double, out double)

Attempts to perform the convert and reports whether it succeeded.

Declaration
public static bool TryConvert(ScreenMeasurementUnit from, ScreenMeasurementUnit to, double value, out double result)
Parameters
Type Name Description
ScreenMeasurementUnit from

The from endpoint of the range.

ScreenMeasurementUnit to

The to endpoint of the range.

double value

The value supplied to this operation.

double result

The result supplied to this operation.

Returns
Type Description
bool

true if the operation succeeds; otherwise, false.

TryConvert(ScreenMeasurementUnit, ScreenMeasurementUnit, double, int, out double)

Attempts to perform the convert and reports whether it succeeded.

Declaration
public static bool TryConvert(ScreenMeasurementUnit from, ScreenMeasurementUnit to, double value, int dpi, out double result)
Parameters
Type Name Description
ScreenMeasurementUnit from

The from endpoint of the range.

ScreenMeasurementUnit to

The to endpoint of the range.

double value

The value supplied to this operation.

int dpi

The output resolution in dots per inch.

double result

The result supplied to this operation.

Returns
Type Description
bool

true if the operation succeeds; otherwise, false.

Back to top

DR-IT Software documentation

DR-IT Software · Products · Documentation index · Product page · Downloads · Support · Licensing

Generated by DocFX