Table of Contents

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 int

The x size

ys int

The y size

sm TuiSelectable[,]

Selectable matrix

startX uint

Start X index in the selectable matrix

startY uint

Start Y index in the selectable matrix

p Placement
x int
y int
f CharFormat

The 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 int

The x size

ys int

The y size

sm TuiSelectable[,]

Selectable matrix

startX uint

Start X index in the selectable matrix

startY uint

Start Y index in the selectable matrix

f CharFormat

The default format

e TuiElement[]

Additional elements

Fields

WaitForKey

If the screen will wait for a key press before updating

public bool WaitForKey

Field Value

bool

Properties

FinishPlayCycleEvent

Action called at the end of each play cycle

public Action<TuiScreenInteractive>? FinishPlayCycleEvent { set; }

Property Value

Action<TuiScreenInteractive>

KeyFunctions

The key actions

public Dictionary<(ConsoleKey, ConsoleModifiers), Action<TuiScreenInteractive, ConsoleKeyInfo>> KeyFunctions { get; }

Property Value

Dictionary<(ConsoleKey, ConsoleModifiers), Action<TuiScreenInteractive, ConsoleKeyInfo>>

MatrixPointerX

X index of the selected element in the matrix

public virtual uint MatrixPointerX { get; set; }

Property Value

uint

MatrixPointerY

Y index of the selected element in the matrix

public virtual uint MatrixPointerY { get; set; }

Property Value

uint

Playing

If the screen is playing or not

public bool Playing { get; }

Property Value

bool

Selected

Currently selected element

public TuiSelectable Selected { get; }

Property Value

TuiSelectable

SelectionMatrix

2d matrix of the elements, ordered and positioned in the way it is wanted

public TuiSelectable[,] SelectionMatrix { get; set; }

Property Value

TuiSelectable[,]

Methods

DeleteAllKeyEvents()

Clears all existent key events. Useful because there are some default ones. Returns itself

public TuiScreenInteractive DeleteAllKeyEvents()

Returns

TuiScreenInteractive

HandleKey(ConsoleKeyInfo)

Handle a key press

public bool HandleKey(ConsoleKeyInfo keyInfo)

Parameters

keyInfo ConsoleKeyInfo

Returns

bool

MoveDown(TuiScreenInteractive, ConsoleKeyInfo)

Move the selected pointer down (y positive)

public static void MoveDown(TuiScreenInteractive s, ConsoleKeyInfo ck)

Parameters

s TuiScreenInteractive
ck ConsoleKeyInfo

MoveLeft(TuiScreenInteractive, ConsoleKeyInfo)

Move the selected pointer left (x negative)

public static void MoveLeft(TuiScreenInteractive s, ConsoleKeyInfo ck)

Parameters

s TuiScreenInteractive
ck ConsoleKeyInfo

MoveRight(TuiScreenInteractive, ConsoleKeyInfo)

Move the selected pointer right (x positive)

public static void MoveRight(TuiScreenInteractive s, ConsoleKeyInfo ck)

Parameters

s TuiScreenInteractive
ck ConsoleKeyInfo

MoveUp(TuiScreenInteractive, ConsoleKeyInfo)

Move the selected pointer up (y negative)

public static void MoveUp(TuiScreenInteractive s, ConsoleKeyInfo ck)

Parameters

s TuiScreenInteractive
ck ConsoleKeyInfo

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

s TuiScreenInteractive
ck ConsoleKeyInfo

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 ConsoleKey
keyFunction Action<TuiScreenInteractive, ConsoleKeyInfo>

Returns

TuiScreenInteractive

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 ConsoleKey
m ConsoleModifiers
keyFunction Action<TuiScreenInteractive, ConsoleKeyInfo>

Returns

TuiScreenInteractive