/// <summary> /// Handles the OK button's Click event. /// </summary> /// <param name="sender">The button object.</param> /// <param name="e">The event arguments.</param> private void btnOk_Click(object sender, EventArgs e) { if (_rename) { // Check for invalid characters. if (NewName.Contains("/") || NewName.Contains("\\")) { MessageBox.Show(Messages.InvalidCharacters, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } } this.DialogResult = DialogResult.OK; }
protected override void ProcessRecord() { if (NewName.Contains("\\")) { NewName = System.IO.Path.GetFileName(NewName); } string newPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(FilePath), NewName); // テスト自動生成 _generator.FilePath(FilePath); _generator.FilePath(newPath); if (File.Exists(FilePath)) { FileSystem.RenameFile(FilePath, NewName); } WriteObject(new FileSummary(newPath, true)); }
public void UpdateUser() { if (!string.IsNullOrWhiteSpace(NewName) && NewName != ActivePlayerName && !NewName.Contains(" ")) { if (_module.TryUpdatePlayerName(ActivePlayer, NewName)) { SetNewName(); UpdateMessage = "Ditt användarnamn är nu bytt till \n" + NewName; SetSuccessMessageBox(); } else { SetErrorMessageBox(); UpdateMessage = "Du har valt ett namn som är \nupptaget - försök igen"; } } else if (NewName == ActivePlayerName) { SetErrorMessageBox(); UpdateMessage = "Du måste ange ett nytt namn"; } else if (NewName == null) { SetErrorMessageBox(); UpdateMessage = "Du måste ange ett namn"; } else if (NewName.Contains(" ")) { SetErrorMessageBox(); UpdateMessage = "Du får inte ha mellanslag i ditt namn"; } else { SetErrorMessageBox(); UpdateMessage = "Något gick fel"; } }