| title | WaynesSlider |
|---|---|
| parent | CustomControls Package |
| permalink | /tB/Packages/CustomControls/WaynesSlider/ |
| has_toc | false |
{: .no_toc }
A horizontal or vertical slider control --- a draggable block over a track --- for editing an integer value within a range. The user can drag the block, click on the track to step the value by one page, or use the arrow keys when the control has focus; an optional auto-increment timer activates while a mouse button is held down on the track.
The control paints three visual states (NormalState, HoverState, FocusedState) controlled by parallel WaynesSliderState sub-objects, each of which has independent fill / border / corner styling for the background and for the block. The current Value is optionally rendered as text on the block --- as a raw integer or as a formatted percentage --- depending on DisplayFormat.
If the control's Height is greater than its Width on first display, the slider defaults to Direction = Vertical; otherwise it defaults to Horizontal.
Private Sub Form_Load()
sldVolume.MinValue = 0
sldVolume.MaxValue = 100
sldVolume.StepValue = 5
sldVolume.PagingStepValue = 10
sldVolume.DisplayFormat = SliderDisplayValueFormat.DisplayPercentage
End Sub
Value is just a Long property --- assigning to it from outside the control moves the block and triggers a repaint. Combined with a WaynesTimer, the slider can animate itself across its range:
Private Sub Form_Load()
sldProgress.MinValue = 0
sldProgress.MaxValue = 100
sldProgress.Value = 0
Timer1.Interval = 50
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
If sldProgress.Value < sldProgress.MaxValue Then
sldProgress.Value = sldProgress.Value + 1
Else
Timer1.Enabled = False
End If
End Sub
- TOC {:toc}
The slider orientation enum, declared inside the WaynesSlider class. Assigned to Direction.
| Constant | Value | Description |
|---|---|---|
| Horizontal{: #horizontal } | 0 | Track runs left-to-right; arrow keys Left / Right step the value. |
| Vertical{: #vertical } | 1 | Track runs top-to-bottom; arrow keys Up / Down step the value. |
How the Value is rendered on the block, declared inside the WaynesSlider class. Assigned to DisplayFormat.
| Constant | Value | Description |
|---|---|---|
| DisplayValue{: #displayvalue } | 0 | Show the raw integer value. |
| DisplayPercentage{: #displaypercentage } | 1 | Show the value as a percentage of the range --- FormatPercent((Value - MinValue) / (MaxValue - MinValue), 1). |
| DisplayNone{: #displaynone } | 2 | No text on the block. |
{: .no_toc }
Which sides of the control are attached to its container during resize. Anchors. Inherited.
{: .no_toc }
Whether the slider is laid out horizontally or vertically. A member of SliderDirection. Default: chosen on first display from the control's aspect ratio (vertical if Height > Width, else horizontal).
{: .no_toc }
How the Value is rendered as text on the block. A member of SliderDisplayValueFormat. Default: DisplayValue.
{: .no_toc }
How the control is docked inside its container. A member of DockMode. Inherited.
{: .no_toc }
The WaynesSliderState used when the control has the keyboard focus and the mouse is not hovering.
{: .no_toc }
The control's height in pixels. PixelCount. Inherited.
{: .no_toc }
The WaynesSliderState used when the mouse is hovering over the block or over the track.
{: .no_toc }
The horizontal offset of the control's left edge from its container, in pixels. PixelCount. Inherited.
{: .no_toc }
The upper bound of the slider's value range. Long. Default: 100.
{: .no_toc }
The lower bound of the slider's value range. Long. Default: 0.
{: .no_toc }
The interval, in milliseconds, between automatic increments of Value while a mouse button is held down on the track. Long. A value of 0 disables auto-repeat.
{: .no_toc }
The unique design-time name of the control on its parent form. String. Inherited.
{: .no_toc }
The WaynesSliderState used when the slider is idle --- not hovered, not focused.
{: .no_toc }
How far Value moves when the user clicks on the track outside the block (or holds a mouse button down on the track). Long. Default: 1.
{: .no_toc }
The granularity of the slider --- Value is rounded to a multiple of StepValue offset from MinValue before each paint. Long. Default: 1.
{: .no_toc }
The position of the control in the form's TAB-key navigation order. Long. Inherited.
{: .no_toc }
Whether the user can reach the control by pressing TAB. Boolean. Inherited. Default: True.
{: .no_toc }
The vertical offset of the control's top edge from its container, in pixels. PixelCount. Inherited.
{: .no_toc }
The current position of the block within the range, as an integer. Long. Clamped to [MinValue, MaxValue] at paint time unless WrapAround is True.
Syntax: object.Value [ = value ]
{: .no_toc }
Whether the control is currently displayed. Boolean. Inherited. Default: True.
{: .no_toc }
The control's width in pixels. PixelCount. Inherited.
{: .no_toc }
When False (the default), Value is clamped to the range [MinValue, MaxValue]. When True, values outside the range are allowed and the block wraps around --- the slider paints additional block instances on the opposite edge to give a continuous visual. Boolean.