Files
2025-07-14 12:03:59 +02:00

57 lines
1.5 KiB
C#

using System.Reflection;
using Inspectron.Settings.WindowsWizard.Interfaces;
namespace Inspectron.Settings.WindowsWizard.Controls
{
public partial class NumberEditor : UserControl, ISetupItem
{
private PropertyInfo _prp;
private object _obj;
private int _number;
public NumberEditor()
{
InitializeComponent();
}
public int Number
{
get { return _number; }
set
{
if (_obj == null) return;
_number = value;
_prp.SetValue(_obj, value);
}
}
public int Min
{
get => (int)numericUpDown1.Minimum;
set => numericUpDown1.Minimum = value;
}
public int Max
{
get => (int) numericUpDown1.Maximum;
set => numericUpDown1.Maximum = value;
}
public void SetProperty(object obj, string propertyName)
{
label1.Text = PropHelper.SplitCamelCase(propertyName);
_prp = PropHelper.GetPrp(obj, propertyName);
_obj = obj;
numericUpDown1.Value =_number = ((int)_prp.GetValue(obj)<Min?Min: (int)_prp.GetValue(obj));
}
private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{
_number = (int)numericUpDown1.Value;
if(_obj==null)return;
_prp.SetValue(_obj, _number);
}
}
}