Table of Contents

Class RangeSliderControl

Namespace
SharpConsoleUI.Controls
Assembly
SharpConsoleUI.dll

A dual-thumb range slider control that allows users to select a range of values by dragging two thumbs along a track. Supports keyboard and mouse interaction, minimum range enforcement, and optional value and min/max labels.

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

Constructors

RangeSliderControl()

Initializes a new instance of the RangeSliderControl class with default low=0 and high=100.

public RangeSliderControl()

Properties

ActiveThumb

Gets or sets which thumb is currently active (receives keyboard input).

public ActiveThumb ActiveThumb { get; set; }

Property Value

ActiveThumb

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?

FilledTrackColor

Gets or sets the color of the filled track portion (between the two thumbs).

public Color? FilledTrackColor { get; set; }

Property Value

Color?

FocusedThumbColor

Gets or sets the color of the active/focused thumb.

public Color? FocusedThumbColor { get; set; }

Property Value

Color?

HasFocus

public bool HasFocus { get; }

Property Value

bool

HighValue

Gets or sets the high value of the range. Enforces HighValue >= LowValue + MinRange. Setting HighValue below LowValue + MinRange pushes LowValue down.

public double HighValue { get; set; }

Property Value

double

IsDragging

Gets whether the range slider is currently being dragged.

public bool IsDragging { get; }

Property Value

bool

IsEnabled

Gets or sets whether the range slider is enabled.

public bool IsEnabled { get; set; }

Property Value

bool

LargeStep

Gets or sets the large step increment.

public double LargeStep { get; set; }

Property Value

double

LowValue

Gets or sets the low value of the range. Enforces LowValue <= HighValue - MinRange. Setting LowValue above HighValue - MinRange pushes HighValue up.

public double LowValue { get; set; }

Property Value

double

MaxValue

Gets or sets the maximum value of the slider range.

public double MaxValue { get; set; }

Property Value

double

MinRange

Gets or sets the minimum required gap between the low and high values.

public double MinRange { get; set; }

Property Value

double

MinValue

Gets or sets the minimum value of the slider range.

public double MinValue { get; set; }

Property Value

double

Orientation

Gets or sets the slider orientation.

public SliderOrientation Orientation { get; set; }

Property Value

SliderOrientation

ShowMinMaxLabels

Gets or sets whether to show min/max labels at the track ends.

public bool ShowMinMaxLabels { get; set; }

Property Value

bool

ShowValueLabel

Gets or sets whether to show the range value label.

public bool ShowValueLabel { get; set; }

Property Value

bool

Step

Gets or sets the step increment.

public double Step { get; set; }

Property Value

double

ThumbColor

Gets or sets the color of inactive thumb.

public Color? ThumbColor { get; set; }

Property Value

Color?

TrackColor

Gets or sets the color of the unfilled track portion.

public Color? TrackColor { get; set; }

Property Value

Color?

ValueLabelFormat

Gets or sets the format string for value labels.

public string ValueLabelFormat { get; set; }

Property Value

string

WantsMouseEvents

Whether this control wants to receive mouse events

public bool WantsMouseEvents { get; }

Property Value

bool

Methods

GetLogicalContentSize()

Gets the logical size of the control's content without rendering.

public override Size GetLogicalContentSize()

Returns

Size

The size representing the content's natural dimensions.

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

HighValueChanged

Occurs when the high value changes.

public event EventHandler<double>? HighValueChanged

Event Type

EventHandler<double>

LowValueChanged

Occurs when the low value changes.

public event EventHandler<double>? LowValueChanged

Event Type

EventHandler<double>

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>

RangeChanged

Occurs when either value changes, providing both low and high.

public event EventHandler<(double Low, double High)>? RangeChanged

Event Type

EventHandler<(double Low, double High)>