Class Table
A scrollable table control.
Implements
Inherited Members
Namespace: SadConsole.UI.Controls
Assembly: SadConsole.Extended.dll
Syntax
public class Table : CompositeControl, IContainer, IList<ControlBase>, ICollection<ControlBase>, IEnumerable<ControlBase>, IEnumerable
Constructors
Table(int, int)
Creates a new table with the default SadConsole colors, and cell size of (1 width, 1 height)
Declaration
public Table(int width, int height)
Parameters
Table(int, int, int, Color, Color, int)
Creates a new table with extra params to set the base default values of the table
Declaration
public Table(int width, int height, int cellWidth, Color defaultForeground, Color defaultBackground, int cellHeight = 1)
Parameters
Type | Name | Description |
---|---|---|
int | width | |
int | height | |
int | cellWidth | |
Color | defaultForeground | |
Color | defaultBackground | |
int | cellHeight |
Table(int, int, int, int)
Creates a new table with custom cell width and cell height params; Uses the default SadConsole colors
Declaration
public Table(int width, int height, int cellWidth, int cellHeight = 1)
Parameters
Properties
AutoScrollOnCellSelection
By default the table will automatically scroll to the selected cell if possible.
Declaration
public bool AutoScrollOnCellSelection { get; set; }
Property Value
Type | Description |
---|---|
bool |
Cells
The cells collection used to modify the table cells
Declaration
public Table.TableCells Cells { get; }
Property Value
Type | Description |
---|---|
Table.TableCells |
CurrentMouseCell
Declaration
public Table.Cell? CurrentMouseCell { get; }
Property Value
DefaultBackground
The default background color used for the table background and newly created cells
Declaration
public Color DefaultBackground { get; set; }
Property Value
Type | Description |
---|---|
Color |
DefaultCellSize
The default size a cell gets when it is newly created
Declaration
public Point DefaultCellSize { get; set; }
Property Value
Type | Description |
---|---|
Point |
DefaultForeground
The default foreground color used for the table foreground and newly created cells
Declaration
public Color DefaultForeground { get; set; }
Property Value
Type | Description |
---|---|
Color |
DefaultHoverMode
The default visual hovering mode when hovering over cells
Declaration
public Table.TableCells.Layout.Mode DefaultHoverMode { get; set; }
Property Value
Type | Description |
---|---|
Table.TableCells.Layout.Mode |
DefaultSelectionMode
The default visual selection mode when selecting a cell
Declaration
public Table.TableCells.Layout.Mode DefaultSelectionMode { get; set; }
Property Value
Type | Description |
---|---|
Table.TableCells.Layout.Mode |
DrawFakeCells
By default, only cells that have been modified in anyway will be rendered on the table control. Turn this off, if the whole table should draw as many cells as it fits with their default layout.
Declaration
public bool DrawFakeCells { get; set; }
Property Value
Type | Description |
---|---|
bool |
HorizontalScrollBar
The horizontal scrollbar, use the SetupScrollBar method with Horizontal orientation to initialize it.
Declaration
public ScrollBar? HorizontalScrollBar { get; }
Property Value
Type | Description |
---|---|
ScrollBar |
HorizontalScrollBarMaximum
The updated maximum value, incase the scrollbar object's maximum value is not yet updated by the theme.
Declaration
public int HorizontalScrollBarMaximum { get; }
Property Value
Type | Description |
---|---|
int |
IsHorizontalScrollBarVisible
Returns true if the horizontal scroll bar is currently visible.
Declaration
public bool IsHorizontalScrollBarVisible { get; }
Property Value
Type | Description |
---|---|
bool |
IsVerticalScrollBarVisible
Returns true if the vertical scroll bar is currently visible.
Declaration
public bool IsVerticalScrollBarVisible { get; }
Property Value
Type | Description |
---|---|
bool |
SelectedCell
Returns the current selected cell
Declaration
public Table.Cell? SelectedCell { get; }
Property Value
UseMouse
Declaration
public bool UseMouse { get; set; }
Property Value
Type | Description |
---|---|
bool |
VerticalScrollBar
The vertical scrollbar, use the SetupScrollBar method with Vertical orientation to initialize it.
Declaration
public ScrollBar? VerticalScrollBar { get; }
Property Value
Type | Description |
---|---|
ScrollBar |
VerticalScrollBarMaximum
The updated maximum value, incase the scrollbar object's maximum value is not yet updated by the theme.
Declaration
public int VerticalScrollBarMaximum { get; }
Property Value
Type | Description |
---|---|
int |
Methods
AdjustControlSurface(Cell, ColoredGlyphBase?, bool)
Declaration
protected void AdjustControlSurface(Table.Cell cell, ColoredGlyphBase? customStateAppearance, bool adjustVisibility)
Parameters
Type | Name | Description |
---|---|---|
Table.Cell | cell | |
ColoredGlyphBase | customStateAppearance | |
bool | adjustVisibility |
GetCustomStateAppearance(Cell)
Declaration
protected ColoredGlyphBase? GetCustomStateAppearance(Table.Cell cell)
Parameters
Returns
Type | Description |
---|---|
ColoredGlyphBase |
GetHorizontalAlignment(HorizontalAlign, int, char[])
Declaration
protected static int GetHorizontalAlignment(Table.Cell.Options.HorizontalAlign hAlign, int totalWidth, char[] textArr)
Parameters
Returns
Type | Description |
---|---|
int |
GetOldRowAndColumnValues(List<((int x, int y), (int row, int col))>?, Point, ref int, ref int)
Declaration
protected void GetOldRowAndColumnValues(List<((int x, int y), (int row, int col))>? fakeCells, Point cellPosition, ref int oldRow, ref int oldCol)
Parameters
Type | Name | Description |
---|---|---|
List<((int x, int y), (int row, int col))> | fakeCells | |
Point | cellPosition | |
int | oldRow | |
int | oldCol |
GetTotalCellSize(Cell, int, int, out int, out int)
Declaration
protected static void GetTotalCellSize(Table.Cell cell, int width, int height, out int totalWidth, out int totalHeight)
Parameters
HideVisualCell(int, int, Point)
Declaration
protected void HideVisualCell(int column, int row, Point position)
Parameters
OnLeftMouseClicked(ControlMouseState)
Called when the left mouse button is clicked. Raises the MouseButtonClicked event and calls the DetermineState() method.
Declaration
protected override void OnLeftMouseClicked(ControlBase.ControlMouseState state)
Parameters
Type | Name | Description |
---|---|---|
ControlBase.ControlMouseState | state | The current mouse data |
Overrides
OnMouseExit(ControlMouseState)
Called when the mouse exits the area of the control. Raises the MouseExit event and calls the DetermineState() method.
Declaration
protected override void OnMouseExit(ControlBase.ControlMouseState state)
Parameters
Type | Name | Description |
---|---|---|
ControlBase.ControlMouseState | state | The current mouse data |
Overrides
OnMouseIn(ControlMouseState)
Called as the mouse moves around the control area. Raises the MouseMove event and calls the DetermineState() method.
Declaration
protected override void OnMouseIn(ControlBase.ControlMouseState state)
Parameters
Type | Name | Description |
---|---|---|
ControlBase.ControlMouseState | state | The current mouse data |
Overrides
OnRightMouseClicked(ControlMouseState)
Called when the right mouse button is clicked. Raises the MouseButtonClicked event and calls the DetermineState() method.
Declaration
protected override void OnRightMouseClicked(ControlBase.ControlMouseState state)
Parameters
Type | Name | Description |
---|---|---|
ControlBase.ControlMouseState | state | The current mouse data. |
Overrides
PrintText(Cell)
Declaration
protected void PrintText(Table.Cell cell)
Parameters
ScrollToSelectedItem()
Scrolls the list to the item currently selected.
Declaration
public void ScrollToSelectedItem()
SetScrollBarVisibility(int, int)
Declaration
protected void SetScrollBarVisibility(int maxRowsHeight, int maxColumnsWidth)
Parameters
SetupScrollBar(Orientation, int, Point)
Configures the associated VerticalScrollBar.
Declaration
public void SetupScrollBar(Orientation orientation, int size, Point position)
Parameters
Type | Name | Description |
---|---|---|
Orientation | orientation | The orientation of the scrollbar. |
int | size | |
Point | position | The position of the scrollbar. |
UpdateAndRedraw(TimeSpan)
Updates each control hosted by this control.
Declaration
public override void UpdateAndRedraw(TimeSpan time)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | time | The game frame time delta. |
Overrides
Events
OnCellDoubleClick
Fires an event when a cell is double clicked.
Declaration
public event EventHandler<Table.CellEventArgs>? OnCellDoubleClick
Event Type
Type | Description |
---|---|
EventHandler<Table.CellEventArgs> |
OnCellEnter
Fires an event when a cell is entered by the mouse.
Declaration
public event EventHandler<Table.CellEventArgs>? OnCellEnter
Event Type
Type | Description |
---|---|
EventHandler<Table.CellEventArgs> |
OnCellExit
Fires an event when a cell is exited by the mouse.
Declaration
public event EventHandler<Table.CellEventArgs>? OnCellExit
Event Type
Type | Description |
---|---|
EventHandler<Table.CellEventArgs> |
OnCellLeftClick
Fires an event when a cell is left clicked.
Declaration
public event EventHandler<Table.CellEventArgs>? OnCellLeftClick
Event Type
Type | Description |
---|---|
EventHandler<Table.CellEventArgs> |
OnCellRightClick
Fires an event when a cell is right clicked.
Declaration
public event EventHandler<Table.CellEventArgs>? OnCellRightClick
Event Type
Type | Description |
---|---|
EventHandler<Table.CellEventArgs> |
OnDrawFakeCell
Called when a fake cells is being drawn, you can use this to modify the cell layout.
Declaration
public event EventHandler<Table.CellEventArgs>? OnDrawFakeCell
Event Type
Type | Description |
---|---|
EventHandler<Table.CellEventArgs> |
SelectedCellChanged
Fires an event when the selected cell has changed.
Declaration
public event EventHandler<Table.CellChangedEventArgs>? SelectedCellChanged
Event Type
Type | Description |
---|---|
EventHandler<Table.CellChangedEventArgs> |