Table of Contents

Class Dimension

Namespace
System.Drawing
Assembly
iTextSharp.LGPLv2.Core.dll

The Dimension class encapsulates the width and height of a component (in int precision) in a single object.

public class Dimension : Dimension2D, ICloneable
Inheritance
Dimension
Implements
Inherited Members

Remarks

The class is associated with certain properties of components. Several methods defined by the Component class and the LayoutManager interface return a Dimension object. Normally the values of width and height are non-negative ints. The constructors that allow you to create a dimension do not prevent you from setting a negative value for these properties. If the value of width or height is negative, the behavior of some methods defined by other objects is undefined.

Constructors

Dimension()

Creates an instance of Dimension with a width of zero and a height of zero.

public Dimension()

Dimension(Dimension)

Creates an instance of Dimension whose width and height are the same as for the specified dimension.

public Dimension(Dimension d)

Parameters

d Dimension

the specified dimension for the width and height values.

Dimension(int, int)

Constructs a Dimension and initializes it to the specified width and specified height.

public Dimension(int width, int height)

Parameters

width int

the specified width dimension

height int

the specified height dimension

Properties

Height

Returns the height of this dimension in double precision.

public override double Height { get; }

Property Value

double

the height

Size

Get/set the size of this Dimension object.

public Dimension Size { get; set; }

Property Value

Dimension

the size

Width

Returns the width of this dimension in double precision.

public override double Width { get; }

Property Value

double

the width

height

The height dimension. Negative values can be used.

public int height { get; set; }

Property Value

int

width

The width dimension. Negative values can be used.

public int width { get; set; }

Property Value

int

Methods

Equals(object)

Checks whether two dimension objects have equal values.

public override bool Equals(object obj)

Parameters

obj object

Returns

bool

GetHashCode()

Returns the hash code for this Dimension.

public override int GetHashCode()

Returns

int

a hash code

SetSize(double, double)

Set the size of this Dimension object to the specified width and height in double precision.

public override void SetSize(double width, double height)

Parameters

width double

the new width for the Dimension object

height double

the new height for the Dimension object

SetSize(int, int)

Set the size of this Dimension object to the specified width and height.

public void SetSize(int width, int height)

Parameters

width int

the new width for this Dimension object.

height int

the new height for this Dimension object.

ToString()

Returns a string representation of the values of this Dimension object's height and width fields.

public override string ToString()

Returns

string

a string representation of this Dimension object.

Remarks

This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null .