private void BtnRename_Click(System.Object sender, System.EventArgs e) { TFrmSettingsRename frmRename; String NewName; String OldName; if (FStoredSettings.IsSystemSettings(LB_ExistingSettings.SelectedItem.ToString())) { MessageBox.Show( "'" + LB_ExistingSettings.SelectedItem.ToString() + "'" + Environment.NewLine + "is a predefined set of settings, and therefore cannot be renamed. " + Environment.NewLine + "You should load it and then save it with a different name!", "Cannot rename System Settings"); return; } frmRename = new TFrmSettingsRename(); frmRename.NewName = LB_ExistingSettings.SelectedItem.ToString(); frmRename.OldName = frmRename.NewName; if (frmRename.ShowDialog() == System.Windows.Forms.DialogResult.OK) { NewName = frmRename.NewName; OldName = frmRename.OldName; if (NewName != OldName) { // don't allow empty name if (NewName.Length == 0) { return; } // check if the name already exists in the list if (this.LB_ExistingSettings.FindStringExact(NewName) != ListBox.NoMatches) { if (FStoredSettings.IsSystemSettings(NewName)) { MessageBox.Show( "\"" + NewName + "\"" + Environment.NewLine + "is a predefined set of settings, and therefore cannot be overwritten. " + Environment.NewLine + "Please choose another name!", "Cannot overwrite System Settings"); return; } // ask if it should be overwritten if (MessageBox.Show("This name already exists. Do you still want to use this name and overwrite the existing settings?", "Overwrite existing Settings?", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No) { return; } } // do the renaming FStoredSettings.RenameSettings(OldName, NewName); LoadSettingsList(); } } }
private void BtnRename_Click(System.Object sender, System.EventArgs e) { TFrmSettingsRename frmRename; String NewName; String OldName; if (FStoredSettings.IsSystemSettings(LB_ExistingSettings.SelectedItem.ToString())) { MessageBox.Show( "'" + LB_ExistingSettings.SelectedItem.ToString() + "'" + Environment.NewLine + "is a predefined set of settings, and therefore cannot be renamed. " + Environment.NewLine + "You should load it and then save it with a different name!", "Cannot rename System Settings"); return; } frmRename = new TFrmSettingsRename(); frmRename.NewName = LB_ExistingSettings.SelectedItem.ToString(); frmRename.OldName = frmRename.NewName; if (frmRename.ShowDialog() == System.Windows.Forms.DialogResult.OK) { NewName = frmRename.NewName; OldName = frmRename.OldName; if (NewName != OldName) { // don't allow empty name if (NewName.Length == 0) { return; } // check if the name already exists in the list if (this.LB_ExistingSettings.FindStringExact(NewName) != ListBox.NoMatches) { if (FStoredSettings.IsSystemSettings(NewName)) { MessageBox.Show( "\"" + NewName + "\"" + Environment.NewLine + "is a predefined set of settings, and therefore cannot be overwritten. " + Environment.NewLine + "Please choose another name!", "Cannot overwrite System Settings"); return; } // ask if it should be overwritten if (MessageBox.Show("This name already exists. Do you still want to use this name and overwrite the existing settings?", "Overwrite existing Settings?", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No) { return; } } // do the renaming FStoredSettings.RenameSettings(OldName, NewName); LoadSettingsList(); } } }