private void settingsButton_Click(object sender, EventArgs e) { ShowForm(settingsForm, () => (settingsForm = new SettingsForm(drone))); }
public Binding(SettingsForm settings, Control control, string dataMember) { this.Settings = settings; this.Control = control; this.DataMember = dataMember; this.memberParts = dataMember.Split('.'); if (control is TextBox) { controlProperty = control.GetType().GetProperty("Text"); (control as TextBox).TextChanged += (s, e) => UpdateData(); } else if (control is NumericUpDown) { controlProperty = control.GetType().GetProperty("Value"); (control as NumericUpDown).ValueChanged += (s, e) => UpdateData(); } else if (control is CheckBox) { controlProperty = control.GetType().GetProperty("Checked"); (control as CheckBox).CheckedChanged += (s, e) => UpdateData(); } else throw new NotSupportedException("Control type not supported"); NotifyValueChanged(); }