StructUnit
A structure representing a unit of measure.
Definition
Namespace:Telerik.Reporting.Drawing
Assembly:Telerik.Reporting.dll
Syntax:
[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
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.
Unit(string)
Initializes a new instance of the Unit structure from the specified string value.
Declaration
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
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
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
A UnitType specifying the type of the Unit.
Fields
Properties
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
double
A double value representing the DPI of the current graphics context.
IsEmpty
Specifies whether this Unit structure is uninitialized.
Declaration
[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.
Methods
Add(Unit, Unit)
Returns a Unit that is the sum of two units and its unit type matches the first argument type.
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
unit1
The first Unit.
unit2
The second Unit.
type
A UnitType specifying the type of the resultant unit.
Returns
The sum of the two units.
ChangeType(UnitType)
Returns a unit equal by magnitude to this Unit but with its type changed.
Cm(double)
Creates a new Unit of type UnitType.Cm and magnitude equal to value.
Declaration
public static Unit Cm(double value)
Parameters
value
double
A double value specifying the magnitude of the Unit.
Returns
The created Unit.
Cm(int)
Creates a new Unit of type UnitType.Cm and magnitude equal to value.
Declaration
public static Unit Cm(int value)
Parameters
value
int
An int value specifying the magnitude of the Unit.
Returns
The created Unit.
CompareTo(Unit)
Internal use only
CompareTo(object)
Internal use only
Declaration
public int CompareTo(object value)
Parameters
value
object
Returns
int
Divide(Unit)
Divides this Unit by another.
Declaration
public float Divide(Unit value)
Parameters
value
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
public Unit Divide(double value)
Parameters
value
double
A double value to divide by.
Returns
The quotient resulting by dividing this Unit by the specified value.
Equals(object)
Tests whether obj is a Unit that equals this Unit.
Declaration
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
FromDips(double, UnitType)
Creates a unit from device-independent pixels in the specified unit type.
FromPixels(double, UnitType)
Creates a unit from device-dependent pixels in the specified unit type.
GetHashCode()
Returns a hash code for this Unit structure.
Declaration
public override int GetHashCode()
Returns
int
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
value
double
A double value specifying the magnitude of the Unit.
Returns
The created Unit.
Inch(int)
Creates a new Unit of type UnitType.Inch and magnitude equal to value.
Declaration
public static Unit Inch(int value)
Parameters
value
int
An int value specifying the magnitude of the Unit.
Returns
The created Unit.
Max(Unit, Unit)
Returns the larger of two units.
Min(Unit, Unit)
Returns the smaller of two units.
Mm(double)
Creates a new Unit of type UnitType.Mm and magnitude equal to value.
Declaration
public static Unit Mm(double value)
Parameters
value
double
A double value specifying the magnitude of the Unit.
Returns
The created Unit.
Mm(int)
Creates a new Unit of type UnitType.Mm and magnitude equal to value.
Declaration
public static Unit Mm(int value)
Parameters
value
int
An int value specifying the magnitude of the Unit.
Returns
The created Unit.
Multiply(double)
Multiplies this Unit by a specified value.
Declaration
public Unit Multiply(double value)
Parameters
value
double
A double value to multiply by.
Returns
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
value
string
A string value defining the unit.
Returns
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
value
string
A string value defining the unit.
culture
CultureInfo
The CultureInfo object defining the rules for the parsing.
Returns
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
value
double
A double value specifying the magnitude of the Unit.
Returns
The created Unit.
Pica(int)
Creates a new Unit of type UnitType.Pica and magnitude equal to value.
Declaration
public static Unit Pica(int value)
Parameters
value
int
An int value specifying the magnitude of the Unit.
Returns
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
dips
double
A double value specifying the magnitude of the Unit in device-independent pixels (96 DPI pixels or dips).
Returns
The created Unit.
Pixel(int)
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
dips
int
An int value specifying the magnitude of the Unit in device-independent pixels (96 DPI pixels or dips).
Returns
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
value
double
A double value specifying the magnitude of the Unit.
Returns
The created Unit.
Point(int)
Creates a new Unit of type UnitType.Point and magnitude equal to value.
Declaration
public static Unit Point(int value)
Parameters
value
int
An int value specifying the magnitude of the Unit.
Returns
The created Unit.
Subtract(Unit)
Subtracts a unit from this Unit.
Subtract(Unit, Unit)
Returns a Unit that is the difference of two units and is of the specified type.
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
unit1
The Unit to subtract from.
unit2
The Unit to subtract.
type
A UnitType specifying the type of the resultant unit.
Returns
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
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
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.
operator *(Unit, double)
Multiplies a Unit by a specified value.
operator *(double, Unit)
Multiplies a value by a Unit.
operator +(Unit, Unit)
Adds one Unit to another.
Declaration
public static Unit operator +(Unit unit1, Unit unit2)
Parameters
unit1
The first Unit.
unit2
The second Unit.
Returns
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
operator -(Unit, Unit)
Subtract one Unit from another.
Declaration
public static Unit operator -(Unit unit1, Unit unit2)
Parameters
unit1
The Unit to subtract from.
unit2
The Unit to subtract.
Returns
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.
operator /(Unit, double)
Divides a Unit by a specified value.
operator <(Unit, Unit)
Compares two units.
operator <=(Unit, Unit)
Compares two units.
operator ==(Unit, Unit)
Compares two units.
operator >(Unit, Unit)
Compares two units.
operator >=(Unit, Unit)
Compares two units.