using System.Reflection;
using Inspectron.Settings.WindowsWizard.Interfaces;

namespace Inspectron.Settings.WindowsWizard.Controls
{
    public partial class CheckEditor : UserControl, ISetupItem
    {
        private PropertyInfo _prp;
        private object _obj;

        public CheckEditor()
        {
            InitializeComponent();
        }
        public void SetProperty(object obj, string propertyName)
        {
            checkBox1.Text = PropHelper.SplitCamelCase(propertyName);
            _prp = PropHelper.GetPrp(obj, propertyName);
            _obj = obj;
            checkBox1.Checked = (bool)_prp.GetValue(obj);
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            _prp.SetValue(_obj, checkBox1.Checked);
        }
    }
}
