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
BackgroundColor
Gets or sets the background color.
public Color? BackgroundColor { get; set; }
Property Value
CanFocusWithMouse
Whether this control can receive focus via mouse clicks
public bool CanFocusWithMouse { get; }
Property Value
CanReceiveFocus
Whether this control can receive focus
public bool CanReceiveFocus { get; }
Property Value
Container
Gets or sets the parent container that hosts this control.
public override IContainer? Container { get; set; }
Property Value
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
FocusedThumbColor
Gets or sets the color of the active/focused thumb.
public Color? FocusedThumbColor { get; set; }
Property Value
HasFocus
public bool HasFocus { get; }
Property Value
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
IsDragging
Gets whether the range slider is currently being dragged.
public bool IsDragging { get; }
Property Value
IsEnabled
Gets or sets whether the range slider is enabled.
public bool IsEnabled { get; set; }
Property Value
LargeStep
Gets or sets the large step increment.
public double LargeStep { get; set; }
Property Value
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
MaxValue
Gets or sets the maximum value of the slider range.
public double MaxValue { get; set; }
Property Value
MinRange
Gets or sets the minimum required gap between the low and high values.
public double MinRange { get; set; }
Property Value
MinValue
Gets or sets the minimum value of the slider range.
public double MinValue { get; set; }
Property Value
Orientation
Gets or sets the slider orientation.
public SliderOrientation Orientation { get; set; }
Property Value
ShowMinMaxLabels
Gets or sets whether to show min/max labels at the track ends.
public bool ShowMinMaxLabels { get; set; }
Property Value
ShowValueLabel
Gets or sets whether to show the range value label.
public bool ShowValueLabel { get; set; }
Property Value
Step
Gets or sets the step increment.
public double Step { get; set; }
Property Value
ThumbColor
Gets or sets the color of inactive thumb.
public Color? ThumbColor { get; set; }
Property Value
TrackColor
Gets or sets the color of the unfilled track portion.
public Color? TrackColor { get; set; }
Property Value
ValueLabelFormat
Gets or sets the format string for value labels.
public string ValueLabelFormat { get; set; }
Property Value
WantsMouseEvents
Whether this control wants to receive mouse events
public bool WantsMouseEvents { get; }
Property Value
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
constraintsLayoutConstraintsThe 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
bufferCharacterBufferThe buffer to paint to.
boundsLayoutRectThe absolute bounds where the control should paint.
clipRectLayoutRectThe clipping rectangle (visible area).
defaultFgColordefaultBgColor
ProcessKey(ConsoleKeyInfo)
Processes a keyboard input event.
public bool ProcessKey(ConsoleKeyInfo key)
Parameters
keyConsoleKeyInfoThe 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
argsMouseEventArgsMouse 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
LowValueChanged
Occurs when the low value changes.
public event EventHandler<double>? LowValueChanged
Event Type
MouseClick
Event fired when the control is clicked
public event EventHandler<MouseEventArgs>? MouseClick
Event Type
MouseDoubleClick
Event fired when the control is double-clicked
public event EventHandler<MouseEventArgs>? MouseDoubleClick
Event Type
MouseEnter
Event fired when the mouse enters the control area
public event EventHandler<MouseEventArgs>? MouseEnter
Event Type
MouseLeave
Event fired when the mouse leaves the control area
public event EventHandler<MouseEventArgs>? MouseLeave
Event Type
MouseMove
Event fired when the mouse moves over the control
public event EventHandler<MouseEventArgs>? MouseMove
Event Type
MouseRightClick
Event fired when the control is right-clicked (Button3)
public event EventHandler<MouseEventArgs>? MouseRightClick
Event Type
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)>