Table of Contents

Class TimePickerControl

Namespace
SharpConsoleUI.Controls
Assembly
SharpConsoleUI.dll

A time picker control with segmented hour/minute/second/AM-PM fields. Supports 12h and 24h formats, keyboard digit entry, and mouse interaction.

public class TimePickerControl : BaseControl, IDOMPaintable, INotifyPropertyChanged, IInteractiveControl, IFocusableControl, IMouseAwareControl, IWindowControl, IDisposable, ICursorShapeProvider
Inheritance
TimePickerControl
Implements
Inherited Members
Extension Methods

Constructors

TimePickerControl(string)

Initializes a new instance of the TimePickerControl class.

public TimePickerControl(string prompt = "Time:")

Parameters

prompt string

The prompt text displayed in the header.

Properties

BackgroundColor

Gets or sets the background color.

public Color? BackgroundColor { get; set; }

Property Value

Color?

CanFocusWithMouse

Whether this control can receive focus via mouse clicks

public bool CanFocusWithMouse { get; }

Property Value

bool

CanReceiveFocus

Whether this control can receive focus

public bool CanReceiveFocus { get; }

Property Value

bool

Container

Gets or sets the parent container that hosts this control.

public override IContainer? Container { get; set; }

Property Value

IContainer

ContentWidth

Gets the minimum width needed to display the control's content, including margins. Returns null if width cannot be determined. This is calculated based on content (text length, child controls, etc.) and represents the natural/intrinsic size.

public override int? ContentWidth { get; }

Property Value

int?

Culture

Gets or sets the culture used for time formatting.

public CultureInfo Culture { get; set; }

Property Value

CultureInfo

DisabledForegroundColor

Gets or sets the foreground color when disabled.

public Color DisabledForegroundColor { get; set; }

Property Value

Color

FocusedBackgroundColor

Gets or sets the background color when focused.

public Color? FocusedBackgroundColor { get; set; }

Property Value

Color?

FocusedForegroundColor

Gets or sets the foreground color when focused.

public Color FocusedForegroundColor { get; set; }

Property Value

Color

ForegroundColor

Gets or sets the foreground color.

public Color ForegroundColor { get; set; }

Property Value

Color

HasFocus

public bool HasFocus { get; }

Property Value

bool

IsEnabled

Gets or sets whether the control is enabled.

public bool IsEnabled { get; set; }

Property Value

bool

MaxTime

Gets or sets the maximum selectable time.

public TimeSpan? MaxTime { get; set; }

Property Value

TimeSpan?

MinTime

Gets or sets the minimum selectable time.

public TimeSpan? MinTime { get; set; }

Property Value

TimeSpan?

PreferredCursorShape

Gets the preferred cursor shape for this control. Return null to use the default cursor shape.

public CursorShape? PreferredCursorShape { get; }

Property Value

CursorShape?

Prompt

Gets or sets the prompt text displayed in the header.

public string Prompt { get; set; }

Property Value

string

SegmentBackgroundColor

Gets or sets the background color for the active time segment.

public Color? SegmentBackgroundColor { get; set; }

Property Value

Color?

SegmentForegroundColor

Gets or sets the foreground color for the active time segment.

public Color SegmentForegroundColor { get; set; }

Property Value

Color

SelectedTime

Gets or sets the currently selected time.

public TimeSpan? SelectedTime { get; set; }

Property Value

TimeSpan?

ShowSeconds

Gets or sets whether seconds are displayed.

public bool ShowSeconds { get; set; }

Property Value

bool

Use24HourFormat

Gets or sets whether 24-hour format is used.

public bool? Use24HourFormat { get; set; }

Property Value

bool?

WantsMouseEvents

Whether this control wants to receive mouse events

public bool WantsMouseEvents { get; }

Property Value

bool

Methods

MeasureDOM(LayoutConstraints)

Measures the control's desired size given the available constraints.

public override LayoutSize MeasureDOM(LayoutConstraints constraints)

Parameters

constraints LayoutConstraints

The layout constraints (min/max width/height).

Returns

LayoutSize

The desired size of the control.

OnDisposing()

Called during Dispose() before Container is set to null. Override to perform control-specific cleanup (null events, close portals, clear data, etc.).

protected override void OnDisposing()

PaintDOM(CharacterBuffer, LayoutRect, LayoutRect, Color, Color)

Paints the control's content directly to a CharacterBuffer.

public override void PaintDOM(CharacterBuffer buffer, LayoutRect bounds, LayoutRect clipRect, Color defaultFg, Color defaultBg)

Parameters

buffer CharacterBuffer

The buffer to paint to.

bounds LayoutRect

The absolute bounds where the control should paint.

clipRect LayoutRect

The clipping rectangle (visible area).

defaultFg Color
defaultBg Color

ProcessKey(ConsoleKeyInfo)

Processes a keyboard input event.

public bool ProcessKey(ConsoleKeyInfo key)

Parameters

key ConsoleKeyInfo

The key information for the pressed key.

Returns

bool

True if the key was handled by this control; otherwise, false.

ProcessMouseEvent(MouseEventArgs)

Processes a mouse event for this control

public bool ProcessMouseEvent(MouseEventArgs args)

Parameters

args MouseEventArgs

Mouse event arguments with control-relative coordinates

Returns

bool

True if the event was handled and should not propagate further

Events

MouseClick

Event fired when the control is clicked

public event EventHandler<MouseEventArgs>? MouseClick

Event Type

EventHandler<MouseEventArgs>

MouseDoubleClick

Event fired when the control is double-clicked

public event EventHandler<MouseEventArgs>? MouseDoubleClick

Event Type

EventHandler<MouseEventArgs>

MouseEnter

Event fired when the mouse enters the control area

public event EventHandler<MouseEventArgs>? MouseEnter

Event Type

EventHandler<MouseEventArgs>

MouseLeave

Event fired when the mouse leaves the control area

public event EventHandler<MouseEventArgs>? MouseLeave

Event Type

EventHandler<MouseEventArgs>

MouseMove

Event fired when the mouse moves over the control

public event EventHandler<MouseEventArgs>? MouseMove

Event Type

EventHandler<MouseEventArgs>

MouseRightClick

Event fired when the control is right-clicked (Button3)

public event EventHandler<MouseEventArgs>? MouseRightClick

Event Type

EventHandler<MouseEventArgs>

SelectedTimeChanged

Occurs when the selected time changes.

public event EventHandler<TimeSpan?>? SelectedTimeChanged

Event Type

EventHandler<TimeSpan?>