Struct XUnit
Represents a value and its unit of measure.
public struct XUnit : IFormattable, IComparable<XUnit>, IComparable
- Implements
- Inherited Members
Constructors
XUnit(double)
Initializes a new instance of the XUnit class with type set to point.
public XUnit(double point)
Parameters
point
double
XUnit(double, XGraphicsUnit)
Initializes a new instance of the XUnit class.
public XUnit(double value, XGraphicsUnit type)
Parameters
value
doubletype
XGraphicsUnit
Fields
Zero
Represents a unit with all values zero.
public static readonly XUnit Zero
Field Value
Properties
Centimeter
Gets or sets the value in centimeter.
public double Centimeter { get; set; }
Property Value
Inch
Gets or sets the value in inch.
public double Inch { get; set; }
Property Value
Millimeter
Gets or sets the value in millimeter.
public double Millimeter { get; set; }
Property Value
Point
Gets or sets the value in point.
public double Point { get; set; }
Property Value
Presentation
Gets or sets the value in presentation units (1/96 inch).
public double Presentation { get; set; }
Property Value
Type
Gets the unit of measure.
public readonly XGraphicsUnit Type { get; }
Property Value
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
.
public readonly double Value { get; }
Property Value
Methods
CompareTo(XUnit)
Compares this XUnit with another XUnit value.
public int CompareTo(XUnit other)
Parameters
other
XUnit
Returns
CompareTo(object?)
Compares this XUnit with another object.
public int CompareTo(object? obj)
Parameters
obj
object
Returns
ConvertType(XGraphicsUnit)
Converts an existing object from one unit into another unit type.
public void ConvertType(XGraphicsUnit type)
Parameters
type
XGraphicsUnit
Equals(object?)
Calls base class Equals.
public override bool Equals(object? obj)
Parameters
obj
object
Returns
FromCentimeter(double)
Returns an XUnit object. Sets type to centimeters.
public static XUnit FromCentimeter(double value)
Parameters
value
double
Returns
FromInch(double)
Returns an XUnit object. Sets type to inch.
public static XUnit FromInch(double value)
Parameters
value
double
Returns
FromMillimeter(double)
Returns an XUnit object. Sets type to millimeters.
public static XUnit FromMillimeter(double value)
Parameters
value
double
Returns
FromPoint(double)
Returns an XUnit object. Sets type to point.
public static XUnit FromPoint(double value)
Parameters
value
double
Returns
FromPresentation(double)
Returns an XUnit object. Sets type to Presentation.
public static XUnit FromPresentation(double value)
Parameters
value
double
Returns
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
IsSameValue(XUnit)
Compares the actual values of this XUnit and another XUnit value tolerating rounding errors.
public bool IsSameValue(XUnit other)
Parameters
other
XUnit
Returns
Parse(string)
This member is intended to be used by XmlDomainObjectReader only.
public static XUnit Parse(string value)
Parameters
value
string
Returns
ToString()
Returns the object as string. The unit of measure is appended to the end of the string.
public override string ToString()
Returns
ToString(IFormatProvider?)
Returns the object as string using the format information. The unit of measure is appended to the end of the string.
public string ToString(IFormatProvider? formatProvider)
Parameters
formatProvider
IFormatProvider
Returns
Operators
operator +(XUnit, XUnit)
Adds an XUnit to an XUnit.
public static XUnit operator +(XUnit l, XUnit r)
Parameters
Returns
operator +(XUnit, string)
Adds a string parsed as XUnit to an XUnit.
public static XUnit operator +(XUnit l, string r)
Parameters
Returns
operator /(XUnit, double)
Divides an XUnit by a double.
public static XUnit operator /(XUnit l, double r)
Parameters
Returns
operator ==(XUnit, XUnit)
Memberwise comparison checking the exact value und unit. To compare by value tolerating rounding errors, use IsSameValue() or code like Math.Abs(a.Pt - b.Pt) < 1e-5.
public static bool operator ==(XUnit l, XUnit r)
Parameters
Returns
operator >(XUnit, XUnit)
Compares two XUnit values.
public static bool operator >(XUnit l, XUnit r)
Parameters
Returns
operator >=(XUnit, XUnit)
Compares two XUnit values.
public static bool operator >=(XUnit l, XUnit r)
Parameters
Returns
implicit operator double(XUnit)
Converts an XUnit object to a double value as point.
[Obsolete("In PDFsharp 6.1 implicit conversion to double is marked obsolete, because it led to misunderstandings and unexpected behavior. Use the XUnit.Point property instead.")]
public static implicit operator double(XUnit value)
Parameters
value
XUnit
Returns
implicit operator XUnit(double)
Converts a double to an XUnit object with type set to point.
[Obsolete("In PDFsharp 6.1 implicit conversion from double is marked obsolete, because it led to misunderstandings and unexpected behavior. Provide the unit by XUnit.FromPoint() or use the new class XUnitPt instead.")]
public static implicit operator XUnit(double value)
Parameters
value
double
Returns
implicit operator XUnit(int)
Converts an int to an XUnit object with type set to point.
[Obsolete("In PDFsharp 6.1 implicit conversion from int is marked obsolete, because it led to misunderstandings and unexpected behavior. Provide the unit by XUnit.FromPoint() or use the new class XUnitPt instead.")]
public static implicit operator XUnit(int value)
Parameters
value
int
Returns
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.
public static implicit operator XUnit(string value)
Parameters
value
string
Returns
operator !=(XUnit, XUnit)
Memberwise comparison checking exact value und unit. To compare by value tolerating rounding errors, use IsSameValue() or code like Math.Abs(a.Pt - b.Pt) < 1e-5.
public static bool operator !=(XUnit l, XUnit r)
Parameters
Returns
operator <(XUnit, XUnit)
Compares two XUnit values.
public static bool operator <(XUnit l, XUnit r)
Parameters
Returns
operator <=(XUnit, XUnit)
Compares two XUnit values.
public static bool operator <=(XUnit l, XUnit r)
Parameters
Returns
operator *(XUnit, double)
Multiplies an XUnit with a double.
public static XUnit operator *(XUnit l, double r)
Parameters
Returns
operator -(XUnit, XUnit)
Subtracts an XUnit from an XUnit.
public static XUnit operator -(XUnit l, XUnit r)
Parameters
Returns
operator -(XUnit, string)
Subtracts a string parsed as Unit from an XUnit.
public static XUnit operator -(XUnit l, string r)
Parameters
Returns
operator -(XUnit)
Returns the negative value of an XUnit.
public static XUnit operator -(XUnit value)
Parameters
value
XUnit