Example #1
0
 public StringSetterControl()
 {
     InitializeComponent();
     tbValue.TextChanged += (o, e) => _setterImpl.Value = tbValue.Text;
     _setterImpl = new SetterImpl();
     _setterImpl.ValueChanged += () => tbValue.Text = _setterImpl.Value != null ? _setterImpl.Value.ToString() : "";
     _setterImpl.Value = "";
 }
Example #2
0
        public NumericSetterControl(decimal min, decimal max, bool @float)
        {
            InitializeComponent();

            this.Load += (o, e) =>
            {
                this.ParentForm.FormClosing += (o1, e1) =>
                {
                    _setterImpl.Value = nudValue.Value;
                };
            };
            
            nudValue.Maximum = max;
            nudValue.Minimum = min;
            nudValue.ThousandsSeparator = true;
            if (!@float)
                nudValue.DecimalPlaces = 0;

            nudValue.KeyUp += (o, e) =>
                _setterImpl.Value = nudValue.Value;

            _setterImpl = new SetterImpl();
            _setterImpl.ValueChanged += () =>
            {
                if (_setterImpl.Value != null)
                    nudValue.Value = Convert.ToDecimal(_setterImpl.Value);
            };
            _setterImpl.ModeChanged += () =>
            {
                if (_setterImpl.Mode == AppendType.Decrement)
                    cbMode.SelectedIndex = 2;
                else if (_setterImpl.Mode == AppendType.Equalize)
                    cbMode.SelectedIndex = 0;
                else if (_setterImpl.Mode == AppendType.Increment)
                    cbMode.SelectedIndex = 1;
                else throw new Exception("unknown mode");
            };
            cbMode.SelectedIndexChanged += (o, e) =>
            {
                if (cbMode.SelectedIndex == 0)
                    _setterImpl.Mode = AppendType.Equalize;
                else if (cbMode.SelectedIndex == 1)
                    _setterImpl.Mode = AppendType.Increment;
                else if (cbMode.SelectedIndex == 2)
                    _setterImpl.Mode = AppendType.Decrement;
                else throw new Exception("unknown mode");
            };
            cbMode.SelectedIndex = 0;

            if (0 >= min && 0 <= max)
                nudValue.Value = 0;
            else nudValue.Value = min;
        }
Example #3
0
        public BoolSetterControl()
        {
            InitializeComponent();
            cbValue.SelectedIndexChanged += (o, e) => _setterImpl.Value = cbValue.SelectedIndex == 0 ? true : false;
            _setterImpl = new SetterImpl();
            _setterImpl.ValueChanged += () =>
            {
                if (_setterImpl.Value != null)
                    cbValue.SelectedIndex = (bool)_setterImpl.Value ? 0 : 1;
            };

            _setterImpl.InvertOnRepeatChanged += () => this.cbInvert.Checked = _setterImpl.InvertOnRepeat;

            _setterImpl.Value = true;
            cbValue.Enabled = !_setterImpl.InvertOnRepeat;
            cbInvert.Checked = _setterImpl.InvertOnRepeat;
        }
Example #4
0
 public ListSetterControl(string[] values)
 {
     InitializeComponent();
     _setterImpl = new SetterImpl();
     cbValue.SelectedIndexChanged += (o, e) =>
     {
         _setterImpl.Value = cbValue.SelectedItem.ToString();
     };
     foreach (var value in values)
     {
         cbValue.Items.Add(value);
     }
     if (cbValue.Items.Count > 0)
         cbValue.SelectedIndex = 0;
     _setterImpl = new SetterImpl();
     _setterImpl.ValueChanged += () =>
     {
         if (_setterImpl.Value != null)
             cbValue.SelectedItem = _setterImpl.Value.ToString();
     };
     _setterImpl.Value = values.FirstOrDefault();
 }
Example #5
0
 public ValueSetter()
 {
     InitializeComponent();
     Setter = new SetterImpl();
 }