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
Default
Declaration
public Unit(double dips)
Parameters
System. 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
Unit(String)
Initializes a new instance of the Unit structure from the specified string value.
Declaration
public Unit(string value)
Parameters
System. 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
Unit
Unit(String, CultureInfo)
Initializes a new instance of the
Unit structure from the
specified string value and using the specified
System.
Declaration
public Unit(string value, CultureInfo culture)
Parameters
System. A string value representing the magnitude and type of the Unit. |
System. A System. |
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
Fields
Empty
Initializes a new instance of the Unit structure.
Declaration
public static readonly Unit Empty
Field Value
Zero
Initializes a new instance of the Unit structure equal to zero.
Declaration
public static readonly Unit Zero
Field Value
Properties
DefaultType
Declaration
public static UnitType DefaultType { get; set; }
Property Value
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. 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. 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
Value
Gets the magnitude of this Unit.
Declaration
public float Value { get; }
Property Value
System. 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
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. |
Unit A 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
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. 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. An int value specifying the magnitude of the Unit. |
Returns
Unit
The created Unit. |
CompareTo(Object)
Declaration
public int CompareTo(object value)
Parameters
System.
|
Returns
System.
|
CompareTo(Unit)
Divide(Double)
Divides this Unit by a specified value.
Declaration
public Unit Divide(double value)
Parameters
System. 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. 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. The System. |
Returns
System. 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. The magnitude of the new Unit in device-independent pixels. |
Unit 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. The magnitude of the new Unit in device-dependent pixels. |
Unit 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. 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. 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. 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
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
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. 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. 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. 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. 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
Unit
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. A string value defining the unit. |
System. The System. |
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
Unit
Pica(Double)
Creates a new Unit of type UnitType.Pica and magnitude equal to value.
Declaration
public static Unit Pica(double value)
Parameters
System. 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. 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. 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. 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. 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. 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
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. |
Unit A 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. 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. A System. |
Returns
System. 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
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. 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
Returns
System. The quotient resulting by dividing of two Units. |
Equality(Unit, Unit)
Compares two units.
Declaration
public static bool operator ==(Unit unit1, Unit unit2)
Parameters
Returns
System. 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
Returns
System. 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
Returns
System. 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
Returns
System. 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
Returns
System. 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
Returns
System. 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. 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. 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
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. Thrown when unit1 is empty. |