Table of Contents

Class ClockElement

Namespace
SharpConsoleUI.Panel
Assembly
SharpConsoleUI.dll

A panel element that displays the current time, auto-updating via a timer.

public class ClockElement : PanelElement, IPanelElement, IDisposable
Inheritance
ClockElement
Implements
Inherited Members
Extension Methods

Constructors

ClockElement(string?)

Initializes a new ClockElement.

public ClockElement(string? name = null)

Parameters

name string

Optional element name. Defaults to "clock".

Properties

FixedWidth

Gets the fixed width of this element, or null if it uses MeasureWidth() or flex sizing.

public override int? FixedWidth { get; }

Property Value

int?

Format

Gets or sets the time format string (e.g., "HH:mm", "HH:mm:ss").

public string Format { get; set; }

Property Value

string

TextColor

Gets or sets an optional text color override.

public Color? TextColor { get; set; }

Property Value

Color?

UpdateIntervalMs

Gets or sets the update interval in milliseconds.

public int UpdateIntervalMs { get; set; }

Property Value

int

Methods

Dispose()

Disposes the timer resource.

public void Dispose()

MeasureWidth()

Measures the natural content width of this element. Used when FixedWidth is null and FlexGrow is 0.

public override int MeasureWidth()

Returns

int

The measured width in columns.

Render(CharacterBuffer, int, int, int, Color, Color)

Renders the element into the character buffer at the specified position.

public override void Render(CharacterBuffer buffer, int x, int y, int width, Color fg, Color bg)

Parameters

buffer CharacterBuffer

The character buffer to render into.

x int

The x position to render at.

y int

The y position to render at.

width int

The allocated width for this element.

fg Color

The default foreground color.

bg Color

The default background color.