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
uniformintValue 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
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
Fields
Bottom
The bottom side of the thickness.
public int Bottom
Field Value
DefaultFormat
Default format to convert the thickness.
public const string DefaultFormat = "left top right bottom"
Field Value
Left
The left side of the thickness.
public int Left
Field Value
Right
The right side of the thickness.
public int Right
Field Value
Top
The top side of the thickness.
public int Top
Field Value
Zero
The zero (default) thickness.
public static readonly Thickness Zero
Field Value
Properties
Height
Gets total height of the thickness.
[JsonIgnore]
public readonly int Height { get; }
Property Value
IsUniform
Gets a value indicating whether the thickness is uniform (all sides are equal).
[JsonIgnore]
public readonly bool IsUniform { get; }
Property Value
Width
Gets total width of the thickness.
[JsonIgnore]
public readonly int Width { get; }
Property Value
Methods
Equals(Thickness)
Indicates whether the current object is equal to another object of the same type.
public readonly bool Equals(Thickness other)
Parameters
otherThicknessAn object to compare with this object.
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override readonly bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand 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
sstringThe string to parse.
providerIFormatProviderAn object that provides culture-specific formatting information about
s.
Returns
- Thickness
The result of parsing
s.
Exceptions
- ArgumentNullException
sis null.- FormatException
sis not in the correct format.- OverflowException
sis not representable byTSelf.
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
formatstringThe format to use.
-or-
A null reference (
Nothingin Visual Basic) to use the default format defined for the type of the IFormattable implementation.formatProviderIFormatProviderThe provider to use to format the value.
-or-
A null reference (
Nothingin 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
sstringThe string to parse.
providerIFormatProviderAn object that provides culture-specific formatting information about
s.resultThicknessWhen this method returns, contains the result of successfully parsing
sor an undefined value on failure.
Returns
Operators
operator +(Thickness, Thickness)
Adds two values together to compute their sum.
public static Thickness operator +(Thickness left, Thickness right)
Parameters
Returns
- Thickness
The sum of
leftandright.
operator +(Rectangle, Thickness)
public static Rectangle operator +(Rectangle area, Thickness margin)
Parameters
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
Returns
operator !=(Thickness, Thickness)
Compares two values to determine inequality.
public static bool operator !=(Thickness left, Thickness right)
Parameters
Returns
operator -(Thickness, Thickness)
Subtracts two values to compute their difference.
public static Thickness operator -(Thickness left, Thickness right)
Parameters
leftThicknessThe value from which
rightis subtracted.rightThicknessThe value that is subtracted from
left.
Returns
- Thickness
The value of
rightsubtracted fromleft.
operator -(Rectangle, Thickness)
public static Rectangle operator -(Rectangle area, Thickness padding)
Parameters
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
valueThicknessThe value for which to compute the unary negation.
Returns
- Thickness
The unary negation of
value.