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
CellLocationsY
Gets the list of Y-coordinates for cell locations.
public List<int> CellLocationsY { get; }
Property Value
ColWidths
Gets the list of column widths.
public List<int> ColWidths { get; }
Property Value
ColumnSpacing
Gets or sets the spacing between columns.
public int ColumnSpacing { get; set; }
Property Value
ColumnsProportions
Gets the collection of proportions that define how columns divide available space.
public ObservableCollection<Proportion> ColumnsProportions { get; }
Property Value
DefaultColumnProportion
Gets or sets the default proportion for columns.
public Proportion DefaultColumnProportion { get; set; }
Property Value
DefaultRowProportion
Gets or sets the default proportion for rows.
public Proportion DefaultRowProportion { get; set; }
Property Value
GridLinesX
Gets the list of X-coordinates for grid lines (internal use).
public List<int> GridLinesX { get; }
Property Value
GridLinesY
Gets the list of Y-coordinates for grid lines (internal use).
public List<int> GridLinesY { get; }
Property Value
RowHeights
Gets the list of row heights.
public List<int> RowHeights { get; }
Property Value
RowSpacing
Gets or sets the spacing between rows.
public int RowSpacing { get; set; }
Property Value
RowsProportions
Gets the collection of proportions that define how rows divide available space.
public ObservableCollection<Proportion> RowsProportions { get; }
Property Value
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
widgetsIEnumerable<Widget>The widgets to arrange.
boundsRectangleThe 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
colintThe 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
rowintThe 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
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
colintThe 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
indexintThe 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
indexintThe 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
rowintThe 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
widgetsIEnumerable<Widget>The widgets to measure.
availableSizePointThe available size for layout.
Returns
- Point
The desired size needed to display the grid with all widgets.