Class TabControl
A control with tabs along the edge of the control. Each tab sets the content of the control.
Implements
Inherited Members
Namespace: SadConsole.UI.Controls
Assembly: SadConsole.dll
Syntax
public class TabControl : CompositeControl, IContainer, IList<ControlBase>, ICollection<ControlBase>, IEnumerable<ControlBase>, IEnumerable
Constructors
TabControl(IEnumerable<TabItem>, int, int)
Creates a new tab control with the specified tab items.
Declaration
public TabControl(IEnumerable<TabItem> tabItems, int width, int height)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<TabItem> | tabItems | Tabs that are present on the tabcontrol |
| int | width | Width of the content area |
| int | height | Heigh of the content area |
TabControl(IEnumerable<TabItem>, int, int, int)
Creates a new tab control with the specified tab items.
Declaration
public TabControl(IEnumerable<TabItem> tabItems, int activeTabIndex, int width, int height)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<TabItem> | tabItems | Tabs that are present on the tabcontrol |
| int | activeTabIndex | What tab to be active on initialization |
| int | width | Width of the content area |
| int | height | Heigh of the content area |
Fields
CachedMousePosition
The mouse position recorded from the last time the mouse was over the control.
Declaration
protected Point CachedMousePosition
Field Value
| Type | Description |
|---|---|
| Point |
ContentRegion
The region of the control where a tab item's content should be displayed.
Declaration
protected Rectangle ContentRegion
Field Value
| Type | Description |
|---|---|
| Rectangle |
InvalidActiveTabIndex
The index used when there isn't an active tab.
Declaration
public const int InvalidActiveTabIndex = -1
Field Value
| Type | Description |
|---|---|
| int |
TabsRegion
The region of the control where a tab headers should be displayed.
Declaration
protected Rectangle TabsRegion
Field Value
| Type | Description |
|---|---|
| Rectangle |
Properties
ActiveTabIndex
The index of the active tab. If InvalidActiveTabIndex is returned, there is no active tab.
Declaration
[DataMember]
public int ActiveTabIndex { get; protected set; }
Property Value
| Type | Description |
|---|---|
| int |
ConnectedLineStyle
An array of glyphs indexed by ICellSurface.ConnectedLineIndex. Defaults to ConnectedLineThin.
Declaration
[DataMember]
public int[] ConnectedLineStyle { get; set; }
Property Value
| Type | Description |
|---|---|
| int[] |
CurrentTab
Retursn the current tab.
Declaration
public TabItem CurrentTab { get; }
Property Value
| Type | Description |
|---|---|
| TabItem |
this[int]
Gets or sets the tab item at the specified index.
Declaration
public TabItem this[int index] { get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The index of the tab item to get or set. |
Property Value
| Type | Description |
|---|---|
| TabItem | The tab item content. |
TabItems
The list of tab items displayed by the control.
Declaration
[DataMember]
protected List<TabItem> TabItems { get; set; }
Property Value
| Type | Description |
|---|---|
| List<TabItem> |
TabOrientation
Sets the position of the tab strip to the top or bottom of the control.
Declaration
[DataMember]
public TabControl.Orientation TabOrientation { get; set; }
Property Value
| Type | Description |
|---|---|
| TabControl.Orientation |
Tabs
Gets a list of tabs in this control.
Declaration
public ListEnumerator<TabItem> Tabs { get; }
Property Value
| Type | Description |
|---|---|
| ListEnumerator<TabItem> |
Methods
AddTab(TabItem)
Adds a tab to the control.
Declaration
public void AddTab(TabItem tab)
Parameters
| Type | Name | Description |
|---|---|---|
| TabItem | tab | TabItem with header and associated console for tab content |
AddTab(string, Panel)
Creates and adds a tab to the control.
Declaration
public TabItem AddTab(string header, Panel content)
Parameters
| Type | Name | Description |
|---|---|---|
| string | header | The header of the new tab. |
| Panel | content | Associated content for the new tab. |
Returns
| Type | Description |
|---|---|
| TabItem | The new tab item. |
ContainsTab(TabItem)
Determines whether a tab is contained in this control.
Declaration
public bool ContainsTab(TabItem tab)
Parameters
| Type | Name | Description |
|---|---|---|
| TabItem | tab | The tab to check. |
Returns
| Type | Description |
|---|---|
| bool | Returns true when the tab is in the control; otherwise, false. |
GetTabIndex(TabItem)
Gets the index of a tab
Declaration
public int GetTabIndex(TabItem tab)
Parameters
| Type | Name | Description |
|---|---|---|
| TabItem | tab | Tab you need the index of |
Returns
| Type | Description |
|---|---|
| int | 0 based index of the tab |
OnActiveTabItem(int, int)
Raises the ActiveTabItemChanged event.
Declaration
protected void OnActiveTabItem(int previousActiveIndex, int activeIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| int | previousActiveIndex | The tab index of the previous item. |
| int | activeIndex | The index of the active tab. |
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
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
OnResized()
Resizes the tab item.
Declaration
protected override void OnResized()
Overrides
RemoveTab(TabItem)
Removes a tab from the control.
Declaration
public void RemoveTab(TabItem tab)
Parameters
| Type | Name | Description |
|---|---|---|
| TabItem | tab | TabItem that should be removed |
RemoveTab(int)
Removes a tab by index.
Declaration
public void RemoveTab(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The index of the tab to remove. |
SelectNextTab()
Sets the next tab as active. Stops at the last tab.
Declaration
public bool SelectNextTab()
Returns
| Type | Description |
|---|---|
| bool |
SelectPreviousTab()
Sets the previous tab as active. Stops at the first tab.
Declaration
public bool SelectPreviousTab()
Returns
| Type | Description |
|---|---|
| bool |
SetActiveTab(int)
Sets the tab specified by the index as active.
Declaration
public void SetActiveTab(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | Index of the tab. |
ThemeDetermineContentRegion()
Sets the ContentRegion rectangle to how much space the tab control should give to tab item content.
Declaration
protected void ThemeDetermineContentRegion()
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
ActiveTabItemChanged
Raised when the active tab changes.
Declaration
public event EventHandler<ValueChangedEventArgs<TabItem?>>? ActiveTabItemChanged
Event Type
| Type | Description |
|---|---|
| EventHandler<ValueChangedEventArgs<TabItem>> |