private void btEdit_Click(object sender, EventArgs e) { if (1 == lbProfiles.CheckedItems.Count) { AddEditProfileForm AddEditProfile = new AddEditProfileForm("Edit profile",lbProfiles.CheckedItems[0].ToString()); if (AddEditProfile.ShowDialog(SettingsForm.Instance) == DialogResult.OK) { if (null != Registry.CurrentUser.OpenSubKey(SettingsForm.AppRootKey + '\\' + AddEditProfile.ProfileName)) { MessageBox.Show("Profile " + AddEditProfile.ProfileName + " exists, try again. ", "Edit profile"); } else { CopyKey(Registry.CurrentUser.CreateSubKey(SettingsForm.AppRootKey), lbProfiles.CheckedItems[0].ToString(), AddEditProfile.ProfileName); Registry.CurrentUser.DeleteSubKeyTree(SettingsForm.AppRootKey + '\\' + lbProfiles.CheckedItems[0].ToString()); } } } else { MessageBox.Show("Please, select one profile for editing", "Edit profile"); } fillListProfiles(); }
public string AddProfile() { string vReturn = ""; AddEditProfileForm AddEditProfile = new AddEditProfileForm("New profile", null); if (AddEditProfile.ShowDialog(SettingsForm.Instance) == DialogResult.OK) { if (null != Registry.CurrentUser.OpenSubKey(SettingsForm.AppRootKey + '\\' + AddEditProfile.ProfileName)) { MessageBox.Show("Profile " + AddEditProfile.ProfileName + " exists, try again. ", "New profile"); } else { Registry.CurrentUser.CreateSubKey(SettingsForm.AppRootKey + '\\' + AddEditProfile.ProfileName); vReturn = AddEditProfile.ProfileName; } } return vReturn; }