Table of Contents

Class GridBuilder

Namespace
SharpConsoleUI.Builders
Assembly
SharpConsoleUI.dll

Fluent builder for GridControl. Column and row definitions, gaps, padding, size, alignment, colour role, and child placements are accumulated and applied in Build() in dependency order: track definitions are set first so that placement range-validation in Place(IWindowControl, int, int, int, int) sees the defined tracks, then the deferred Place(IWindowControl, int, int, int, int)/Add(IWindowControl) intents are replayed in the order they were declared.

public sealed class GridBuilder : IControlBuilder<GridControl>
Inheritance
GridBuilder
Implements
Inherited Members
Extension Methods

Methods

Add(IWindowControl)

Appends a child control in row-major auto-flow order. The placement is deferred and applied in Build() after the track definitions are set, in declaration order relative to any interleaved Place(IWindowControl, int, int, int, int) calls.

public GridBuilder Add(IWindowControl control)

Parameters

control IWindowControl

The control to append.

Returns

GridBuilder

The builder for chaining.

Build()

Builds the configured GridControl. Track definitions are applied first so that the deferred Place(IWindowControl, int, int, int, int)/Add(IWindowControl) intents (replayed afterwards, in order) see the defined tracks for range-validation and auto-flow.

public GridControl Build()

Returns

GridControl

The configured control.

ColumnGap(int)

Sets the gap, in cells, between adjacent columns.

public GridBuilder ColumnGap(int gap)

Parameters

gap int

The column gap in cells.

Returns

GridBuilder

The builder for chaining.

ColumnGridlines(bool)

Draws a vertical rule between every adjacent column.

public GridBuilder ColumnGridlines(bool show = true)

Parameters

show bool

Returns

GridBuilder

ColumnSplitterAfter(int)

Makes the boundary after column afterIndex draggable to resize the two columns.

public GridBuilder ColumnSplitterAfter(int afterIndex)

Parameters

afterIndex int

The zero-based index of the column the splitter follows.

Returns

GridBuilder

The builder for chaining.

Columns(params GridLength[])

Adds column track definitions, left to right.

public GridBuilder Columns(params GridLength[] columns)

Parameters

columns GridLength[]

The column lengths (fixed cells, auto-to-content, or star weights).

Returns

GridBuilder

The builder for chaining.

GridlineAfterColumn(int)

Adds a vertical rule at the boundary after column index.

public GridBuilder GridlineAfterColumn(int index)

Parameters

index int

Returns

GridBuilder

GridlineAfterRow(int)

Adds a horizontal rule at the boundary after row index.

public GridBuilder GridlineAfterRow(int index)

Parameters

index int

Returns

GridBuilder

GridlineColor(Color)

Sets an explicit gridline colour (null keeps the role-derived default).

public GridBuilder GridlineColor(Color color)

Parameters

color Color

Returns

GridBuilder

GridlineStyle(BorderStyle)

Sets the gridline box-drawing style (default Single).

public GridBuilder GridlineStyle(BorderStyle style)

Parameters

style BorderStyle

Returns

GridBuilder

Outline(bool)

Renders the grid's role chrome in outline style.

public GridBuilder Outline(bool outline = true)

Parameters

outline bool

Whether to render role chrome as an outline.

Returns

GridBuilder

The builder for chaining.

Place(IWindowControl, int, int, int, int)

Places a child control at the specified cell, with optional row and column spanning. The placement is deferred and applied in Build() after the track definitions are set so range-validation succeeds.

public GridBuilder Place(IWindowControl control, int row, int col, int rowSpan = 1, int colSpan = 1)

Parameters

control IWindowControl

The control to place.

row int

The zero-based row index of the cell's top-left corner.

col int

The zero-based column index of the cell's top-left corner.

rowSpan int

The number of rows the cell occupies. Must be at least 1.

colSpan int

The number of columns the cell occupies. Must be at least 1.

Returns

GridBuilder

The builder for chaining.

RowGap(int)

Sets the gap, in cells, between adjacent rows.

public GridBuilder RowGap(int gap)

Parameters

gap int

The row gap in cells.

Returns

GridBuilder

The builder for chaining.

RowGridlines(bool)

Draws a horizontal rule between every adjacent row.

public GridBuilder RowGridlines(bool show = true)

Parameters

show bool

Returns

GridBuilder

RowSplitterAfter(int)

Makes the boundary after row afterIndex draggable to resize the two rows.

public GridBuilder RowSplitterAfter(int afterIndex)

Parameters

afterIndex int

The zero-based index of the row the splitter follows.

Returns

GridBuilder

The builder for chaining.

Rows(params GridLength[])

Adds row track definitions, top to bottom.

public GridBuilder Rows(params GridLength[] rows)

Parameters

rows GridLength[]

The row lengths (fixed cells, auto-to-content, or star weights).

Returns

GridBuilder

The builder for chaining.

WithAlignment(HorizontalAlignment)

Sets the horizontal alignment of the grid within its container.

public GridBuilder WithAlignment(HorizontalAlignment alignment)

Parameters

alignment HorizontalAlignment

The horizontal alignment.

Returns

GridBuilder

The builder for chaining.

WithColorRole(ColorRole, ThemeMode?)

Sets the grid's semantic colour role, which tints the per-cell chrome (cell borders and the surface fill of cells that opt into chrome) from the theme's role palette.

public GridBuilder WithColorRole(ColorRole role, ThemeMode? mode = null)

Parameters

role ColorRole

The semantic role determining the chrome colour.

mode ThemeMode?

Optional ThemeMode override for dark/light role-colour derivation. When null, the active theme's mode is used.

Returns

GridBuilder

The builder for chaining.

WithHeight(int)

Sets the grid's height.

public GridBuilder WithHeight(int height)

Parameters

height int

The height in cells.

Returns

GridBuilder

The builder for chaining.

WithMargin(Margin)

Sets the margin around the grid.

public GridBuilder WithMargin(Margin margin)

Parameters

margin Margin

The margin.

Returns

GridBuilder

The builder for chaining.

WithMargin(int, int, int, int)

Sets the margin around the grid.

public GridBuilder WithMargin(int left, int top, int right, int bottom)

Parameters

left int

Left margin.

top int

Top margin.

right int

Right margin.

bottom int

Bottom margin.

Returns

GridBuilder

The builder for chaining.

WithName(string)

Sets the control name for FindControl queries.

public GridBuilder WithName(string name)

Parameters

name string

The control name.

Returns

GridBuilder

The builder for chaining.

WithPadding(Padding)

Sets the grid's own inner padding.

public GridBuilder WithPadding(Padding padding)

Parameters

padding Padding

The padding value.

Returns

GridBuilder

The builder for chaining.

WithPadding(int, int, int, int)

Sets the grid's own inner padding.

public GridBuilder WithPadding(int left, int top, int right, int bottom)

Parameters

left int

Left padding.

top int

Top padding.

right int

Right padding.

bottom int

Bottom padding.

Returns

GridBuilder

The builder for chaining.

WithSize(int, int)

Sets both the grid's width and height.

public GridBuilder WithSize(int width, int height)

Parameters

width int

The width in cells.

height int

The height in cells.

Returns

GridBuilder

The builder for chaining.

WithVerticalAlignment(VerticalAlignment)

Sets the vertical alignment of the grid within its container.

public GridBuilder WithVerticalAlignment(VerticalAlignment alignment)

Parameters

alignment VerticalAlignment

The vertical alignment.

Returns

GridBuilder

The builder for chaining.

WithWidth(int)

Sets the grid's width.

public GridBuilder WithWidth(int width)

Parameters

width int

The width in cells.

Returns

GridBuilder

The builder for chaining.

Operators

implicit operator GridControl(GridBuilder)

Implicit conversion to GridControl.

public static implicit operator GridControl(GridBuilder builder)

Parameters

builder GridBuilder

The builder to convert.

Returns

GridControl