Class TuiScreenInteractive
- Namespace
- AshConsoleGraphics.Interactive
- Assembly
- AshConsoleGraphics.dll
Interactive screen with selectables and key actions
public class TuiScreenInteractive : TuiScreen, IEnumerable<TuiElement>, IEnumerable
- Inheritance
-
TuiScreenInteractive
- Implements
- Derived
- Inherited Members
Constructors
TuiScreenInteractive(int, int, TuiSelectable[,], uint, uint, Placement, int, int, CharFormat?, params TuiElement[])
Initializes a new interactive screen
public TuiScreenInteractive(int xs, int ys, TuiSelectable[,] sm, uint startX, uint startY, Placement p, int x, int y, CharFormat? f, params TuiElement[] e)
Parameters
xs
intThe x size
ys
intThe y size
sm
TuiSelectable[,]Selectable matrix
startX
uintStart X index in the selectable matrix
startY
uintStart Y index in the selectable matrix
p
Placementx
inty
intf
CharFormatThe default format
e
TuiElement[]Additional elements
TuiScreenInteractive(int, int, TuiSelectable[,], uint, uint, CharFormat?, params TuiElement[])
Initializes a new interactive screen
public TuiScreenInteractive(int xs, int ys, TuiSelectable[,] sm, uint startX, uint startY, CharFormat? f, params TuiElement[] e)
Parameters
xs
intThe x size
ys
intThe y size
sm
TuiSelectable[,]Selectable matrix
startX
uintStart X index in the selectable matrix
startY
uintStart Y index in the selectable matrix
f
CharFormatThe default format
e
TuiElement[]Additional elements
Fields
WaitForKey
If the screen will wait for a key press before updating
public bool WaitForKey
Field Value
Properties
FinishPlayCycleEvent
Action called at the end of each play cycle
public Action<TuiScreenInteractive>? FinishPlayCycleEvent { set; }
Property Value
KeyFunctions
The key actions
public Dictionary<(ConsoleKey, ConsoleModifiers), Action<TuiScreenInteractive, ConsoleKeyInfo>> KeyFunctions { get; }
Property Value
MatrixPointerX
X index of the selected element in the matrix
public virtual uint MatrixPointerX { get; set; }
Property Value
MatrixPointerY
Y index of the selected element in the matrix
public virtual uint MatrixPointerY { get; set; }
Property Value
Playing
If the screen is playing or not
public bool Playing { get; }
Property Value
Selected
Currently selected element
public TuiSelectable Selected { get; }
Property Value
SelectionMatrix
2d matrix of the elements, ordered and positioned in the way it is wanted
public TuiSelectable[,] SelectionMatrix { get; set; }
Property Value
Methods
DeleteAllKeyEvents()
Clears all existent key events. Useful because there are some default ones. Returns itself
public TuiScreenInteractive DeleteAllKeyEvents()
Returns
HandleKey(ConsoleKeyInfo)
Handle a key press
public bool HandleKey(ConsoleKeyInfo keyInfo)
Parameters
keyInfo
ConsoleKeyInfo
Returns
MoveDown(TuiScreenInteractive, ConsoleKeyInfo)
Move the selected pointer down (y positive)
public static void MoveDown(TuiScreenInteractive s, ConsoleKeyInfo ck)
Parameters
MoveLeft(TuiScreenInteractive, ConsoleKeyInfo)
Move the selected pointer left (x negative)
public static void MoveLeft(TuiScreenInteractive s, ConsoleKeyInfo ck)
Parameters
MoveRight(TuiScreenInteractive, ConsoleKeyInfo)
Move the selected pointer right (x positive)
public static void MoveRight(TuiScreenInteractive s, ConsoleKeyInfo ck)
Parameters
MoveUp(TuiScreenInteractive, ConsoleKeyInfo)
Move the selected pointer up (y negative)
public static void MoveUp(TuiScreenInteractive s, ConsoleKeyInfo ck)
Parameters
Play()
Plays the interactive screen. Handles all key presses
public void Play()
Stop()
Stop playing
public void Stop()
StopPlaying(TuiScreenInteractive, ConsoleKeyInfo)
Stop a screen playing
public static void StopPlaying(TuiScreenInteractive s, ConsoleKeyInfo ck)
Parameters
SubKeyEvent(ConsoleKey, Action<TuiScreenInteractive, ConsoleKeyInfo>)
Adds a new key event with no modifiers and returns itself
public TuiScreenInteractive SubKeyEvent(ConsoleKey k, Action<TuiScreenInteractive, ConsoleKeyInfo> keyFunction)
Parameters
k
ConsoleKeykeyFunction
Action<TuiScreenInteractive, ConsoleKeyInfo>
Returns
SubKeyEvent(ConsoleKey, ConsoleModifiers, Action<TuiScreenInteractive, ConsoleKeyInfo>)
Adds a new key event and returns itself
public TuiScreenInteractive SubKeyEvent(ConsoleKey k, ConsoleModifiers m, Action<TuiScreenInteractive, ConsoleKeyInfo> keyFunction)
Parameters
k
ConsoleKeym
ConsoleModifierskeyFunction
Action<TuiScreenInteractive, ConsoleKeyInfo>