Table of Contents

Struct Size

Namespace
Northwoods.Go
Assembly
Northwoods.GoDiagram.WinForms.dll

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

public struct Size
Inherited Members

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.

public Size(double w = 0, double h = 0)

Parameters

w double

The initial width (must be non-negative).

h double

The initial height (must be non-negative).

Properties

Height

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

public double Height { get; set; }

Property Value

double

Width

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

public double Width { get; set; }

Property Value

double

Methods

Equals(double, double)

Indicates whether the given size is equal to this Size.

public bool Equals(double w, double h)

Parameters

w double

the width.

h double

the height.

Returns

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.

public override bool Equals(object obj)

Parameters

obj object

The Size to compare to the current Size.

Returns

bool

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

See Also

EqualsApprox(Size)

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

public bool EqualsApprox(Size s)

Parameters

s Size

The Size to compare to the current Size.

Returns

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.

public override int GetHashCode()

Returns

int

A hash code for the current size structure.

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.

public Size Inflate(double w, double h)

Parameters

w double

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

h double

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

Returns

Size

A new Size.

IsReal()

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

public bool IsReal()

Returns

bool

Parse(object)

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

public static object Parse(object str)

Parameters

str object

Returns

object

Parse(string)

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

public static Size Parse(string str)

Parameters

str string

Returns

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

public static string Stringify(Size val)

Parameters

val Size

Returns

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.

public static object Stringify(object sz)

Parameters

sz object

Returns

object

StringifyFixed(Size, int)

This static method can be used to write out a Size as a string with its numbers at a fixed number of digits after the decimal point.

public static string StringifyFixed(Size val, int digits)

Parameters

val Size

the Size

digits int

the number of decimals to output

Returns

string

Remarks

This is useful for limiting the size of JSON output and making it more legible. It might also be useful for regression testing.

StringifyFixed(object)

This is a convenience method for StringifyFixed(Size, int) that can be used as a BackConverter. This convenience method uses two decimal places.

public static object StringifyFixed(object size)

Parameters

size object

Returns

object

ToString()

Returns a string representation of the size.

public override string ToString()

Returns

string

A string representation of the current size.

Operators

operator ==(Size, Size)

public static bool operator ==(Size left, Size right)

Parameters

left Size
right Size

Returns

bool

operator !=(Size, Size)

public static bool operator !=(Size left, Size right)

Parameters

left Size
right Size

Returns

bool