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
controlIWindowControlThe 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
gapintThe 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
showbool
Returns
ColumnSplitterAfter(int)
Makes the boundary after column afterIndex draggable to resize the two columns.
public GridBuilder ColumnSplitterAfter(int afterIndex)
Parameters
afterIndexintThe 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
columnsGridLength[]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
indexint
Returns
GridlineAfterRow(int)
Adds a horizontal rule at the boundary after row index.
public GridBuilder GridlineAfterRow(int index)
Parameters
indexint
Returns
GridlineColor(Color)
Sets an explicit gridline colour (null keeps the role-derived default).
public GridBuilder GridlineColor(Color color)
Parameters
colorColor
Returns
GridlineStyle(BorderStyle)
Sets the gridline box-drawing style (default Single).
public GridBuilder GridlineStyle(BorderStyle style)
Parameters
styleBorderStyle
Returns
Outline(bool)
Renders the grid's role chrome in outline style.
public GridBuilder Outline(bool outline = true)
Parameters
outlineboolWhether 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
controlIWindowControlThe control to place.
rowintThe zero-based row index of the cell's top-left corner.
colintThe zero-based column index of the cell's top-left corner.
rowSpanintThe number of rows the cell occupies. Must be at least 1.
colSpanintThe 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
gapintThe 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
showbool
Returns
RowSplitterAfter(int)
Makes the boundary after row afterIndex draggable to resize the two rows.
public GridBuilder RowSplitterAfter(int afterIndex)
Parameters
afterIndexintThe 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
rowsGridLength[]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
alignmentHorizontalAlignmentThe 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
roleColorRoleThe semantic role determining the chrome colour.
modeThemeMode?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
heightintThe height in cells.
Returns
- GridBuilder
The builder for chaining.
WithMargin(Margin)
Sets the margin around the grid.
public GridBuilder WithMargin(Margin margin)
Parameters
marginMarginThe 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
Returns
- GridBuilder
The builder for chaining.
WithName(string)
Sets the control name for FindControl queries.
public GridBuilder WithName(string name)
Parameters
namestringThe control name.
Returns
- GridBuilder
The builder for chaining.
WithPadding(Padding)
Sets the grid's own inner padding.
public GridBuilder WithPadding(Padding padding)
Parameters
paddingPaddingThe 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
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
Returns
- GridBuilder
The builder for chaining.
WithVerticalAlignment(VerticalAlignment)
Sets the vertical alignment of the grid within its container.
public GridBuilder WithVerticalAlignment(VerticalAlignment alignment)
Parameters
alignmentVerticalAlignmentThe vertical alignment.
Returns
- GridBuilder
The builder for chaining.
WithWidth(int)
Sets the grid's width.
public GridBuilder WithWidth(int width)
Parameters
widthintThe 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
builderGridBuilderThe builder to convert.