private String GetFileFilters() { FileFilterBuilder builder = new FileFilterBuilder(); IEnumerable <SubtitlesFileFormat> supportedFormats = CreateCurrentFormatFirstSubtitlesFormatsCollection(); foreach (var supportedformat in supportedFormats) { builder.AppendFileFormat(supportedformat.Description, supportedformat.CorrectExtensions); } return(builder.ToString()); }
private string PromptUserForNewFilePath(IDocumentClient client, string fileName, IDocument existingDocument) { string filePath = Path.GetFileName(fileName); FileFilterBuilder fb = new FileFilterBuilder(); string[] extensions = client.Info.Extensions; foreach (string extension in extensions) { fb.AddFileType(client.Info.FileType, extension); } if (extensions.Length > 1) { fb.AddAllFilesWithExtensions(); } string filter = fb.ToString(); FileDialogService.InitialDirectory = client.Info.InitialDirectory; if (FileDialogService.SaveFileName(ref filePath, filter) != FileDialogResult.OK) { return(null); } if (!client.Info.IsCompatiblePath(filePath)) { Outputs.WriteLine(OutputMessageType.Error, "File extension not supported".Localize()); return(null); } // Check that the document isn't already open Uri uri = new Uri(filePath); IDocument openDocument = FindOpenDocument(uri); if (openDocument != null && openDocument != existingDocument) { Outputs.WriteLine(OutputMessageType.Error, "A file with that name is already open".Localize()); return(null); } return(filePath); }
private String GetFileFilters() { if (subtitlesManager.SupportedSubtitlesFormats.Count() == 0) { return(String.Empty); } var supportedSubtitlesFormats = subtitlesManager.SupportedSubtitlesFormats; var extensions = supportedSubtitlesFormats.SelectMany(format => format.CorrectExtensions).Distinct(); FileFilterBuilder builder = new FileFilterBuilder(); builder.AppendFileFormat(Resources.DscAllSupported, extensions); foreach (var supportedSubtitle in supportedSubtitlesFormats) { builder.AppendFileFormat(supportedSubtitle.Description, supportedSubtitle.CorrectExtensions); } return(builder.ToString()); }
private string PromptUserForNewFilePath(IDocumentClient client, string fileName, IDocument existingDocument) { string filePath = Path.GetFileName(fileName); FileFilterBuilder fb = new FileFilterBuilder(); string[] extensions = client.Info.Extensions; foreach (string extension in extensions) fb.AddFileType(client.Info.FileType, extension); if (extensions.Length > 1) fb.AddAllFilesWithExtensions(); string filter = fb.ToString(); FileDialogService.InitialDirectory = client.Info.InitialDirectory; if (FileDialogService.SaveFileName(ref filePath, filter) != FileDialogResult.OK) return null; if (!client.Info.IsCompatiblePath(filePath)) { Outputs.WriteLine(OutputMessageType.Error, "File extension not supported".Localize()); return null; } // Check that the document isn't already open Uri uri = new Uri(filePath); IDocument openDocument = FindOpenDocument(uri); if (openDocument != null && openDocument != existingDocument) { Outputs.WriteLine(OutputMessageType.Error, "A file with that name is already open".Localize()); return null; } return filePath; }
public void ToString_ReturnsExpectedValues(FileFilterBuilder builder, string expected) { builder.ToString().Should().Be(expected); }