Table of Contents

Struct XUnit

Namespace
PdfSharp.Drawing
Assembly
PdfSharp.dll

Represents a value and its unit of measure.

public struct XUnit
Extension Methods

Constructors

XUnit(double)

Initializes a new instance of the XUnit class with type set to point.

XUnit(double, XGraphicsUnit)

Initializes a new instance of the XUnit class.

Fields

Zero

Represents a unit with all values zero.

Properties

Centimeter

Gets or sets the value in centimeter.

Inch

Gets or sets the value in inch.

Millimeter

Gets or sets the value in millimeter.

Point

Gets or sets the value in point.

Presentation

Gets or sets the value in presentation units (1/96 inch).

Type

Gets the unit of measure.

Value

Gets the raw value of the object without any conversion. To determine the XGraphicsUnit use property

Type

. To get the value in point use property

Point

.

Methods

CompareTo(XUnit)

Compares this XUnit with another XUnit value.

CompareTo(object?)

Compares this XUnit with another object.

ConvertType(XGraphicsUnit)

Converts an existing object from one unit into another unit type.

Equals(object?)

Calls base class Equals.

FromCentimeter(double)

Returns an XUnit object. Sets type to centimeters.

FromInch(double)

Returns an XUnit object. Sets type to inch.

FromMillimeter(double)

Returns an XUnit object. Sets type to millimeters.

FromPoint(double)

Returns an XUnit object. Sets type to point.

FromPresentation(double)

Returns an XUnit object. Sets type to Presentation.

GetHashCode()

Returns the hash code for this instance.

IsSameValue(XUnit)

Compares the actual values of this XUnit and another XUnit value tolerating rounding errors.

Parse(string)

This member is intended to be used by XmlDomainObjectReader only.

ToString()

Returns the object as string. The unit of measure is appended to the end of the string.

ToString(IFormatProvider?)

Returns the object as string using the format information. The unit of measure is appended to the end of the string.

Operators

operator +(XUnit, XUnit)

Adds an XUnit to an XUnit.

operator +(XUnit, string)

Adds a string parsed as XUnit to an XUnit.

operator /(XUnit, double)

Divides an XUnit by a double.

operator ==(XUnit, XUnit)

Memberwise comparison checking the exact value and unit. To compare by value tolerating rounding errors, use IsSameValue() or code like Math.Abs(a.Pt - b.Pt) < 1e-5.

operator >(XUnit, XUnit)

Compares two XUnit values.

operator >=(XUnit, XUnit)

Compares two XUnit values.

implicit operator double(XUnit)

Converts an XUnit object to a double value as point.

implicit operator XUnit(double)

Converts a double to an XUnit object with type set to point.

implicit operator XUnit(int)

Converts an int to an XUnit object with type set to point.

implicit operator XUnit(string)

Converts a string to an XUnit object. If the string contains a suffix like 'cm' or 'in' the object will be converted to the appropriate type, otherwise point is assumed.

operator !=(XUnit, XUnit)

Memberwise comparison checking exact value and unit. To compare by value tolerating rounding errors, use IsSameValue() or code like Math.Abs(a.Pt - b.Pt) < 1e-5.

operator <(XUnit, XUnit)

Compares two XUnit values.

operator <=(XUnit, XUnit)

Compares two XUnit values.

operator *(XUnit, double)

Multiplies an XUnit with a double.

operator -(XUnit, XUnit)

Subtracts an XUnit from an XUnit.

operator -(XUnit, string)

Subtracts a string parsed as Unit from an XUnit.

operator -(XUnit)

Returns the negative value of an XUnit.