Table of Contents

Struct Thickness

Namespace
Myra.Graphics2D
Assembly
Myra.dll

Represents the thicknesses of the four sides of a rectangle (left, right, top, bottom).

public struct Thickness
Inherited Members

Constructors

Thickness(int)

Initializes a new instance of the Thickness struct with the same value for all sides.

public Thickness(int value)

Parameters

value int

The thickness for all sides.

Thickness(int, int)

Initializes a new instance of the Thickness struct with separate horizontal and vertical values.

public Thickness(int horizontalValue, int verticalValue)

Parameters

horizontalValue int

The thickness for left and right sides.

verticalValue int

The thickness for top and bottom sides.

Thickness(int, int, int, int)

Initializes a new instance of the Thickness struct with individual values for each side.

public Thickness(int left, int top, int right, int bottom)

Parameters

left int

The left thickness.

top int

The top thickness.

right int

The right thickness.

bottom int

The bottom thickness.

Fields

Zero

Gets a thickness with all values set to zero.

public static readonly Thickness Zero

Field Value

Thickness

Properties

Bottom

Gets or sets the bottom thickness.

[Range(0)]
public int Bottom { get; set; }

Property Value

int

Height

Gets the total vertical thickness (top + bottom).

[Browsable(false)]
public int Height { get; }

Property Value

int

Left

Gets or sets the left thickness.

[Range(0)]
public int Left { get; set; }

Property Value

int

Right

Gets or sets the right thickness.

[Range(0)]
public int Right { get; set; }

Property Value

int

SameSize

Gets a value indicating whether all sides have the same thickness.

[Browsable(false)]
public bool SameSize { get; }

Property Value

bool

Top

Gets or sets the top thickness.

[Range(0)]
public int Top { get; set; }

Property Value

int

Width

Gets the total horizontal thickness (left + right).

[Browsable(false)]
public int Width { get; }

Property Value

int

Methods

Equals(object)

Determines whether the specified object is equal to the current thickness.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with the current thickness.

Returns

bool

True if the specified object is equal to the current thickness; otherwise, false.

FromString(string)

Parses a thickness value from a string.

public static Thickness FromString(string s)

Parameters

s string

The string to parse.

Returns

Thickness

The parsed thickness, or Zero if the string is null or empty.

Remarks

Supported formats: "5" (all sides), "5, 10" (horizontal, vertical), "1, 2, 3, 4" (left, top, right, bottom).

Exceptions

ArgumentException

The string format is invalid.

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

A 32-bit signed integer hash code.

ToString()

Returns a string representation of the thickness.

public override string ToString()

Returns

string

A string representation in the format "value", "h, v", or "l, t, r, b".

Operators

operator ==(Thickness, Thickness)

Determines whether two thickness values are equal.

public static bool operator ==(Thickness a, Thickness b)

Parameters

a Thickness

The first thickness to compare.

b Thickness

The second thickness to compare.

Returns

bool

True if the two thickness values are equal; otherwise, false.

operator !=(Thickness, Thickness)

Determines whether two thickness values are not equal.

public static bool operator !=(Thickness a, Thickness b)

Parameters

a Thickness

The first thickness to compare.

b Thickness

The second thickness to compare.

Returns

bool

True if the two thickness values are not equal; otherwise, false.

operator -(Rectangle, Thickness)

Subtracts the thickness from a rectangle.

public static Rectangle operator -(Rectangle a, Thickness b)

Parameters

a Rectangle

The rectangle to subtract from.

b Thickness

The thickness to subtract.

Returns

Rectangle

A new rectangle with the thickness applied, shrinking the rectangle.