Table of Contents

Struct Thickness

Namespace
Icy.UI
Assembly
IcyUI.dll

Represents the same base struct for both paddings and margins.

[DataContract]
[Serializable]
public struct Thickness : IEquatable<Thickness>, IFormattable, IParsable<Thickness>, IEqualityOperators<Thickness, Thickness, bool>, IAdditionOperators<Thickness, Thickness, Thickness>, ISubtractionOperators<Thickness, Thickness, Thickness>
Implements
Inherited Members
Extension Methods

Constructors

Thickness(int)

Initializes a new instance of the Thickness struct with uniform sides.

public Thickness(int uniform)

Parameters

uniform int

Value of one side.

Thickness(int, int)

Initializes a new instance of the Thickness struct from the horizontal and vertical components.

public Thickness(int horizontal, int vertical)

Parameters

horizontal int

Uniform horizontal value.

vertical int

Uniform vertical value.

Thickness(int, int, int, int)

Initializes a new instance of the Thickness struct with all components.

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

Parameters

left int

Left side.

top int

Top side.

right int

Right side.

bottom int

Bottom side.

Fields

Bottom

The bottom side of the thickness.

public int Bottom

Field Value

int

DefaultFormat

Default format to convert the thickness.

public const string DefaultFormat = "left top right bottom"

Field Value

string

Left

The left side of the thickness.

public int Left

Field Value

int

Right

The right side of the thickness.

public int Right

Field Value

int

Top

The top side of the thickness.

public int Top

Field Value

int

Zero

The zero (default) thickness.

public static readonly Thickness Zero

Field Value

Thickness

Properties

Height

Gets total height of the thickness.

[JsonIgnore]
public readonly int Height { get; }

Property Value

int

IsUniform

Gets a value indicating whether the thickness is uniform (all sides are equal).

[JsonIgnore]
public readonly bool IsUniform { get; }

Property Value

bool

Width

Gets total width of the thickness.

[JsonIgnore]
public readonly int Width { get; }

Property Value

int

Methods

Equals(Thickness)

Indicates whether the current object is equal to another object of the same type.

public readonly bool Equals(Thickness other)

Parameters

other Thickness

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override readonly bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

GetHashCode()

Returns the hash code for this instance.

public override readonly int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

Parse(string, IFormatProvider?)

Parses a string into a value.

public static Thickness Parse(string s, IFormatProvider? provider)

Parameters

s string

The string to parse.

provider IFormatProvider

An object that provides culture-specific formatting information about s.

Returns

Thickness

The result of parsing s.

Exceptions

ArgumentNullException

s is null.

FormatException

s is not in the correct format.

OverflowException

s is not representable by TSelf.

ToString()

Returns the fully qualified type name of this instance.

public override readonly string ToString()

Returns

string

The fully qualified type name.

ToString(string?, IFormatProvider?)

Formats the value of the current instance using the specified format.

public readonly string ToString(string? format, IFormatProvider? formatProvider)

Parameters

format string

The format to use.

-or-

A null reference (Nothing in Visual Basic) to use the default format defined for the type of the IFormattable implementation.

formatProvider IFormatProvider

The provider to use to format the value.

-or-

A null reference (Nothing in Visual Basic) to obtain the numeric format information from the current locale setting of the operating system.

Returns

string

The value of the current instance in the specified format.

TryParse(string?, IFormatProvider?, out Thickness)

Tries to parse a string into a value.

public static bool TryParse(string? s, IFormatProvider? provider, out Thickness result)

Parameters

s string

The string to parse.

provider IFormatProvider

An object that provides culture-specific formatting information about s.

result Thickness

When this method returns, contains the result of successfully parsing s or an undefined value on failure.

Returns

bool

true if s was successfully parsed; otherwise, false.

Operators

operator +(Thickness, Thickness)

Adds two values together to compute their sum.

public static Thickness operator +(Thickness left, Thickness right)

Parameters

left Thickness

The value to which right is added.

right Thickness

The value that is added to left.

Returns

Thickness

The sum of left and right.

operator +(Rectangle, Thickness)

Adds the Thickness to the Rectangle.

public static Rectangle operator +(Rectangle area, Thickness margin)

Parameters

area Rectangle

A Rectangle to add margin.

margin Thickness

A Thickness to apply.

Returns

Rectangle

New rectangle whose size is extended by margin's side values.

operator ==(Thickness, Thickness)

Compares two values to determine equality.

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

Parameters

left Thickness

The value to compare with right.

right Thickness

The value to compare with left.

Returns

bool

true if left is equal to right; otherwise, false.

operator !=(Thickness, Thickness)

Compares two values to determine inequality.

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

Parameters

left Thickness

The value to compare with right.

right Thickness

The value to compare with left.

Returns

bool

true if left is not equal to right; otherwise, false.

operator -(Thickness, Thickness)

Subtracts two values to compute their difference.

public static Thickness operator -(Thickness left, Thickness right)

Parameters

left Thickness

The value from which right is subtracted.

right Thickness

The value that is subtracted from left.

Returns

Thickness

The value of right subtracted from left.

operator -(Rectangle, Thickness)

Subtracts the Thickness from the Rectangle.

public static Rectangle operator -(Rectangle area, Thickness padding)

Parameters

area Rectangle

A Rectangle to subtract padding.

padding Thickness

A Thickness to remove.

Returns

Rectangle

New rectangle whose size is subtracted by padding's side values.

operator -(Thickness)

Computes the unary negation of a value.

public static Thickness operator -(Thickness value)

Parameters

value Thickness

The value for which to compute the unary negation.

Returns

Thickness

The unary negation of value.