Struct Unit
A structure representing a unit of measure.
Namespace: Telerik.Reporting.Drawing
Assembly: Telerik.Reporting.dll
Syntax
public struct Unit : IComparable, IComparable<Unit>
Constructors
Unit(Double)
Creates a new instance of the Unit structure from the specified device-independent pixels. The Unit's type is DefaultType
Declaration
public Unit(double dips)
Parameters
|
System.Double
dips
A double value specifying the magnitude of the Unit in device-independent pixels. |
Unit(Double, UnitType)
Initializes a new instance of the Unit structure with the specified value and type.
Declaration
public Unit(double value, UnitType type)
Parameters
|
System.Double
value
A double value representing the magnitude of the Unit. |
|
UnitType
type
A UnitType specifying the type of the Unit. |
Unit(String)
Initializes a new instance of the Unit structure from the specified string value.
Declaration
public Unit(string value)
Parameters
|
System.String
value
A string value representing the magnitude and type of the Unit. |
Remarks
Parameters passed to this constructor should be of the form "2px", "3.4in", "4cm", "2mm", "12.5pt", "4pc", etc. For more information on string representations of units see UnitType.
Unit(String, CultureInfo)
Initializes a new instance of the Unit structure from the specified string value and using the specified System.Globalization.CultureInfo.
Declaration
public Unit(string value, CultureInfo culture)
Parameters
|
System.String
value
A string value representing the magnitude and type of the Unit. |
|
System.Globalization.CultureInfo
culture
A System.Globalization.CultureInfo. If a null reference (Nothing in Visual Basic) is passed, the current culture is assumed. |
Remarks
The culture parameters is used to parse the string value.
Unit(String, CultureInfo, UnitType)
Initializes a new instance of the Unit structure from the specified string value, culture, and type.
Declaration
public Unit(string value, CultureInfo culture, UnitType type)
Parameters
|
System.String
value
A string value representing the magnitude of the Unit. |
|
System.Globalization.CultureInfo
culture
A System.Globalization.CultureInfo. If a null reference (Nothing in Visual Basic) is passed, the current culture is assumed. |
|
UnitType
type
A UnitType specifying the type of the Unit. |
Fields
Empty
Initializes a new instance of the Unit structure.
Declaration
public static readonly Unit Empty
Field Value
|
Unit
|
Zero
Initializes a new instance of the Unit structure equal to zero.
Declaration
public static readonly Unit Zero
Field Value
|
Unit
|
Properties
DefaultType
Declaration
public static UnitType DefaultType { get; set; }
Property Value
|
UnitType
A UnitType value that defines the default units of measure for a Report. |
DotsPerInch
Gets a double value representing the DPI of the current graphics context (the DPI of a device-dependent pixel).
Declaration
public static double DotsPerInch { get; }
Property Value
|
System.Double
A double value representing the DPI of the current graphics context. |
IsEmpty
Specifies whether this Unit structure is uninitialized.
Declaration
public bool IsEmpty { get; }
Property Value
|
System.Boolean
This property returns true if this unit is uninitialized; otherwise, false. |
Type
Gets the type of the Unit.
Declaration
public UnitType Type { get; }
Property Value
|
UnitType
A UnitType specifying the type of this Unit. |
Value
Gets the magnitude of this Unit.
Declaration
public float Value { get; }
Property Value
|
System.Single
A float value indicating the magnitude of the Unit. |
Remarks
This property makes sense only in combination with the Type property.
Methods
Add(Unit)
Adds a unit to this Unit.
Declaration
public Unit Add(Unit unit1)
Parameters
|
Unit
unit1
The Unit to add. |
Returns
|
Unit
The sum of unit1 and this Unit in this Unit's type. |
Add(Unit, Unit)
Returns a Unit that is the sum of two units and its unit type matches the first argument type.
Declaration
public static Unit Add(Unit unit1, Unit unit2)
Parameters
|
Unit
unit1
The first Unit. |
|
Unit
unit2
The second Unit. |
Returns
|
Unit
The sum of the two units in the unit type of the first argument unit. |
Add(Unit, Unit, UnitType)
Returns a Unit that is the sum of two units and is of the specified type.
Declaration
[Obsolete("Use Add(unit1, unit2) and ChangeType(type) instead.")]
public static Unit Add(Unit unit1, Unit unit2, UnitType type)
Parameters
|
Unit
unit1
The first Unit. |
|
Unit
unit2
The second Unit. |
|
UnitType
type
A UnitType specifying the type of the resultant unit. |
Returns
|
Unit
The sum of the two units. |
ChangeType(UnitType)
Returns a unit equal by magnitude to this Unit but with its type changed.
Declaration
public Unit ChangeType(UnitType type)
Parameters
|
UnitType
type
The UnitType to change to. |
Returns
|
Unit
A Unit equal to this Unit, but with type that equals the type parameter. |
Cm(Double)
Creates a new Unit of type UnitType.Cm and magnitude equal to value.
Declaration
public static Unit Cm(double value)
Parameters
|
System.Double
value
A double value specifying the magnitude of the Unit. |
Returns
|
Unit
The created Unit. |
Cm(Int32)
Creates a new Unit of type UnitType.Cm and magnitude equal to value.
Declaration
public static Unit Cm(int value)
Parameters
|
System.Int32
value
An int value specifying the magnitude of the Unit. |
Returns
|
Unit
The created Unit. |
CompareTo(Object)
Internal use only
Declaration
public int CompareTo(object value)
Parameters
|
System.Object
value
|
Returns
|
System.Int32
|
CompareTo(Unit)
Internal use only
Declaration
public int CompareTo(Unit value)
Parameters
|
Unit
value
|
Returns
|
System.Int32
|
Divide(Double)
Divides this Unit by a specified value.
Declaration
public Unit Divide(double value)
Parameters
|
System.Double
value
A double value to divide by. |
Returns
|
Unit
The quotient resulting by dividing this Unit by the specified value. |
Divide(Unit)
Divides this Unit by another.
Declaration
public float Divide(Unit value)
Parameters
|
Unit
value
A Unit value to divide by. |
Returns
|
System.Single
The quotient resulting by dividing this Unit by the specified Unit. |
Equals(Object)
Tests whether obj is a Unit that equals this Unit.
Declaration
public override bool Equals(object obj)
Parameters
|
System.Object
obj
The System.Object to test. |
Returns
|
System.Boolean
This method returns true if obj is a Unit and its magnitude is equal to this Unit's magnitude; otherwise false. |
Overrides
FromDips(Double, UnitType)
Creates a unit from device-independent pixels in the specified unit type.
Declaration
public static Unit FromDips(double dips, UnitType resultType)
Parameters
|
System.Double
dips
The magnitude of the new Unit in device-independent pixels. |
|
UnitType
resultType
The unit type of the newly created Unit |
Returns
|
Unit
Newly created Unit |
FromPixels(Double, UnitType)
Creates a unit from device-dependent pixels in the specified unit type.
Declaration
public static Unit FromPixels(double devicePixels, UnitType resultType)
Parameters
|
System.Double
devicePixels
The magnitude of the new Unit in device-dependent pixels. |
|
UnitType
resultType
The unit type of the newly created Unit |
Returns
|
Unit
Newly created Unit |
GetHashCode()
Returns a hash code for this Unit structure.
Declaration
public override int GetHashCode()
Returns
|
System.Int32
An integer value that specifies a hash value for this Unit structure. |
Overrides
Inch(Double)
Creates a new Unit of type UnitType.Inch and magnitude equal to value.
Declaration
public static Unit Inch(double value)
Parameters
|
System.Double
value
A double value specifying the magnitude of the Unit. |
Returns
|
Unit
The created Unit. |
Inch(Int32)
Creates a new Unit of type UnitType.Inch and magnitude equal to value.
Declaration
public static Unit Inch(int value)
Parameters
|
System.Int32
value
An int value specifying the magnitude of the Unit. |
Returns
|
Unit
The created Unit. |
Max(Unit, Unit)
Returns the larger of two units.
Declaration
public static Unit Max(Unit val1, Unit val2)
Parameters
|
Unit
val1
The first of two units to compare. |
|
Unit
val2
The second of two units to compare. |
Returns
|
Unit
Parameter val1 or val2, whichever is larger. |
Min(Unit, Unit)
Returns the smaller of two units.
Declaration
public static Unit Min(Unit val1, Unit val2)
Parameters
|
Unit
val1
The first of two units to compare. |
|
Unit
val2
The second of two units to compare. |
Returns
|
Unit
Parameter val1 or val2, whichever is smaller. |
Mm(Double)
Creates a new Unit of type UnitType.Mm and magnitude equal to value.
Declaration
public static Unit Mm(double value)
Parameters
|
System.Double
value
A double value specifying the magnitude of the Unit. |
Returns
|
Unit
The created Unit. |
Mm(Int32)
Creates a new Unit of type UnitType.Mm and magnitude equal to value.
Declaration
public static Unit Mm(int value)
Parameters
|
System.Int32
value
An int value specifying the magnitude of the Unit. |
Returns
|
Unit
The created Unit. |
Multiply(Double)
Multiplies this Unit by a specified value.
Declaration
public Unit Multiply(double value)
Parameters
|
System.Double
value
A double value to multiply by. |
Returns
|
Unit
The product of multiplying this Unit by the specified value. |
Parse(String)
Parses a string value to create a new Unit.
Declaration
public static Unit Parse(string value)
Parameters
|
System.String
value
A string value defining the unit. |
Returns
|
Unit
The created Unit. |
Remarks
The parameter passed to this Method should be of the form "2px", "3.4in", "4cm", "2mm", "12.5pt", "4pc", etc. For more information on string representations of units see UnitType.
Parse(String, CultureInfo)
Parses a string value to create a new Unit based on the specified culture.
Declaration
public static Unit Parse(string value, CultureInfo culture)
Parameters
|
System.String
value
A string value defining the unit. |
|
System.Globalization.CultureInfo
culture
The System.Globalization.CultureInfo object defining the rules for the parsing. |
Returns
|
Unit
The created Unit. |
Remarks
The parameter passed to this Method should be of the form "2px", "3.4in", "4cm", "2mm", "12.5pt", "4pc", etc. For more information on string representations of units see UnitType.
Pica(Double)
Creates a new Unit of type UnitType.Pica and magnitude equal to value.
Declaration
public static Unit Pica(double value)
Parameters
|
System.Double
value
A double value specifying the magnitude of the Unit. |
Returns
|
Unit
The created Unit. |
Pica(Int32)
Creates a new Unit of type UnitType.Pica and magnitude equal to value.
Declaration
public static Unit Pica(int value)
Parameters
|
System.Int32
value
An int value specifying the magnitude of the Unit. |
Returns
|
Unit
The created Unit. |
Pixel(Double)
Creates a new Unit of type UnitType.Pixel and magnitude equal to value in device-independent pixels.
Declaration
public static Unit Pixel(double dips)
Parameters
|
System.Double
dips
A double value specifying the magnitude of the Unit in device-independent pixels (96 DPI pixels or dips). |
Returns
|
Unit
The created Unit. |
Pixel(Int32)
Creates a new Unit of type UnitType.Pixel and magnitude equal to value in device-independent pixels.
Declaration
public static Unit Pixel(int dips)
Parameters
|
System.Int32
dips
An int value specifying the magnitude of the Unit in device-independent pixels (96 DPI pixels or dips). |
Returns
|
Unit
The created Unit. |
Point(Double)
Creates a new Unit of type UnitType.Point and magnitude equal to value.
Declaration
public static Unit Point(double value)
Parameters
|
System.Double
value
A double value specifying the magnitude of the Unit. |
Returns
|
Unit
The created Unit. |
Point(Int32)
Creates a new Unit of type UnitType.Point and magnitude equal to value.
Declaration
public static Unit Point(int value)
Parameters
|
System.Int32
value
An int value specifying the magnitude of the Unit. |
Returns
|
Unit
The created Unit. |
Subtract(Unit)
Subtracts a unit from this Unit.
Declaration
public Unit Subtract(Unit unit1)
Parameters
|
Unit
unit1
The Unit to subtract. |
Returns
|
Unit
The difference of this Unit and unit1 in this Unit's type. |
Subtract(Unit, Unit)
Returns a Unit that is the difference of two units and is of the specified type.
Declaration
public static Unit Subtract(Unit unit1, Unit unit2)
Parameters
|
Unit
unit1
The Unit to subtract from. |
|
Unit
unit2
The Unit to subtract. |
Returns
|
Unit
The difference of the two units in the unit type of the first argument unit. |
Subtract(Unit, Unit, UnitType)
Returns a Unit that is the difference of two units and is of the specified type.
Declaration
[Obsolete("Use Telerik.Reporting.Drawing.Subtract(Unit, Unit) and Telerik.Reporting.Drawing.ChangeType(UnitType) instead.")]
public static Unit Subtract(Unit unit1, Unit unit2, UnitType type)
Parameters
|
Unit
unit1
The Unit to subtract from. |
|
Unit
unit2
The Unit to subtract. |
|
UnitType
type
A UnitType specifying the type of the resultant unit. |
Returns
|
Unit
The difference of the two units in the specified unit type. |
ToString()
Returns a human-readable representation of this Unit.
Declaration
public override string ToString()
Returns
|
System.String
A human-readable representation of this Unit. |
Overrides
ToString(CultureInfo)
Returns a human-readable representation of this Unit.
Declaration
public string ToString(CultureInfo culture)
Parameters
|
System.Globalization.CultureInfo
culture
A System.Globalization.CultureInfo specifying the culture to use. |
Returns
|
System.String
A human-readable representation of this Unit. |
Operators
Addition(Unit, Unit)
Adds one Unit to another.
Declaration
public static Unit operator +(Unit unit1, Unit unit2)
Parameters
|
Unit
unit1
The first Unit. |
|
Unit
unit2
The second Unit. |
Returns
|
Unit
The sum of the two units. |
Remarks
If unit1 is empty the method returns unit2. If unit2 is empty the method returns unit1. Otherwise, the method returns the sum of the two units in unit1's type.
Division(Unit, Double)
Divides a Unit by a specified value.
Declaration
public static Unit operator /(Unit unit1, double value)
Parameters
|
Unit
unit1
The Unit to divide. |
|
System.Double
value
A double value to divide by. |
Returns
|
Unit
A Unit that is the quotient of unit1 and value. |
Division(Unit, Unit)
Divides the first Unit by the second.
Declaration
public static float operator /(Unit unit1, Unit unit2)
Parameters
|
Unit
unit1
A Unit to divide. |
|
Unit
unit2
A Unit to divide by. |
Returns
|
System.Single
The quotient resulting by dividing of two Units. |
Equality(Unit, Unit)
Compares two units.
Declaration
public static bool operator ==(Unit unit1, Unit unit2)
Parameters
|
Unit
unit1
The first unit to compare. |
|
Unit
unit2
The second unit to compare. |
Returns
|
System.Boolean
true if unit1 is equal to unit2; otherwise false. |
GreaterThan(Unit, Unit)
Compares two units.
Declaration
public static bool operator>(Unit unit1, Unit unit2)
Parameters
|
Unit
unit1
The first unit to compare. |
|
Unit
unit2
The second unit to compare. |
Returns
|
System.Boolean
true if unit1 is greater than unit2; otherwise false. |
GreaterThanOrEqual(Unit, Unit)
Compares two units.
Declaration
public static bool operator >=(Unit unit1, Unit unit2)
Parameters
|
Unit
unit1
The first unit to compare. |
|
Unit
unit2
The second unit to compare. |
Returns
|
System.Boolean
true if unit1 is greater than or equal to unit2; otherwise false. |
Inequality(Unit, Unit)
Compares two units.
Declaration
public static bool operator !=(Unit unit1, Unit unit2)
Parameters
|
Unit
unit1
The first unit to compare. |
|
Unit
unit2
The second unit to compare. |
Returns
|
System.Boolean
true if unit1 is not equal to unit2; otherwise false. |
LessThan(Unit, Unit)
Compares two units.
Declaration
public static bool operator <(Unit unit1, Unit unit2)
Parameters
|
Unit
unit1
The first unit to compare. |
|
Unit
unit2
The second unit to compare. |
Returns
|
System.Boolean
true if unit1 is less than unit2; otherwise false. |
LessThanOrEqual(Unit, Unit)
Compares two units.
Declaration
public static bool operator <=(Unit unit1, Unit unit2)
Parameters
|
Unit
unit1
The first unit to compare. |
|
Unit
unit2
The second unit to compare. |
Returns
|
System.Boolean
true if unit1 is less than or equal to unit2; otherwise false. |
Multiply(Double, Unit)
Multiplies a value by a Unit.
Declaration
public static Unit operator *(double value, Unit unit1)
Parameters
|
System.Double
value
The double value to multiply. |
|
Unit
unit1
The Unit to multiply by. |
Returns
|
Unit
A Unit that is the product of value and unit1. |
Multiply(Unit, Double)
Multiplies a Unit by a specified value.
Declaration
public static Unit operator *(Unit unit1, double value)
Parameters
|
Unit
unit1
The Unit to multiply. |
|
System.Double
value
A double value to multiply by. |
Returns
|
Unit
The product of unit1 and value. |
Subtraction(Unit, Unit)
Subtract one Unit from another.
Declaration
public static Unit operator -(Unit unit1, Unit unit2)
Parameters
|
Unit
unit1
The Unit to subtract from. |
|
Unit
unit2
The Unit to subtract. |
Returns
|
Unit
The difference of the two units. |
Remarks
If unit2 is empty the method returns unit1. Otherwise, the method returns the difference of the two units in unit1's type.
Exceptions
|
System.ArgumentException
Thrown when unit1 is empty. |