MenuSliderItem
MenuSliderItem
Section titled “MenuSliderItem”A menu item with a slider on the right.
Example usage
Section titled “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
Section titled “Example preview”
Reacting to a slider
Section titled “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}.");};Constructors
Section titled “Constructors”| Constructor | Description |
|---|---|
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. |
| Parameter | Type | Description |
|---|---|---|
| name | string | The text on the left side of the item. |
| description | string | Shown below the menu while the item is highlighted. |
| min | int | The lowest position. Must be lower than max. |
| max | int | The highest position. |
| startPosition | int | The starting position, between min and max inclusive. |
| showDivider | bool | Draws a white divider line in the middle of the slider. Defaults to false. |
Properties
Section titled “Properties”| Property | Type | Default value | Description |
|---|---|---|---|
| Min | int | min argument |
Read only. The lowest position. |
| Max | int | max argument |
Read only. The highest position. |
| Position | int | startPosition argument |
The current position. |
| ShowDivider | bool | false | Draws a white divider line in the middle of the slider. |
| SliderLeftIcon | Icon | Icon.NONE | Icon on the left side of the slider. |
| SliderRightIcon | Icon | Icon.NONE | Icon on the right side of the slider. |
| BackgroundColor | System.Drawing.Color | System.Drawing.Color.FromArgb(255, 24, 93, 151) | The slider background color. |
| BarColor | System.Drawing.Color | System.Drawing.Color.FromArgb(255, 53, 165, 223) | The slider bar color. |
Methods
Section titled “Methods”MenuSliderItem has no methods of its own.
