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
bufferCharacterBufferThe character buffer to render to.
clipRectLayoutRectThe clipping rectangle.
boundsLayoutRectThe control bounds for clipping.
xintStarting X position.
yintY position.
lengthintNumber of characters to paint.
trackCharcharThe character to use.
colorColorThe foreground color.
bgColorColorThe 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
bufferCharacterBufferThe character buffer to render to.
clipRectLayoutRectThe clipping rectangle.
boundsLayoutRectThe control bounds for clipping.
xintX position.
yintStarting Y position.
lengthintNumber of characters to paint.
trackCharcharThe character to use.
colorColorThe foreground color.
bgColorColorThe 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
positionintThe position on the track (0-based).
mindoubleThe minimum value.
maxdoubleThe maximum value.
trackLengthintThe 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
valuedoubleThe raw value to snap.
mindoubleThe minimum value (step base).
maxdoubleThe maximum value.
stepdoubleThe 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
valuedoubleThe current value.
mindoubleThe minimum value.
maxdoubleThe maximum value.
trackLengthintThe length of the track in characters.
Returns
- int
The position on the track (0-based).