Struct Size

GoDiagram®
v10.0.8
by Northwoods Software®

A Size describes a width and a height in two-dimensional coordinates. The width and height must both be non-negative.

Namespace: Northwoods.Go
Assembly: Northwoods.GoDiagram.WinForms.dll
Syntax
public struct Size
Remarks

Use the static functions Parse(string) and Stringify(Size) to convert to and from a standard string representation that is independent of the current locale.

Constructors

Size(double, double)

The default constructor produces the Size(0,0). This constructor may take either zero arguments or two arguments.

Declaration
public Size(double w = 0, double h = 0)
Parameters
Type Name Description
double w

The initial width (must be non-negative).

double h

The initial height (must be non-negative).

Properties

Height

Gets or sets the height value of the Size. The value must not be negative.

Declaration
public double Height { get; set; }
Property Value
Type Description
double

Width

Gets or sets the width value of the Size. The value must not be negative.

Declaration
public double Width { get; set; }
Property Value
Type Description
double

Methods

Equals(double, double)

Indicates whether the given size is equal to this Size.

Declaration
public bool Equals(double w, double h)
Parameters
Type Name Description
double w

the width.

double h

the height.

Returns
Type Description
bool

True if the Sizes have the same width and height, false otherwise.

See Also

Equals(object)

Indicates whether the given Size is equal to the current Size.

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
object obj

The Size to compare to the current Size.

Returns
Type Description
bool

True if the Sizes have the same width and height, false otherwise.

Overrides
See Also

EqualsApprox(Size)

Indicates whether the given Size is nearly equal to this Size.

Declaration
public bool EqualsApprox(Size s)
Parameters
Type Name Description
Size s

The Size to compare to the current Size.

Returns
Type Description
bool

True if the two Sizes have Width and Height values that are equal with a tolerance of 0.5, false otherwise.

GetHashCode()

Creates a hash code for the size.

Declaration
public override int GetHashCode()
Returns
Type Description
int

A hash code for the current size structure.

Overrides

Inflate(double, double)

Returns a new Size that is this Size with its width and height changed by the given distances. When the arguments are negative, this operation deflates this Size, but not beyond zero.

Declaration
public Size Inflate(double w, double h)
Parameters
Type Name Description
double w

The additional width, which must be a real number; may be negative.

double h

The additional height, which must be a real number; may be negative.

Returns
Type Description
Size

A new Size.

IsReal()

True if this Size has Width and Height values that are real numbers and not infinity.

Declaration
public bool IsReal()
Returns
Type Description
bool

Parse(object)

This is a convenience method for Parse(string) that can be used as a Converter.

Declaration
public static object Parse(object str)
Parameters
Type Name Description
object str
Returns
Type Description
object

Parse(string)

This static method can be used to read in a Size from a string that was produced by Stringify(Size).

Declaration
public static Size Parse(string str)
Parameters
Type Name Description
string str
Returns
Type Description
Size
Remarks

Size.Parse("1 2") produces the Size new Size(1, 2).

Stringify(Size)

This static method can be used to write out a Size as a string that can be read by Parse(string).

Declaration
public static string Stringify(Size val)
Parameters
Type Name Description
Size val
Returns
Type Description
string
Remarks

Size.Stringify(new Size(1, 2)) produces the string "1 2".

Stringify(object)

This is a convenience method for Stringify(Size) that can be used as a BackConverter.

Declaration
public static object Stringify(object sz)
Parameters
Type Name Description
object sz
Returns
Type Description
object

ToString()

Returns a string representation of the size.

Declaration
public override string ToString()
Returns
Type Description
string

A string representation of the current size.

Overrides

Operators

operator ==(Size, Size)

Declaration
public static bool operator ==(Size left, Size right)
Parameters
Type Name Description
Size left
Size right
Returns
Type Description
bool

operator !=(Size, Size)

Declaration
public static bool operator !=(Size left, Size right)
Parameters
Type Name Description
Size left
Size right
Returns
Type Description
bool