private void RenameSavestate(Savestate savestate) { using (NameEditForm nameEditForm = new NameEditForm($"Edit {savestate.DisplayName}", "Savestate Name:", savestate.DisplayName)) { if (nameEditForm.ShowDialog() == DialogResult.OK) { if (savestate.DisplayName.Equals(nameEditForm.Input)) { return; } if (Savestate.ExistsInProfile(nameEditForm.Input, currentlySelectedProfile) && !savestate.DisplayName.Equals(nameEditForm.Input, StringComparison.OrdinalIgnoreCase)) { MessageBox.Show($"A savestate named \"{nameEditForm.Input}\" already exists!", "Savestate Already Exists", MessageBoxButtons.OK, MessageBoxIcon.Warning); RenameSavestate(savestate); return; } savestate.ChangeName(nameEditForm.Input); trvSavestates.SelectedNode.Text = nameEditForm.Input; TreeNode nodeToSelect = trvSavestates.SelectedNode; trvSavestates.Sort(); trvSavestates.SelectedNode = nodeToSelect; } } }
private void tsbAddProfile_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(settings.ProfilesDirectory)) { DialogResult result = MessageBox.Show("Please setup your profile directory before creating profiles.", "Setup Required", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); if (result == DialogResult.OK) { btnBrowseProfilesDir.PerformClick(); } return; } using (NameEditForm nameEditForm = new NameEditForm("New Profile", "Profile Name:", string.Empty)) { if (nameEditForm.ShowDialog() == DialogResult.OK) { CreateProfile(nameEditForm.Input); } } }
private void RenameProfile(Profile profile) { using (NameEditForm nameEditForm = new NameEditForm($"Edit {profile.DisplayName}", "Profile Name:", profile.DisplayName)) { if (nameEditForm.ShowDialog() == DialogResult.OK) { if (profile.DisplayName.Equals(nameEditForm.Input)) { return; } if (Profile.Exists(nameEditForm.Input) && !profile.DisplayName.Equals(nameEditForm.Input, StringComparison.OrdinalIgnoreCase)) { MessageBox.Show($"A profile named \"{nameEditForm.Input}\" already exists!", "Profile Already Exists", MessageBoxButtons.OK, MessageBoxIcon.Warning); RenameProfile(currentlySelectedProfile); return; } profile.ChangeName(nameEditForm.Input); RefreshProfilesList(); lstProfiles.SelectedIndex = lstProfiles.Items.IndexOf(profile); } } }