random-file-runner/RyzStudio/Windows/ThemedForms/PickerBox/TNumericPickerBox.cs

53 lines
1.2 KiB
C#
Raw Normal View History

2021-10-24 15:49:48 +00:00
using RyzStudio.Windows.Forms;
using System.Windows.Forms;
namespace RyzStudio.Windows.ThemedForms
{
public class TNumericPickerBox : TPickerBox
{
protected int minimumValue = 0;
protected int maximumValue = 50;
public TNumericPickerBox() : base()
{
this.ComboBox.MaxDropDownItems = 10;
this.Clear();
}
public ComboBox InnerControl { get => this.ComboBox; }
public int Value
{
get => (ThreadControl.GetValue(this.ComboBox) + minimumValue);
set => ThreadControl.SetValue(this.ComboBox, (value - minimumValue));
}
public void Clear()
{
ThreadControl.Clear(this.ComboBox);
ThreadControl.Add(this.ComboBox, "0");
ThreadControl.SetValue(this.ComboBox, 0);
}
public void Clear(int min, int max, int value)
{
minimumValue = min;
maximumValue = max;
ThreadControl.Clear(this.ComboBox);
for (int i=min; i< max; i++)
{
ThreadControl.Add(this.ComboBox, i.ToString());
}
this.Value = value;
}
}
}