Table of Contents

Struct Margin

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

A Margin represents a band of space outside or inside a rectangular area, with possibly different values on each of the four sides.

public struct Margin
Inherited Members

Remarks

Example uses include Margin, Padding, and Padding.

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

Constructors

Margin(double)

Create a Margin with all four sides using the same number.

public Margin(double s = 0)

Parameters

s double

the margin for all four sides, defaults to 0

Margin(double, double)

Create a Margin with the top and bottom getting the first parameter and the left and right getting the second.

public Margin(double tb, double rl)

Parameters

tb double

the margin for the top and bottom sides

rl double

the margin for the right and left sides

Margin(double, double, double, double)

Create a Margin with each side getting the corresponding parameter in the order top, right, bottom, left.

public Margin(double t, double r, double b, double l)

Parameters

t double

the margin for the top side

r double

the margin for the right side

b double

the margin for the bottom side

l double

the margin for the left side

Properties

Bottom

Gets or sets the bottom value of this margin. Default is 0.

public double Bottom { readonly get; set; }

Property Value

double

Left

Gets or sets the left value of this margin. Default is 0.

public double Left { readonly get; set; }

Property Value

double

Right

Gets or sets the right value of this margin. Default is 0.

public double Right { readonly get; set; }

Property Value

double

Top

Gets or sets the top value of this margin. Default is 0.

public double Top { readonly get; set; }

Property Value

double

Methods

Equals(double, double, double, double)

Indicates whether the given Margin is equal to this Margin.

public bool Equals(double t, double r, double b, double l)

Parameters

t double

top.

r double

right.

b double

bottom.

l double

left.

Returns

bool

True if the two Margins have identical Top and Right and Bottom and Left values, false otherwise.

See Also

Equals(object)

Indicates whether the given Margin is equal to this Margin.

public override bool Equals(object obj)

Parameters

obj object

The Margin to compare to the current Margin.

Returns

bool

True if the two Margins have identical Top and Right and Bottom and Left values, false otherwise.

See Also

EqualsApprox(Margin)

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

public bool EqualsApprox(Margin m)

Parameters

m Margin

The Margin to compare to the current Margin.

Returns

bool

True if the two Margins have Top, Right, Bottom and Left values within 0.5, false otherwise.

GetHashCode()

Creates a hash code for the margin.

public override int GetHashCode()

Returns

int

A hash code for the current margin structure.

IsReal()

True if this Margin has 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 Margin from a string that was produced by Stringify(Margin).

public static Margin Parse(string str)

Parameters

str string

Returns

Margin

Remarks

Margin.Parse("1 2 3 4") produces the Margin new Margin(1, 2, 3, 4). This function will throw an error on invalid strings.

Stringify(Margin)

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

public static string Stringify(Margin val)

Parameters

val Margin

Returns

string

Remarks

Margin.Stringify(new Margin(1, 2, 3, 4)) produces the string "1 2 3 4".

Stringify(object)

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

public static object Stringify(object marg)

Parameters

marg object

Returns

object

StringifyFixed(Margin, int)

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

public static string StringifyFixed(Margin val, int digits)

Parameters

val Margin

the Margin

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(Margin, int) that can be used as a BackConverter. This convenience method uses two decimal places.

public static object StringifyFixed(object marg)

Parameters

marg object

Returns

object

ToString()

Returns a string representation of the margin.

public override string ToString()

Returns

string

A string representation of the current margin.

Operators

operator ==(Margin, Margin)

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

Parameters

left Margin
right Margin

Returns

bool

implicit operator Margin(double)

public static implicit operator Margin(double d)

Parameters

d double

Returns

Margin

implicit operator Margin(int)

public static implicit operator Margin(int d)

Parameters

d int

Returns

Margin

operator !=(Margin, Margin)

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

Parameters

left Margin
right Margin

Returns

bool