video-preview/RyzStudio/Windows/ThemedForms/PickerBox/TNumericPickerBox.cs

53 lines
1.2 KiB
C#
Raw Permalink Normal View History

2021-10-03 17:43:59 +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;
}
}
}