vMenu Docs
API ReferenceMenu Items

MenuSliderItem

A menu item with a slider on the right.

A menu item with a slider on the right.


Example usage

// Creating 3 sliders, showing off the 3 possible variations and custom colors.
MenuSliderItem slider = new MenuSliderItem("Slider", 0, 10, 5, false);

MenuSliderItem slider2 = new MenuSliderItem("Slider + Bar", 0, 10, 5, true)
{
    BarColor = System.Drawing.Color.FromArgb(255, 73, 233, 111),
    BackgroundColor = System.Drawing.Color.FromArgb(255, 25, 100, 43)
};

MenuSliderItem slider3 = new MenuSliderItem("Slider + Bar + Icons", "The icons are currently male/female because that's probably the most common use. But any icon can be used!", 0, 10, 5, true)
{
    BarColor = System.Drawing.Color.FromArgb(255, 255, 0, 0),
    BackgroundColor = System.Drawing.Color.FromArgb(255, 100, 0, 0),

    SliderLeftIcon = MenuItem.Icon.MALE,
    SliderRightIcon = MenuItem.Icon.FEMALE
};

// adding the sliders to the menu.
menu.AddMenuItem(slider);
menu.AddMenuItem(slider2);
menu.AddMenuItem(slider3);

Example preview

Example

Reacting to a slider

MenuSliderItem volume = new MenuSliderItem("Volume", 0, 10, 5, true);
menu.AddMenuItem(volume);

// Fires every time the slider moves.
menu.OnSliderPositionChange += (_menu, _sliderItem, _oldPosition, _newPosition, _itemIndex) =>
{
    if (_sliderItem == volume)
    {
        SetVolume(_newPosition / 10f);
    }
};

// Fires when the user presses select on the slider.
menu.OnSliderItemSelect += (_menu, _sliderItem, _sliderPosition, _itemIndex) =>
{
    Debug.WriteLine($"Slider pressed at position {_sliderPosition}.");
};

Sliders do not wrap around. Left at Min or right at Max plays the error sound and does not raise OnSliderPositionChange.


Constructors

ConstructorDescription
MenuSliderItem(string name, int min, int max, int startPosition)No description, no divider.
MenuSliderItem(string name, int min, int max, int startPosition, bool showDivider)No description.
MenuSliderItem(string name, string description, int min, int max, int startPosition)No divider.
MenuSliderItem(string name, string description, int min, int max, int startPosition, bool showDivider)All options set.
ParameterTypeDescription
namestringThe text on the left side of the item.
descriptionstringShown below the menu while the item is highlighted.
minintThe lowest position. Must be lower than max.
maxintThe highest position.
startPositionintThe starting position, between min and max inclusive.
showDividerboolDraws a white divider line in the middle of the slider. Defaults to false.

Min and Max can only be set through a constructor. Position can be changed at any time. A Position outside Min to Max is reset to (Max - Min) / 2 when the row is drawn.


Properties

LeftIcon, RightIcon and Label are not available for MenuSliderItems. Use SliderLeftIcon and SliderRightIcon instead.

PropertyTypeDefault valueDescription
Minintmin argumentRead only. The lowest position.
Maxintmax argumentRead only. The highest position.
PositionintstartPosition argumentThe current position.
ShowDividerboolfalseDraws a white divider line in the middle of the slider.
SliderLeftIconIconIcon.NONEIcon on the left side of the slider.
SliderRightIconIconIcon.NONEIcon on the right side of the slider.
BackgroundColorSystem.Drawing.ColorSystem.Drawing.Color.FromArgb(255, 24, 93, 151)The slider background color.
BarColorSystem.Drawing.ColorSystem.Drawing.Color.FromArgb(255, 53, 165, 223)The slider bar color.

Methods

MenuSliderItem has no methods of its own.

On this page