private Control CreateInputControl(LucidityOption option) { Control control; // Create an input control for the option based on the option type switch (option.OptionType) { case SupportedOptionTypes.String: control = new TextBox(); (control as TextBox).Text = Convert.ToString(option.Value); control.Width = 300; (control as TextBox).TextChanged += (s, e) => { option.Value = (s as TextBox).Text; }; break; case SupportedOptionTypes.Bool: control = new CheckBox(); (control as CheckBox).Checked = Convert.ToBoolean(option.Value); (control as CheckBox).CheckStateChanged += (s, e) => { option.Value = (s as CheckBox).Checked; }; break; case SupportedOptionTypes.Integer: control = new NumericUpDown(); (control as NumericUpDown).Value = Convert.ToInt32(option.Value); (control as NumericUpDown).ValueChanged += (s, e) => { option.Value = Convert.ToInt32((s as NumericUpDown).Value); }; break; case SupportedOptionTypes.Decimal: control = new NumericUpDown(); (control as NumericUpDown).DecimalPlaces = 2; (control as NumericUpDown).Value = Convert.ToDecimal(option.Value); (control as NumericUpDown).ValueChanged += (s, e) => { option.Value = (s as NumericUpDown).Value; }; break; default: MessageBox.Show(string.Format("Cannot create an input control for the option type of {0}", option.OptionType.ToString())); control = null; break; } return control; }
public NullOptionValueNotAllowedException(LucidityOption option) : base(string.Format("Attempted to set the Lucidity option of {0} to null, but null option values are not allowed", option.Name)) { }