private void RV_Button_Click(object sender, EventArgs e) { if (sender is Button) { this.Enabled = false; if (Enum.TryParse(((Button)sender).Name, out RandomVariableType rvType)) { var rv = new RandomVariable(rvType); var rvWindow = new RandomVariableWindow(rv); if (rvWindow.ShowDialog() != DialogResult.None) { this.Enabled = true; } } else { this.Enabled = true; } } }