void AddProfile(Profile p = null) { using(var x = new CharactorProfile(p ?? new Profile())) if(x.ShowDialog() == DialogResult.OK) if(Profiles.Any(y => y.Name.Equals(x.Result.Name))) { MessageBox.Show("Profile named '" + x.Result.Name + "' already exists!"); AddProfile(x.Result); } else { Profiles.Add(x.Result); UpdateProfileList(); } }
void EditProfileButtonClick(object sender, EventArgs e) { if(profileListView.SelectedItems.Count != 1) { MessageBox.Show("Please select a profile."); return; } var name = profileListView.SelectedItems.OfType<ListViewItem>().Hd().Text; var p = Profiles.Find(x => x.Name.Equals(name)); using(var d = new CharactorProfile(p.CloneNX())) if(d.ShowDialog() == DialogResult.OK) { Profiles.Remove(p); Profiles.Add(d.Result); UpdateProfileList(); } }