Table of Contents

Class SliderRenderingHelper

Namespace
SharpConsoleUI.Helpers
Assembly
SharpConsoleUI.dll

Shared rendering and math utilities for SliderControl and RangeSliderControl. Eliminates code duplication between the two slider implementations.

public static class SliderRenderingHelper
Inheritance
SliderRenderingHelper
Inherited Members

Methods

PaintHorizontalTrackSegment(CharacterBuffer, LayoutRect, LayoutRect, int, int, int, char, Color, Color)

Paints a horizontal segment of track characters.

public static void PaintHorizontalTrackSegment(CharacterBuffer buffer, LayoutRect clipRect, LayoutRect bounds, int x, int y, int length, char trackChar, Color color, Color bgColor)

Parameters

buffer CharacterBuffer

The character buffer to render to.

clipRect LayoutRect

The clipping rectangle.

bounds LayoutRect

The control bounds for clipping.

x int

Starting X position.

y int

Y position.

length int

Number of characters to paint.

trackChar char

The character to use.

color Color

The foreground color.

bgColor Color

The background color.

PaintVerticalTrackSegment(CharacterBuffer, LayoutRect, LayoutRect, int, int, int, char, Color, Color)

Paints a vertical segment of track characters.

public static void PaintVerticalTrackSegment(CharacterBuffer buffer, LayoutRect clipRect, LayoutRect bounds, int x, int y, int length, char trackChar, Color color, Color bgColor)

Parameters

buffer CharacterBuffer

The character buffer to render to.

clipRect LayoutRect

The clipping rectangle.

bounds LayoutRect

The control bounds for clipping.

x int

X position.

y int

Starting Y position.

length int

Number of characters to paint.

trackChar char

The character to use.

color Color

The foreground color.

bgColor Color

The background color.

PositionToValue(int, double, double, int)

Converts a track position in [0, trackLength - 1] to a value in [min, max].

public static double PositionToValue(int position, double min, double max, int trackLength)

Parameters

position int

The position on the track (0-based).

min double

The minimum value.

max double

The maximum value.

trackLength int

The length of the track in characters.

Returns

double

The value corresponding to the position.

SnapToStep(double, double, double, double)

Snaps a value to the nearest step increment from the minimum value.

public static double SnapToStep(double value, double min, double max, double step)

Parameters

value double

The raw value to snap.

min double

The minimum value (step base).

max double

The maximum value.

step double

The step increment.

Returns

double

The snapped value, clamped to [min, max].

ValueToPosition(double, double, double, int)

Converts a value in [min, max] to a track position in [0, trackLength - 1].

public static int ValueToPosition(double value, double min, double max, int trackLength)

Parameters

value double

The current value.

min double

The minimum value.

max double

The maximum value.

trackLength int

The length of the track in characters.

Returns

int

The position on the track (0-based).