private void btnSaveCurrentOptions_Click(object sender, EventArgs e) { // ToDo: check that name is OK string profileName = tbProfileName.Text; if (string.IsNullOrEmpty(profileName)) { MessageBox.Show("Profile name should not be empty!", "Profile name is incorrect"); return; } //bool bReplace = false; //if (lbProfiles.SelectedItem != null) //{ // Profile currentProfile = (Profile) lbProfiles.SelectedItem; // bReplace = (currentProfile.Name != profileName && // _controller.Profiles.Where(p => p.Name == profileName).FirstOrDefault() != null); //} //else //{ // bReplace = _controller.Profiles.Where(p => p.Name == profileName).FirstOrDefault() != null; //} //if (bReplace) //{ // DialogResult result = MessageBox.Show(string.Format("Profile {0} will be replaced. Continue?", profileName), "Warning!", // MessageBoxButtons.OKCancel); // if (result == DialogResult.Cancel) // { // return; // } //} Profile newProfile = _controller.SaveCurrentProfile(profileName); lbProfiles.DataSource = null; lbProfiles.DisplayMember = "Name"; lbProfiles.DataSource = _controller.Profiles; lbProfiles.SelectedItem = newProfile; }