Class RuleControl
- Namespace
- SharpConsoleUI.Controls
- Assembly
- SharpConsoleUI.dll
A control that renders a horizontal rule (divider line) with optional title text. Renders directly to CharacterBuffer using BoxChars.
public class RuleControl : BaseControl, IWindowControl, IDisposable, IDOMPaintable, INotifyPropertyChanged
- Inheritance
-
RuleControl
- Implements
- Inherited Members
- Extension Methods
Constructors
RuleControl()
Initializes a new instance of the RuleControl class.
public RuleControl()
Properties
BorderStyle
Gets or sets the border style for the rule line characters.
public BorderStyle BorderStyle { get; set; }
Property Value
Color
Gets or sets the color of the rule line.
public Color? Color { 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?
IsIndeterminate
Gets whether indeterminate shimmer mode is active.
public bool IsIndeterminate { get; }
Property Value
IsProgressActive
Gets whether progress or indeterminate mode is active.
public bool IsProgressActive { get; }
Property Value
ProgressRatio
Gets the current progress ratio (0.0 to 1.0).
public float ProgressRatio { get; }
Property Value
Title
Gets or sets the title text displayed within the rule.
public string? Title { get; set; }
Property Value
TitleAlignment
Gets or sets the horizontal alignment of the title within the rule.
public TextJustification TitleAlignment { get; set; }
Property Value
Methods
ClearProgress(TimeSpan?)
Clears progress. Cancels shimmer. Optionally fades the progress to zero.
public void ClearProgress(TimeSpan? fadeDuration = null)
Parameters
fadeDurationTimeSpan?Fade duration. Default: 300ms. Pass TimeSpan.Zero for immediate.
Create()
Creates a new builder for configuring a RuleControl
public static RuleBuilder Create()
Returns
- RuleBuilder
A new builder instance
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.
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
SetIndeterminate(ColorGradient, TimeSpan?)
Shows indeterminate shimmer. A gradient segment sweeps left to right in a loop.
public void SetIndeterminate(ColorGradient gradient, TimeSpan? cycleDuration = null)
Parameters
gradientColorGradientColor gradient for the shimmer segment.
cycleDurationTimeSpan?Duration of one sweep cycle. Default: 1500ms.
SetProgress(float, ColorGradient)
Shows determinate progress. Fills the rule left-to-right with the gradient up to the ratio. Cancels any active shimmer or clear animation.
public void SetProgress(float ratio, ColorGradient gradient)
Parameters
ratiofloatProgress ratio, clamped to [0,1].
gradientColorGradientColor gradient to apply to the filled portion.