Table of Contents

Class GridLayout

Namespace
Myra.Graphics2D.UI
Assembly
Myra.dll

A layout system that arranges widgets in a grid with configurable rows and columns.

public class GridLayout : ILayout
Inheritance
GridLayout
Implements
Inherited Members

Constructors

GridLayout()

Initializes a new instance of the GridLayout class.

public GridLayout()

Properties

CellLocationsX

Gets the list of X-coordinates for cell locations.

public List<int> CellLocationsX { get; }

Property Value

List<int>

CellLocationsY

Gets the list of Y-coordinates for cell locations.

public List<int> CellLocationsY { get; }

Property Value

List<int>

ColWidths

Gets the list of column widths.

public List<int> ColWidths { get; }

Property Value

List<int>

ColumnSpacing

Gets or sets the spacing between columns.

public int ColumnSpacing { get; set; }

Property Value

int

ColumnsProportions

Gets the collection of proportions that define how columns divide available space.

public ObservableCollection<Proportion> ColumnsProportions { get; }

Property Value

ObservableCollection<Proportion>

DefaultColumnProportion

Gets or sets the default proportion for columns.

public Proportion DefaultColumnProportion { get; set; }

Property Value

Proportion

DefaultRowProportion

Gets or sets the default proportion for rows.

public Proportion DefaultRowProportion { get; set; }

Property Value

Proportion

GridLinesX

Gets the list of X-coordinates for grid lines (internal use).

public List<int> GridLinesX { get; }

Property Value

List<int>

GridLinesY

Gets the list of Y-coordinates for grid lines (internal use).

public List<int> GridLinesY { get; }

Property Value

List<int>

RowHeights

Gets the list of row heights.

public List<int> RowHeights { get; }

Property Value

List<int>

RowSpacing

Gets or sets the spacing between rows.

public int RowSpacing { get; set; }

Property Value

int

RowsProportions

Gets the collection of proportions that define how rows divide available space.

public ObservableCollection<Proportion> RowsProportions { get; }

Property Value

ObservableCollection<Proportion>

Methods

Arrange(IEnumerable<Widget>, Rectangle)

Arranges the widgets within the specified bounds according to the grid layout.

public void Arrange(IEnumerable<Widget> widgets, Rectangle bounds)

Parameters

widgets IEnumerable<Widget>

The widgets to arrange.

bounds Rectangle

The bounds in which to arrange the widgets.

GetCellLocationX(int)

Gets the X-coordinate of the cell in the specified column.

public int GetCellLocationX(int col)

Parameters

col int

The column index.

Returns

int

The X-coordinate of the cell, or zero if the index is invalid.

GetCellLocationY(int)

Gets the Y-coordinate of the cell in the specified row.

public int GetCellLocationY(int row)

Parameters

row int

The row index.

Returns

int

The Y-coordinate of the cell, or zero if the index is invalid.

GetCellRectangle(int, int)

Gets the rectangle of the cell at the specified column and row.

public Rectangle GetCellRectangle(int col, int row)

Parameters

col int

The column index.

row int

The row index.

Returns

Rectangle

The rectangle of the cell, or empty if the indices are invalid.

GetColumnProportion(int)

Gets the proportion for the specified column.

public Proportion GetColumnProportion(int col)

Parameters

col int

The column index.

Returns

Proportion

The proportion for the column, or the default column proportion if not found.

GetColumnWidth(int)

Gets the width of the column at the specified index.

public int GetColumnWidth(int index)

Parameters

index int

The column index.

Returns

int

The width of the column, or zero if the index is invalid.

GetRowHeight(int)

Gets the height of the row at the specified index.

public int GetRowHeight(int index)

Parameters

index int

The row index.

Returns

int

The height of the row, or zero if the index is invalid.

GetRowProportion(int)

Gets the proportion for the specified row.

public Proportion GetRowProportion(int row)

Parameters

row int

The row index.

Returns

Proportion

The proportion for the row, or the default row proportion if not found.

Measure(IEnumerable<Widget>, Point)

Measures the desired size of the grid layout with all its widgets within the given available size.

public Point Measure(IEnumerable<Widget> widgets, Point availableSize)

Parameters

widgets IEnumerable<Widget>

The widgets to measure.

availableSize Point

The available size for layout.

Returns

Point

The desired size needed to display the grid with all widgets.