|
@@ -10,6 +10,7 @@ using PixiEditor.DrawingApi.Core.Surface.ImageData;
|
|
using PixiEditor.DrawingApi.Core.Surface.PaintImpl;
|
|
using PixiEditor.DrawingApi.Core.Surface.PaintImpl;
|
|
using PixiEditor.Exceptions;
|
|
using PixiEditor.Exceptions;
|
|
using PixiEditor.Helpers;
|
|
using PixiEditor.Helpers;
|
|
|
|
+using PixiEditor.Localization;
|
|
using PixiEditor.Models.DataHolders;
|
|
using PixiEditor.Models.DataHolders;
|
|
using PixiEditor.Parser;
|
|
using PixiEditor.Parser;
|
|
using PixiEditor.Parser.Deprecated;
|
|
using PixiEditor.Parser.Deprecated;
|
|
@@ -51,13 +52,17 @@ internal class Importer : NotifyableObject
|
|
|
|
|
|
return BitmapFactory.ConvertToPbgra32Format(bitmap);
|
|
return BitmapFactory.ConvertToPbgra32Format(bitmap);
|
|
}
|
|
}
|
|
- catch (NotSupportedException)
|
|
|
|
|
|
+ catch (NotSupportedException e)
|
|
{
|
|
{
|
|
- throw new CorruptedFileException($"The file type '{Path.GetExtension(path)}' is not supported");
|
|
|
|
|
|
+ throw new InvalidFileTypeException(new LocalizedString("FILE_EXTENSION_NOT_SUPPORTED", Path.GetExtension(path)), e);
|
|
}
|
|
}
|
|
- catch (FileFormatException)
|
|
|
|
|
|
+ catch (FileFormatException e)
|
|
{
|
|
{
|
|
- throw new CorruptedFileException("The file appears to be corrupted");
|
|
|
|
|
|
+ throw new CorruptedFileException("FAILED_TO_OPEN_FILE", e);
|
|
|
|
+ }
|
|
|
|
+ catch (Exception e)
|
|
|
|
+ {
|
|
|
|
+ throw new RecoverableException("ERROR_IMPORTING_IMAGE", e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -79,7 +84,7 @@ internal class Importer : NotifyableObject
|
|
}
|
|
}
|
|
catch (InvalidFileException e)
|
|
catch (InvalidFileException e)
|
|
{
|
|
{
|
|
- throw new CorruptedFileException("The given file seems to be corrupted or from a newer version of PixiEditor", e);
|
|
|
|
|
|
+ throw new CorruptedFileException("FAILED_TO_OPEN_FILE", e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -102,7 +107,7 @@ internal class Importer : NotifyableObject
|
|
}
|
|
}
|
|
catch (InvalidFileException e)
|
|
catch (InvalidFileException e)
|
|
{
|
|
{
|
|
- throw new CorruptedFileException("The given file seems to be corrupted or from a newer version of PixiEditor", e);
|
|
|
|
|
|
+ throw new CorruptedFileException("FAILED_TO_OPEN_FILE", e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -111,17 +116,9 @@ internal class Importer : NotifyableObject
|
|
{
|
|
{
|
|
if (!IsSupportedFile(path))
|
|
if (!IsSupportedFile(path))
|
|
{
|
|
{
|
|
- throw new ArgumentException($"The file type '{Path.GetExtension(path)}' is not supported");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- try
|
|
|
|
- {
|
|
|
|
- return Path.GetExtension(path) != ".pixi" ? ImportWriteableBitmap(path) : PixiParser.Deserialize(path).ToDocument().PreviewBitmap;
|
|
|
|
- }
|
|
|
|
- catch (InvalidFileException)
|
|
|
|
- {
|
|
|
|
- throw new CorruptedFileException();
|
|
|
|
|
|
+ throw new InvalidFileTypeException(new LocalizedString("FILE_EXTENSION_NOT_SUPPORTED", Path.GetExtension(path)));
|
|
}
|
|
}
|
|
|
|
+ return Path.GetExtension(path) != ".pixi" ? ImportWriteableBitmap(path) : PixiParser.Deserialize(path).ToDocument().PreviewBitmap;
|
|
}
|
|
}
|
|
|
|
|
|
public static bool IsSupportedFile(string path)
|
|
public static bool IsSupportedFile(string path)
|