Struct
Unit

A structure representing a unit of measure.

Definition

Namespace:Telerik.Reporting.Drawing

Assembly:Telerik.Reporting.dll

Syntax:

cs-api-definition
[TypeConverter(typeof(UnitConverter))]
public struct 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

cs-api-definition
public Unit(double dips)

Parameters

dips

double

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

cs-api-definition
public Unit(double value, UnitType type)

Parameters

value

double

A double value representing the magnitude of the Unit.

type

UnitType

A UnitType specifying the type of the Unit.

Unit(string)

Initializes a new instance of the Unit structure from the specified string value.

Declaration

cs-api-definition
public Unit(string value)

Parameters

value

string

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 CultureInfo.

Declaration

cs-api-definition
public Unit(string value, CultureInfo culture)

Parameters

value

string

A string value representing the magnitude and type of the Unit.

culture

CultureInfo

A 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

cs-api-definition
public Unit(string value, CultureInfo culture, UnitType type)

Parameters

value

string

A string value representing the magnitude of the Unit.

culture

CultureInfo

A CultureInfo. If a null reference (Nothing in Visual Basic) is passed, the current culture is assumed.

type

UnitType

A UnitType specifying the type of the Unit.

Fields

Empty

Initializes a new instance of the Unit structure.

Declaration

cs-api-definition
public static readonly Unit Empty

Field Value

Unit

Zero

Initializes a new instance of the Unit structure equal to zero.

Declaration

cs-api-definition
public static readonly Unit Zero

Field Value

Unit

Properties

DefaultType

Gets or sets a UnitType representing the default units of measure for a Report.

Declaration

cs-api-definition
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

cs-api-definition
public static double DotsPerInch { get; }

Property Value

double

A double value representing the DPI of the current graphics context.

IsEmpty

Specifies whether this Unit structure is uninitialized.

Declaration

cs-api-definition
[Browsable(false)]
public bool IsEmpty { get; }

Property Value

bool

This property returns true if this unit is uninitialized; otherwise, false.

Type

Gets the type of the Unit.

Declaration

cs-api-definition
[Browsable(false)]
public UnitType Type { get; }

Property Value

UnitType

A UnitType specifying the type of this Unit.

Value

Gets the magnitude of this Unit.

Declaration

cs-api-definition
[Browsable(false)]
public float Value { get; }

Property Value

float

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

cs-api-definition
public Unit Add(Unit unit1)

Parameters

unit1

Unit

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

cs-api-definition
public static Unit Add(Unit unit1, Unit unit2)

Parameters

unit1

Unit

The first Unit.

unit2

Unit

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

cs-api-definition
[Obsolete("Use Add(unit1, unit2) and ChangeType(type) instead.")]
public static Unit Add(Unit unit1, Unit unit2, UnitType type)

Parameters

unit1

Unit

The first Unit.

unit2

Unit

The second Unit.

type

UnitType

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

cs-api-definition
public Unit ChangeType(UnitType type)

Parameters

type

UnitType

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

cs-api-definition
public static Unit Cm(double value)

Parameters

value

double

A double value specifying the magnitude of the Unit.

Returns

Unit

The created Unit.

Cm(int)

Creates a new Unit of type UnitType.Cm and magnitude equal to value.

Declaration

cs-api-definition
public static Unit Cm(int value)

Parameters

value

int

An int value specifying the magnitude of the Unit.

Returns

Unit

The created Unit.

CompareTo(Unit)

Internal use only

Declaration

cs-api-definition
public int CompareTo(Unit value)

Parameters

value

Unit

Returns

int

CompareTo(object)

Internal use only

Declaration

cs-api-definition
public int CompareTo(object value)

Parameters

value

object

Returns

int

Divide(Unit)

Divides this Unit by another.

Declaration

cs-api-definition
public float Divide(Unit value)

Parameters

value

Unit

A Unit value to divide by.

Returns

float

The quotient resulting by dividing this Unit by the specified Unit.

Divide(double)

Divides this Unit by a specified value.

Declaration

cs-api-definition
public Unit Divide(double value)

Parameters

value

double

A double value to divide by.

Returns

Unit

The quotient resulting by dividing this Unit by the specified value.

Equals(object)

Tests whether obj is a Unit that equals this Unit.

Declaration

cs-api-definition
public override bool Equals(object obj)

Parameters

obj

object

The object to test.

Returns

bool

This method returns true if obj is a Unit and its magnitude is equal to this Unit's magnitude; otherwise false.

Overrides ValueType.Equals(object)

FromDips(double, UnitType)

Creates a unit from device-independent pixels in the specified unit type.

Declaration

cs-api-definition
public static Unit FromDips(double dips, UnitType resultType)

Parameters

dips

double

The magnitude of the new Unit in device-independent pixels.

resultType

UnitType

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

cs-api-definition
public static Unit FromPixels(double devicePixels, UnitType resultType)

Parameters

devicePixels

double

The magnitude of the new Unit in device-dependent pixels.

resultType

UnitType

The unit type of the newly created Unit

Returns

Unit

Newly created Unit

GetHashCode()

Returns a hash code for this Unit structure.

Declaration

cs-api-definition
public override int GetHashCode()

Returns

int

An integer value that specifies a hash value for this Unit structure.

Overrides ValueType.GetHashCode()

Inch(double)

Creates a new Unit of type UnitType.Inch and magnitude equal to value.

Declaration

cs-api-definition
public static Unit Inch(double value)

Parameters

value

double

A double value specifying the magnitude of the Unit.

Returns

Unit

The created Unit.

Inch(int)

Creates a new Unit of type UnitType.Inch and magnitude equal to value.

Declaration

cs-api-definition
public static Unit Inch(int value)

Parameters

value

int

An int value specifying the magnitude of the Unit.

Returns

Unit

The created Unit.

Max(Unit, Unit)

Returns the larger of two units.

Declaration

cs-api-definition
public static Unit Max(Unit val1, Unit val2)

Parameters

val1

Unit

The first of two units to compare.

val2

Unit

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

cs-api-definition
public static Unit Min(Unit val1, Unit val2)

Parameters

val1

Unit

The first of two units to compare.

val2

Unit

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

cs-api-definition
public static Unit Mm(double value)

Parameters

value

double

A double value specifying the magnitude of the Unit.

Returns

Unit

The created Unit.

Mm(int)

Creates a new Unit of type UnitType.Mm and magnitude equal to value.

Declaration

cs-api-definition
public static Unit Mm(int value)

Parameters

value

int

An int value specifying the magnitude of the Unit.

Returns

Unit

The created Unit.

Multiply(double)

Multiplies this Unit by a specified value.

Declaration

cs-api-definition
public Unit Multiply(double value)

Parameters

value

double

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

cs-api-definition
public static Unit Parse(string value)

Parameters

value

string

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

cs-api-definition
public static Unit Parse(string value, CultureInfo culture)

Parameters

value

string

A string value defining the unit.

culture

CultureInfo

The 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

cs-api-definition
public static Unit Pica(double value)

Parameters

value

double

A double value specifying the magnitude of the Unit.

Returns

Unit

The created Unit.

Pica(int)

Creates a new Unit of type UnitType.Pica and magnitude equal to value.

Declaration

cs-api-definition
public static Unit Pica(int value)

Parameters

value

int

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

cs-api-definition
public static Unit Pixel(double dips)

Parameters

dips

double

A double value specifying the magnitude of the Unit in device-independent pixels (96 DPI pixels or dips).

Returns

Unit

The created Unit.

Pixel(int)

Creates a new Unit of type UnitType.Pixel and magnitude equal to value in device-independent pixels.

Declaration

cs-api-definition
public static Unit Pixel(int dips)

Parameters

dips

int

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

cs-api-definition
public static Unit Point(double value)

Parameters

value

double

A double value specifying the magnitude of the Unit.

Returns

Unit

The created Unit.

Point(int)

Creates a new Unit of type UnitType.Point and magnitude equal to value.

Declaration

cs-api-definition
public static Unit Point(int value)

Parameters

value

int

An int value specifying the magnitude of the Unit.

Returns

Unit

The created Unit.

Subtract(Unit)

Subtracts a unit from this Unit.

Declaration

cs-api-definition
public Unit Subtract(Unit unit1)

Parameters

unit1

Unit

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

cs-api-definition
public static Unit Subtract(Unit unit1, Unit unit2)

Parameters

unit1

Unit

The Unit to subtract from.

unit2

Unit

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

cs-api-definition
[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

unit1

Unit

The Unit to subtract from.

unit2

Unit

The Unit to subtract.

type

UnitType

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

cs-api-definition
public override string ToString()

Returns

string

A human-readable representation of this Unit.

Overrides ValueType.ToString()

ToString(CultureInfo)

Returns a human-readable representation of this Unit.

Declaration

cs-api-definition
public string ToString(CultureInfo culture)

Parameters

culture

CultureInfo

A CultureInfo specifying the culture to use.

Returns

string

A human-readable representation of this Unit.

Operators

operator !=(Unit, Unit)

Compares two units.

Declaration

cs-api-definition
public static bool operator !=(Unit unit1, Unit unit2)

Parameters

unit1

Unit

The first unit to compare.

unit2

Unit

The second unit to compare.

Returns

bool

true if unit1 is not equal to unit2; otherwise false.

operator *(Unit, double)

Multiplies a Unit by a specified value.

Declaration

cs-api-definition
public static Unit operator *(Unit unit1, double value)

Parameters

unit1

Unit

The Unit to multiply.

value

double

A double value to multiply by.

Returns

Unit

The product of unit1 and value.

operator *(double, Unit)

Multiplies a value by a Unit.

Declaration

cs-api-definition
public static Unit operator *(double value, Unit unit1)

Parameters

value

double

The double value to multiply.

unit1

Unit

The Unit to multiply by.

Returns

Unit

A Unit that is the product of value and unit1.

operator +(Unit, Unit)

Adds one Unit to another.

Declaration

cs-api-definition
public static Unit operator +(Unit unit1, Unit unit2)

Parameters

unit1

Unit

The first Unit.

unit2

Unit

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.

operator -(Unit)

Unary minus. Reverses the sign of Unit

Declaration

cs-api-definition
public static Unit operator -(Unit unit)

Parameters

unit

Unit

The unit to negate.

Returns

Unit

A Unit of the same type as unit but with opposite sign.

operator -(Unit, Unit)

Subtract one Unit from another.

Declaration

cs-api-definition
public static Unit operator -(Unit unit1, Unit unit2)

Parameters

unit1

Unit

The Unit to subtract from.

unit2

Unit

The Unit to subtract.

Returns

Unit

The difference of the two units.

Exceptions

ArgumentException

Thrown when unit1 is empty.

Remarks

If unit2 is empty the method returns unit1. Otherwise, the method returns the difference of the two units in unit1's type.

operator /(Unit, Unit)

Divides the first Unit by the second.

Declaration

cs-api-definition
public static float operator /(Unit unit1, Unit unit2)

Parameters

unit1

Unit

A Unit to divide.

unit2

Unit

A Unit to divide by.

Returns

float

The quotient resulting by dividing of two Units.

operator /(Unit, double)

Divides a Unit by a specified value.

Declaration

cs-api-definition
public static Unit operator /(Unit unit1, double value)

Parameters

unit1

Unit

The Unit to divide.

value

double

A double value to divide by.

Returns

Unit

A Unit that is the quotient of unit1 and value.

operator <(Unit, Unit)

Compares two units.

Declaration

cs-api-definition
public static bool operator <(Unit unit1, Unit unit2)

Parameters

unit1

Unit

The first unit to compare.

unit2

Unit

The second unit to compare.

Returns

bool

true if unit1 is less than unit2; otherwise false.

operator <=(Unit, Unit)

Compares two units.

Declaration

cs-api-definition
public static bool operator <=(Unit unit1, Unit unit2)

Parameters

unit1

Unit

The first unit to compare.

unit2

Unit

The second unit to compare.

Returns

bool

true if unit1 is less than or equal to unit2; otherwise false.

operator ==(Unit, Unit)

Compares two units.

Declaration

cs-api-definition
public static bool operator ==(Unit unit1, Unit unit2)

Parameters

unit1

Unit

The first unit to compare.

unit2

Unit

The second unit to compare.

Returns

bool

true if unit1 is equal to unit2; otherwise false.

operator >(Unit, Unit)

Compares two units.

Declaration

cs-api-definition
public static bool operator >(Unit unit1, Unit unit2)

Parameters

unit1

Unit

The first unit to compare.

unit2

Unit

The second unit to compare.

Returns

bool

true if unit1 is greater than unit2; otherwise false.

operator >=(Unit, Unit)

Compares two units.

Declaration

cs-api-definition
public static bool operator >=(Unit unit1, Unit unit2)

Parameters

unit1

Unit

The first unit to compare.

unit2

Unit

The second unit to compare.

Returns

bool

true if unit1 is greater than or equal to unit2; otherwise false.