public sealed class Slider : IResponsive, IBundleAware
Standard slider UX object.

Constructors

Slider

#
public Slider()
Create a default slider from zero to one.

Slider

#
public Slider(UiNumber number, NonLinearTicks nonLinearity)
Create a slider initialised to a specific number.
number (UiNumber)
nonLinearity (NonLinearTicks)

Slider

#
public Slider(UiNumber number)
Create a slider initialised to a specific number.
number (UiNumber)

Properties

BackColour

#
public Color BackColour { get; set; }
Gets the sets the colour of the slider background. This will also affect the colour of the border, if any.

Bounds

#
public RectangleF Bounds { get; set; }
Gets or sets the layout bounds for this slider.

Bundle

#
public Bundle<Slider> Bundle { get; }
Gets the bundle this slider is associated with.

BundledSliders

#
public IEnumerable<Slider> BundledSliders { get; }
Enumerate over all *other* sliders in the same bundle as this one.

CornerRadius

#
public float CornerRadius { get; }
Gets the corner radii of the grip. This depends solely on the grip type.

CustomFormatting

#
public Func<decimal, string> CustomFormatting { get; set; }
Gets or sets a custom formatting delegate.

Font

#
public Font Font { get; set; }
Gets or sets the value format for the slider grip.

Format

#
public string Format { get; set; }
Gets or sets the value format for the slider grip. The format supports several placeholders:

{0} will be replaced with the standard formatting.

{1} will be replaced with the standard percentile formatting.

{2} will be replaced with the actual value, and as such supports custom formatting hints.

{3} will be replaced with the normalised value, and as such supports custom formatting hints.

{4} will be replaced with the percentage value, and as such supports custom formatting hints.

{5} will be replaced with the non-linear value.

{6} will be replaced with the custom formatting string.

GripColour

#
public Color GripColour { get; set; }
Gets the sets the colour of the slider grip.

GripDisplay

#
public GripShape GripDisplay { get; set; }
Gets or sets the grip display type.

Icon

#
public IIcon Icon { get; set; }
Gets the icon (if any) associated with this slider.

IconKey

#
public string IconKey { get; set; }
Gets the icon state key associated with the slider value.

Limits

#
public UiNumber Limits { get; }
Gets the limits and average value of this slider. Note, for the true values, access the Value property.

NonLinearity

#
public NonLinearTicks NonLinearity { get; }
Gets the non-linearity of this slider.

PresetCount

#
public int PresetCount { get; }
Gets the number of defined presets.

PresetNames

#
public IEnumerable<string> PresetNames { get; }
Enumerate over all preset names.

PresetRestrict

#
public bool PresetRestrict { get; set; }
Gets or sets whether the slider is only allowed to exist at preset values.

PresetValues

#
public IEnumerable<decimal> PresetValues { get; }
Enumerate over all preset values.

RailDisplay

#
public SliderRailDisplay RailDisplay { get; set; }
Gets or sets the rail display type.

Responder

#
public Responses Responder { get; }
Gets the UI response logic.
Responder

SlabThickness

#
public float SlabThickness { get; set; }
Gets or sets the thickness of the grip. When left at its default (float.NaN) the value is derived from the grip type via SliderLayout.GripThickness / SliderLayout.LabelThickness. Callers that want the slab thickness to match a surrounding canvas shape can assign that thickness here prior to drawing.

Values

#
public Plurality<decimal> Values { get; }
Gets the value plurality for this slider.

Methods

AddPreset

#
public void AddPreset(decimal value, string name)
Add a preset by name and value.
value (decimal)Value of preset. May not exist yet as a preset.
name (string)Name of preset. May not be empty or whitespace.

AddPreset

#
public void AddPreset(decimal value)
Add a nameless preset by value.
value (decimal)Value of preset. May not exist yet as a preset.

Draw

#
public void Draw(Context context)
Render this slider into a context.
context (Context)Graphics context.

FormatValue

#
public string FormatValue(decimal value)
format a given value using the Format field. This is the text that the slider displays on the grip.
value (decimal)Value to format.
Formatted value.

IsPreset

#
public bool IsPreset(decimal value)
Gets whether a preset value has already been defined.
value (decimal)Value to search for.

IsPreset

#
public bool IsPreset(string name)
Gets whether a preset name has already been defined. Name comparison is case sensitive.
name (string)Name to search for.

NearestPreset

#
public bool NearestPreset(decimal locus, out decimal preset, out string name)
Find the nearest preset.
locus (decimal)Search start.
preset (out decimal)Nearest preset value.
name (out string)Nearest preset name.
True if preset was found.

NearestPreset

#
public bool NearestPreset(decimal locus, out decimal preset)
Find the nearest preset.
locus (decimal)Search start.
preset (out decimal)Nearest preset value.
True if preset was found.

NextPreset

#
public bool NextPreset(decimal locus, out decimal preset, out string name)
Find the first preset strictly larger than the locus.
locus (decimal)Search locus.
preset (out decimal)Preset value.
name (out string)Preset name.
True if a previous preset was found.

NextPreset

#
public bool NextPreset(decimal locus, out decimal preset)
Find the first preset strictly larger than the locus.
locus (decimal)Search locus.
preset (out decimal)Preset value.
True if a previous preset was found.

PerformLayout

#
public void PerformLayout()
Perform layout for the current slider state.

PreviousPreset

#
public bool PreviousPreset(decimal locus, out decimal preset, out string name)
Find the first preset strictly smaller than the locus.
locus (decimal)Search locus.
preset (out decimal)Preset value.
name (out string)Preset name.
True if a previous preset was found.

PreviousPreset

#
public bool PreviousPreset(decimal locus, out decimal preset)
Find the first preset strictly smaller than the locus.
locus (decimal)Search locus.
preset (out decimal)Preset value.
True if a previous preset was found.

RemovePreset

#
public bool RemovePreset(decimal value)
Remove a preset by value.
value (decimal)Value of preset to remove.
True if preset was removed.

RemovePreset

#
public bool RemovePreset(string name)
Remove all presets with a given name.
name (string)Name of preset to remove.
True if preset was removed.

RenderCustom

#
public void RenderCustom(Context context, Action<Context, Slider> drawBack = null, Action<Context, Slider> drawRail = null, Action<Context, Slider> drawGrip = null, Action<Context, Slider> drawText = null, Action<Context, Slider> drawPopup = null)
Render this slider into a graphics context, with optional overrides for various layers.
context (Context)Graphics context.
drawBack (Action<Context, Slider> = null)Optional background override.
drawRail (Action<Context, Slider> = null)Optional rail override.
drawGrip (Action<Context, Slider> = null)Optional grip override.
drawText (Action<Context, Slider> = null)Optional text override.
drawPopup (Action<Context, Slider> = null)Optional popup override.

RenderStandardBack

#
public static void RenderStandardBack(Context context, Slider slider)
Default background render method.
context (Context)Graphics context.
slider (Slider)Slider to render.

RenderStandardGrip

#
public static void RenderStandardGrip(Context context, Slider slider)
Default grip render method.
context (Context)Graphics context.
slider (Slider)Slider to render.

RenderStandardPopup

#
public static void RenderStandardPopup(Context context, Slider slider)
Default numeric popup render method.
context (Context)Graphics context.
slider (Slider)Slider to render.

RenderStandardRail

#
public static void RenderStandardRail(Context context, Slider slider)
Default rail render method.
context (Context)Graphics context.
slider (Slider)Slider to render.

RenderStandardText

#
public static void RenderStandardText(Context context, Slider slider)
Default rail render method.
context (Context)Graphics context.
slider (Slider)Slider to render.

SetLimits

#
public void SetLimits(UiNumber number)
Set new limits and value of this slider.
number (UiNumber)New number.

SnapToPreset

#
public bool SnapToPreset(decimal locus, out decimal result)
Snap a value to the nearest preset in range.
locus (decimal)Value to snap.
result (out decimal)Snapped value, or original value if no snapping occured.
True if value was snapped.

Events

SliderDisplayChanged

#
public event EventHandler<SliderEventArgs> SliderDisplayChanged
This event is raised whenever the slider state, but not the value changes.

SliderValueChanged

#
public event EventHandler<SliderEventArgs> SliderValueChanged
This event is raised whenever the slider value changes.