Преглед на файлове

Merge branch 'master' of https://github.com/PixiEditor/PixiEditor

Krzysztof Krysiński преди 2 години
родител
ревизия
dbc11618d7

+ 4 - 1
src/PixiEditor/Data/Localization/Languages/en.json

@@ -586,5 +586,8 @@
   "ADD_PRIMARY_COLOR_TO_PALETTE": "Add primary color to palette",
   "ADD_PRIMARY_COLOR_TO_PALETTE": "Add primary color to palette",
   "ADD_PRIMARY_COLOR_TO_PALETTE_DESCRIPTIVE": "Add primary color to current palette",
   "ADD_PRIMARY_COLOR_TO_PALETTE_DESCRIPTIVE": "Add primary color to current palette",
   
   
-  "COPY_COLOR": "Copy color"
+  "COPY_COLOR": "Copy color",
+
+  "FAILED_DOWNLOADING_TITLE": "Downloading update failed",
+  "FAILED_DOWNLOADING": "Failed downloading the update, you might not have enough space on the disk"
 }
 }

+ 1 - 0
src/PixiEditor/Extensions/readme.txt

@@ -0,0 +1 @@
+All the extensions goes in this folder.

+ 1 - 9
src/PixiEditor/Models/AppExtensions/ExtensionLoader.cs

@@ -20,12 +20,12 @@ internal class ExtensionLoader
 
 
     public ExtensionLoader()
     public ExtensionLoader()
     {
     {
-        ValidateExtensionFolder();
         _officialExtensionsKeys.Add("pixieditor.supporterpack", new OfficialExtensionData("supporter-pack.snk", AdditionalContentProduct.SupporterPack));
         _officialExtensionsKeys.Add("pixieditor.supporterpack", new OfficialExtensionData("supporter-pack.snk", AdditionalContentProduct.SupporterPack));
     }
     }
 
 
     public void LoadExtensions()
     public void LoadExtensions()
     {
     {
+        if (!Directory.Exists(Paths.ExtensionsFullPath)) return;
         var directories = Directory.GetDirectories(Paths.ExtensionsFullPath);
         var directories = Directory.GetDirectories(Paths.ExtensionsFullPath);
         foreach (var directory in directories)
         foreach (var directory in directories)
         {
         {
@@ -208,14 +208,6 @@ internal class ExtensionLoader
         extensionType = null;
         extensionType = null;
         return null;
         return null;
     }
     }
-
-    private void ValidateExtensionFolder()
-    {
-        if (!Directory.Exists(Paths.ExtensionsFullPath))
-        {
-            Directory.CreateDirectory(Paths.ExtensionsFullPath);
-        }
-    }
 }
 }
 
 
 internal struct OfficialExtensionData
 internal struct OfficialExtensionData

+ 2 - 1
src/PixiEditor/Models/IO/Importer.cs

@@ -28,8 +28,9 @@ internal class Importer : NotifyableObject
     /// <param name="path">Path of the image.</param>
     /// <param name="path">Path of the image.</param>
     /// <param name="size">New size of the image.</param>
     /// <param name="size">New size of the image.</param>
     /// <returns>WriteableBitmap of imported image.</returns>
     /// <returns>WriteableBitmap of imported image.</returns>
-    public static Surface ImportImage(string path, VecI size)
+    public static Surface? ImportImage(string path, VecI size)
     {
     {
+        if (!Path.Exists(path)) return null;
         Surface original = Surface.Load(path);
         Surface original = Surface.Load(path);
         if (original.Size == size || size == VecI.NegativeOne)
         if (original.Size == size || size == VecI.NegativeOne)
         {
         {

+ 3 - 0
src/PixiEditor/PixiEditor.csproj

@@ -170,6 +170,9 @@
 		<EmbeddedResource Include="OfficialExtensions\supporter-pack.snk" />
 		<EmbeddedResource Include="OfficialExtensions\supporter-pack.snk" />
 		<None Remove="Styles\AvalonDock\Images\**" />
 		<None Remove="Styles\AvalonDock\Images\**" />
 		<Page Remove="Styles\AvalonDock\Images\**" />
 		<Page Remove="Styles\AvalonDock\Images\**" />
+		<None Update="Extensions\readme.txt">
+		  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+		</None>
 	</ItemGroup>
 	</ItemGroup>
 
 
 	<ItemGroup>
 	<ItemGroup>

+ 2 - 0
src/PixiEditor/ViewModels/SubViewModels/Main/FileViewModel.cs

@@ -230,6 +230,8 @@ internal class FileViewModel : SubViewModel<ViewModelMain>
     {
     {
         var image = Importer.ImportImage(path, VecI.NegativeOne);
         var image = Importer.ImportImage(path, VecI.NegativeOne);
 
 
+        if (image == null) return;
+
         var doc = NewDocument(b => b
         var doc = NewDocument(b => b
             .WithSize(image.Size)
             .WithSize(image.Size)
             .WithLayer(l => l
             .WithLayer(l => l

+ 18 - 5
src/PixiEditor/ViewModels/SubViewModels/Main/UpdateViewModel.cs

@@ -79,16 +79,29 @@ internal class UpdateViewModel : SubViewModel<ViewModelMain>
         {
         {
             UpdateReadyToInstall = false;
             UpdateReadyToInstall = false;
             VersionText = new LocalizedString("DOWNLOADING_UPDATE");
             VersionText = new LocalizedString("DOWNLOADING_UPDATE");
-            if (updateCompatible)
+            try
+            {
+                if (updateCompatible)
+                {
+                    await UpdateDownloader.DownloadReleaseZip(UpdateChecker.LatestReleaseInfo);
+                }
+                else
+                {
+                    await UpdateDownloader.DownloadInstaller(UpdateChecker.LatestReleaseInfo);
+                }
+
+                UpdateReadyToInstall = true;
+            }
+            catch (IOException ex)
             {
             {
-                await UpdateDownloader.DownloadReleaseZip(UpdateChecker.LatestReleaseInfo);
+                NoticeDialog.Show("FAILED_DOWNLOADING_TITLE", "FAILED_DOWNLOADING");
+                return false;
             }
             }
-            else
+            catch(TaskCanceledException ex)
             {
             {
-                await UpdateDownloader.DownloadInstaller(UpdateChecker.LatestReleaseInfo);
+                return false;
             }
             }
 
 
-            UpdateReadyToInstall = true;
             return true;
             return true;
         }
         }
 
 

+ 1 - 0
src/PixiEditor/Views/UserControls/Palettes/PaletteViewer.xaml.cs

@@ -112,6 +112,7 @@ internal partial class PaletteViewer : UserControl
     private async Task ImportPalette(string fileName)
     private async Task ImportPalette(string fileName)
     {
     {
         var parser = PaletteProvider.AvailableParsers.FirstOrDefault(x => x.SupportedFileExtensions.Contains(Path.GetExtension(fileName)));
         var parser = PaletteProvider.AvailableParsers.FirstOrDefault(x => x.SupportedFileExtensions.Contains(Path.GetExtension(fileName)));
+        if (parser == null) return;
         var data = await parser.Parse(fileName);
         var data = await parser.Parse(fileName);
         if (data.IsCorrupted || data.Colors.Length == 0) return;
         if (data.IsCorrupted || data.Colors.Length == 0) return;
         Colors.Clear();
         Colors.Clear();