/// <summary> /// Wraps all text boxes for floats in a validator and registers the proper events /// </summary> private void WrapFloatTextBoxes() { // Value type single var validator = FloatTextBoxValidator.Create(AffixValueTypeSingleMinTextBox, "0"); validator.TextChanged += textbox => { localBaseValueMinSingle = FloatTextBoxValidator.GetValue(textbox); CheckAffixValueTypeSingleChanged(); }; validator = FloatTextBoxValidator.Create(AffixValueTypeSingleMaxTextBox, "0"); validator.TextChanged += textbox => { localBaseValueMaxSingle = FloatTextBoxValidator.GetValue(textbox); CheckAffixValueTypeSingleChanged(); }; // Value type range validator = FloatTextBoxValidator.Create(AffixValueTypeRangeMinMinTextBox, "0"); validator.TextChanged += textbox => { localBaseValueMinRange.MinValue = FloatTextBoxValidator.GetValue(textbox); CheckAffixValueTypeRangeMinChanged(); }; validator = FloatTextBoxValidator.Create(AffixValueTypeRangeMinMaxTextBox, "0"); validator.TextChanged += textbox => { localBaseValueMinRange.MaxValue = FloatTextBoxValidator.GetValue(textbox); CheckAffixValueTypeRangeMinChanged(); }; validator = FloatTextBoxValidator.Create(AffixValueTypeRangeMaxMinTextBox, "0"); validator.TextChanged += textbox => { localBaseValueMaxRange.MinValue = FloatTextBoxValidator.GetValue(textbox); CheckAffixValueTypeRangeMaxChanged(); }; validator = FloatTextBoxValidator.Create(AffixValueTypeRangeMaxMaxTextBox, "0"); validator.TextChanged += textbox => { localBaseValueMaxRange.MaxValue = FloatTextBoxValidator.GetValue(textbox); CheckAffixValueTypeRangeMaxChanged(); }; }
public EditProgressionParametersForm(float[] parameters) { originalParameters = parameters; Parameters = new float[parameters.Length]; parameters.CopyTo(Parameters, 0); for (int i = 0; i < parameters.Length; i++) { TextBox textbox = new TextBox { Location = new Point(10, 10 + (i * TEXTBOX_SPACING)), Text = parameters[i].ToString() }; FloatTextBoxValidator validator = FloatTextBoxValidator.Create(textbox); int index = i; validator.TextChanged += (_) => { Parameters[index] = FloatTextBoxValidator.GetValue(textbox); }; Controls.Add(textbox); } InitializeComponent(); Height = parameters.Length * TEXTBOX_SPACING + 100; }