GemBox.Presentation
  • Overview
  • Examples
  • Free version
  • Support
  • Pricelist

    Show / Hide Table of Contents

    Length Struct

    Namespace:
    GemBox.Presentation
    Assembly:
    GemBox.Presentation.dll

    Represents a length, distance or a coordinate.

    • C#
    • VB.NET
    public struct Length : IComparable<Length>, IEquatable<Length>, IFormattable
    Public Structure Length
        Implements IComparable(Of Length), IEquatable(Of Length), IFormattable
    Implements
    IComparable<Length>
    IEquatable<Length>
    IFormattable
    Remarks

    Length internally stores its value in an Int64 field and internally uses EMU (English Metric Unit) as a unit of measurement.

    EMU (English Metric Unit) can evenly divide in both English and Metric units and can avoid rounding errors during the calculation since it defines an integer based, high precision coordinate system (1" = 914 400 EMU, 1 cm = 360 000 EMU, 1 mm = 36 000 EMU, 1 pt = 12 700 EMU).

    Properties

    DefaultUnit

    Gets or sets the default measurement unit that is applied globally every time Length is converted from/to a Double and to a String.

    • C#
    • VB.NET
    public static LengthUnit DefaultUnit { get; set; }
    Public Shared Property DefaultUnit As LengthUnit
    Property Value
    LengthUnit

    The default measurement unit.

    Remarks

    Initial value is Point.

    This property makes code less verbose and, thus, easier to read and maintain because instead of using From(Double, LengthUnit), To(LengthUnit) and ToString(LengthUnit) methods, one can use implicit conversions from/to a Double and to a String.

    Since default measurement unit is applied globally (like any other static member), it is advisable not to set DefaultUnit property or use implicit conversions from/to a Double and to a String if GemBox.Presentation is used by various application functions that expect different default measurement unit, especially if usage is multi-threaded.

    Methods

    CompareTo(Length)

    Compares the value of this instance to a specified Length value and returns an integer that indicates whether this instance is less than, equal to, or greater than the specified Length value.

    • C#
    • VB.NET
    public int CompareTo(Length other)
    Public Function CompareTo(other As Length) As Integer
    Parameters
    other
    Length

    The object to compare to the current instance.

    Returns
    Int32

    A signed number indicating the relative values of this instance and the other parameter.

    If returned value is less than zero, then this instance is less than other; else, if it is zero, then this instance is equal to other; else (if it is greater than zero) this instance is greater than other.

    Equals(Length)

    Determines whether the other Length is equal to this Length instance.

    • C#
    • VB.NET
    public bool Equals(Length other)
    Public Function Equals(other As Length) As Boolean
    Parameters
    other
    Length

    The other length to compare with this length instance.

    Returns
    Boolean

    true if the other Length is equal to this Length instance; otherwise, false.

    Equals(Object)

    Determines whether the specified Object is equal to this Length instance.

    • C#
    • VB.NET
    public override bool Equals(object obj)
    Public Overrides Function Equals(obj As Object) As Boolean
    Parameters
    obj
    Object

    The Object to compare with this length instance.

    Returns
    Boolean

    true if the specified Object is a Length and is equal to this Length instance; otherwise, false.

    Overrides
    ValueType.Equals(Object)

    From(Double, LengthUnit)

    Converts a length value in a specified measurement unit to a Length instance.

    • C#
    • VB.NET
    public static Length From(double value, LengthUnit unit)
    Public Shared Function From(value As Double, unit As LengthUnit) As Length
    Parameters
    value
    Double

    The length value.

    unit
    LengthUnit

    The measurement unit.

    Returns
    Length

    A Length instance that is equivalent to a specified input length in a specified measurement unit.

    GetHashCode()

    Returns a hash code for this Length instance.

    • C#
    • VB.NET
    public override int GetHashCode()
    Public Overrides Function GetHashCode As Integer
    Returns
    Int32

    An integer value that specifies a hash value for this Length instance.

    Overrides
    ValueType.GetHashCode()

    To(LengthUnit)

    Converts this Length instance to a length value in a specified measurement unit.

    • C#
    • VB.NET
    public double To(LengthUnit unit)
    Public Function To(unit As LengthUnit) As Double
    Parameters
    unit
    LengthUnit

    The measurement unit.

    Returns
    Double

    A length value that is equivalent to this Length instance in a specified measurement unit.

    ToString()

    Returns a String that represents this Length instance in a DefaultUnit.

    • C#
    • VB.NET
    public override string ToString()
    Public Overrides Function ToString As String
    Returns
    String

    A String that represents this Length instance in a default measurement unit.

    Overrides
    ValueType.ToString()

    ToString(LengthUnit)

    Returns a String that represents this Length instance in a specified measurement unit.

    • C#
    • VB.NET
    public string ToString(LengthUnit unit)
    Public Function ToString(unit As LengthUnit) As String
    Parameters
    unit
    LengthUnit

    The measurement unit.

    Returns
    String

    A String that represents this Length instance in a specified measurement unit.

    ToString(String, IFormatProvider)

    Returns a String that represents this Length instance in a specified format and a DefaultUnit by using a specified format provider.

    • C#
    • VB.NET
    public string ToString(string format, IFormatProvider formatProvider)
    Public Function ToString(format As String, formatProvider As IFormatProvider) As String
    Parameters
    format
    String

    The format.

    formatProvider
    IFormatProvider

    The format provider.

    Returns
    String

    A String that represents this Length instance in a specified format and a DefaultUnit by using a specified format provider.

    ToString(String, IFormatProvider, LengthUnit)

    Returns a String that represents this Length instance in a specified format and a measurement unit by using a specified format provider.

    • C#
    • VB.NET
    public string ToString(string format, IFormatProvider formatProvider, LengthUnit unit)
    Public Function ToString(format As String, formatProvider As IFormatProvider, unit As LengthUnit) As String
    Parameters
    format
    String

    The format.

    formatProvider
    IFormatProvider

    The format provider.

    unit
    LengthUnit

    The measurement unit.

    Returns
    String

    A String that represents this Length instance in a specified format and a measurement unit by using a specified format provider.

    Operators

    Equality(Length, Length)

    Determines whether first and second Lengths are equal.

    • C#
    • VB.NET
    public static bool operator ==(Length first, Length second)
    Public Shared Operator =(first As Length, second As Length) As Boolean
    Parameters
    first
    Length

    The first length.

    second
    Length

    The second length.

    Returns
    Boolean

    true if first and second lengths are equal; otherwise, false.

    Explicit(Length to Int64)

    Converts a Length instance to a length value in an EMU (English Metric Unit) measurement unit.

    • C#
    • VB.NET
    public static explicit operator long (Length value)
    Public Shared Narrowing Operator CType(value As Length) As Long
    Parameters
    value
    Length

    The length value.

    Returns
    Int64

    A length value that is equivalent to a specified input Length instance in an EMU (English Metric Unit) measurement unit.

    Explicit(Int64 to Length)

    Converts a length value in an EMU (English Metric Unit) measurement unit to a Length instance.

    • C#
    • VB.NET
    public static explicit operator Length(long value)
    Public Shared Narrowing Operator CType(value As Long) As Length
    Parameters
    value
    Int64

    The length value.

    Returns
    Length

    A Length instance that is equivalent to a specified input length in an EMU (English Metric Unit) measurement unit.

    GreaterThan(Length, Length)

    Determines whether first Length is greater than second Length.

    • C#
    • VB.NET
    public static bool operator>(Length first, Length second)
    Public Shared Operator>(first As Length, second As Length) As Boolean
    Parameters
    first
    Length

    The first length.

    second
    Length

    The second length.

    Returns
    Boolean

    true if first length is greater than second length; otherwise, false.

    Implicit(Length to Double)

    Converts a Length instance to a length value in a DefaultUnit.

    • C#
    • VB.NET
    public static implicit operator double (Length value)
    Public Shared Widening Operator CType(value As Length) As Double
    Parameters
    value
    Length

    The length value.

    Returns
    Double

    A length value that is equivalent to a specified input Length instance in a DefaultUnit.

    Implicit(Double to Length)

    Converts a length value in a DefaultUnit to a Length instance.

    • C#
    • VB.NET
    public static implicit operator Length(double value)
    Public Shared Widening Operator CType(value As Double) As Length
    Parameters
    value
    Double

    The length value.

    Returns
    Length

    A Length instance that is equivalent to a specified input length in a DefaultUnit.

    Inequality(Length, Length)

    Determines whether first and second Lengths are not equal.

    • C#
    • VB.NET
    public static bool operator !=(Length first, Length second)
    Public Shared Operator <>(first As Length, second As Length) As Boolean
    Parameters
    first
    Length

    The first length.

    second
    Length

    The second length.

    Returns
    Boolean

    true if first and second lengths are not equal; otherwise, false.

    LessThan(Length, Length)

    Determines whether first Length is less than second Length.

    • C#
    • VB.NET
    public static bool operator <(Length first, Length second)
    Public Shared Operator <(first As Length, second As Length) As Boolean
    Parameters
    first
    Length

    The first length.

    second
    Length

    The second length.

    Returns
    Boolean

    true if first length is less than second length; otherwise, false.

    Implements

    System.IComparable<T>
    System.IEquatable<T>
    System.IFormattable
    Back to top

    Facebook • Twitter • LinkedIn

    © GemBox Ltd. — All rights reserved.