Table of Contents

Struct LayoutSize

Namespace
SharpConsoleUI.Layout
Assembly
SharpConsoleUI.dll

Represents a size with width and height dimensions. Immutable value type for layout calculations. Named LayoutSize to avoid conflicts with System.Drawing.Size during transition.

public readonly record struct LayoutSize : IEquatable<LayoutSize>
Implements
Inherited Members

Constructors

LayoutSize(int, int)

Represents a size with width and height dimensions. Immutable value type for layout calculations. Named LayoutSize to avoid conflicts with System.Drawing.Size during transition.

public LayoutSize(int Width, int Height)

Parameters

Width int
Height int

Properties

Height

public int Height { get; init; }

Property Value

int

Infinite

Gets a size with maximum possible dimensions.

public static LayoutSize Infinite { get; }

Property Value

LayoutSize

IsEmpty

Gets whether this size has zero area.

public bool IsEmpty { get; }

Property Value

bool

Width

public int Width { get; init; }

Property Value

int

Zero

Gets a size with zero width and height.

public static LayoutSize Zero { get; }

Property Value

LayoutSize

Methods

Clamp(LayoutSize, LayoutSize)

Returns a new size clamped between minimum and maximum bounds.

public LayoutSize Clamp(LayoutSize min, LayoutSize max)

Parameters

min LayoutSize
max LayoutSize

Returns

LayoutSize

Constrain(LayoutSize)

Returns a new size with both dimensions constrained to the specified size.

public LayoutSize Constrain(LayoutSize max)

Parameters

max LayoutSize

Returns

LayoutSize

Constrain(int, int)

Returns a new size with both dimensions constrained to the specified maximums.

public LayoutSize Constrain(int maxWidth, int maxHeight)

Parameters

maxWidth int
maxHeight int

Returns

LayoutSize

Expand(LayoutSize)

Returns a new size expanded to at least the specified size.

public LayoutSize Expand(LayoutSize min)

Parameters

min LayoutSize

Returns

LayoutSize

Expand(int, int)

Returns a new size expanded to at least the specified minimums.

public LayoutSize Expand(int minWidth, int minHeight)

Parameters

minWidth int
minHeight int

Returns

LayoutSize

FromDrawingSize(Size)

Creates from System.Drawing.Size.

public static LayoutSize FromDrawingSize(Size size)

Parameters

size Size

Returns

LayoutSize

ToDrawingSize()

Converts to System.Drawing.Size.

public Size ToDrawingSize()

Returns

Size

ToString()

Returns a string representation of this size.

public override string ToString()

Returns

string

WithMaxHeight(int)

Returns a new size with the height constrained to the specified maximum.

public LayoutSize WithMaxHeight(int maxHeight)

Parameters

maxHeight int

Returns

LayoutSize

WithMaxWidth(int)

Returns a new size with the width constrained to the specified maximum.

public LayoutSize WithMaxWidth(int maxWidth)

Parameters

maxWidth int

Returns

LayoutSize