private void ExecuteRenameProjectFile(PrintElementFile file) { string Validation(string newName) { if (string.Equals(file.FileName, newName, StringComparison.OrdinalIgnoreCase)) { return(null); } var path = Path.Combine(Path.GetDirectoryName(file.FilePath), newName + file.FileExtension); if (File.Exists(path)) { return(string.Format(_translationManager.GetTranslation(nameof(StringTable.Msg_FileAlreadyExists)), $"{newName}{file.FileExtension}")); } return(null); } var dialog = new RenameDialog( _translationManager.GetTranslation(nameof(StringTable.Title_RenameFile)), string.Format(_translationManager.GetTranslation(nameof(StringTable.Desc_RenameFile)), $"{file.FileName}{file.FileExtension}"), file.FileName, Validation) { Owner = Application.Current.MainWindow, }; if (dialog.ShowDialog() == true) { var newPath = Path.Combine(Path.GetDirectoryName(file.FilePath), dialog.NewName + file.FileExtension); File.Move(file.FilePath, newPath); } }
private void ExecuteDeleteProjectFile(PrintElementFile file) { if (MessageBox.Show( string.Format(_translationManager.GetTranslation(nameof(StringTable.Msg_ConfirmFileDeletion)), $"{file.FileName}{file.FileExtension}"), "CuraManager", AlertButton.YesNo, AlertImage.Question) == AlertResult.No) { return; } File.Delete(file.FilePath); }
private void ExecuteOpenProjectFile(PrintElementFile file) { if (PrintElement.IsCuraProjectFile(file.FilePath)) { _curaService.OpenCuraProject(file.FilePath); } else { Process.Start(new ProcessStartInfo(file.FilePath) { UseShellExecute = true, }); } }
public PrintElementFileSelection(PrintElementFile element) { Element = element; IsEnabled = true; Amount = 1; }