Table of Contents

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

BorderStyle

Color

Gets or sets the color of the rule line.

public Color? Color { get; set; }

Property Value

Color?

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

bool

IsProgressActive

Gets whether progress or indeterminate mode is active.

public bool IsProgressActive { get; }

Property Value

bool

ProgressRatio

Gets the current progress ratio (0.0 to 1.0).

public float ProgressRatio { get; }

Property Value

float

Title

Gets or sets the title text displayed within the rule.

public string? Title { get; set; }

Property Value

string

TitleAlignment

Gets or sets the horizontal alignment of the title within the rule.

public TextJustification TitleAlignment { get; set; }

Property Value

TextJustification

Methods

ClearProgress(TimeSpan?)

Clears progress. Cancels shimmer. Optionally fades the progress to zero.

public void ClearProgress(TimeSpan? fadeDuration = null)

Parameters

fadeDuration TimeSpan?

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

constraints LayoutConstraints

The 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

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

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

gradient ColorGradient

Color gradient for the shimmer segment.

cycleDuration TimeSpan?

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

ratio float

Progress ratio, clamped to [0,1].

gradient ColorGradient

Color gradient to apply to the filled portion.