|
@@ -67,7 +67,7 @@ internal class Exporter
|
|
|
/// </summary>
|
|
|
public static SaveResult TrySaveUsingDataFromDialog(DocumentViewModel document, string pathFromDialog, FileType fileTypeFromDialog, out string finalPath, VecI? exportSize = null)
|
|
|
{
|
|
|
- finalPath = FixFileExtension(pathFromDialog, fileTypeFromDialog);
|
|
|
+ finalPath = SupportedFilesHelper.FixFileExtension(pathFromDialog, fileTypeFromDialog);
|
|
|
var saveResult = TrySave(document, finalPath, exportSize);
|
|
|
if (saveResult != SaveResult.Success)
|
|
|
finalPath = "";
|
|
@@ -75,17 +75,6 @@ internal class Exporter
|
|
|
return saveResult;
|
|
|
}
|
|
|
|
|
|
- private static string FixFileExtension(string pathWithOrWithoutExtension, FileType requestedType)
|
|
|
- {
|
|
|
- if (requestedType == FileType.Unset)
|
|
|
- throw new ArgumentException("A valid filetype is required", nameof(requestedType));
|
|
|
-
|
|
|
- var typeFromPath = SupportedFilesHelper.ParseImageFormat(Path.GetExtension(pathWithOrWithoutExtension));
|
|
|
- if (typeFromPath != FileType.Unset && typeFromPath == requestedType)
|
|
|
- return pathWithOrWithoutExtension;
|
|
|
- return AppendExtension(pathWithOrWithoutExtension, SupportedFilesHelper.GetFileTypeDialogData(requestedType));
|
|
|
- }
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// Attempts to save the document into the given location, filetype is inferred from path
|
|
|
/// </summary>
|
|
@@ -120,16 +109,6 @@ internal class Exporter
|
|
|
return SaveResult.Success;
|
|
|
}
|
|
|
|
|
|
- private static string AppendExtension(string path, FileTypeDialogData data)
|
|
|
- {
|
|
|
- string ext = data.Extensions.First();
|
|
|
- string filename = Path.GetFileName(path);
|
|
|
- if (filename.Length + ext.Length > 255)
|
|
|
- filename = filename.Substring(0, 255 - ext.Length);
|
|
|
- filename += ext;
|
|
|
- return Path.Combine(Path.GetDirectoryName(path), filename);
|
|
|
- }
|
|
|
-
|
|
|
static Dictionary<FileType, Func<BitmapEncoder>> encodersFactory = new Dictionary<FileType, Func<BitmapEncoder>>();
|
|
|
|
|
|
static Exporter()
|