Ver Fonte

Duplicating fix

Krzysztof Krysiński há 1 mês atrás
pai
commit
a46bc8403f

+ 7 - 1
src/PixiEditor/ViewModels/SubViewModels/BrushesViewModel.cs

@@ -157,7 +157,7 @@ internal class BrushesViewModel : SubViewModel<ViewModelMain>
     [Command.Internal("PixiEditor.Brushes.Duplicate", "DUPLICATE_BRUSH")]
     [Command.Internal("PixiEditor.Brushes.Duplicate", "DUPLICATE_BRUSH")]
     public void DuplicateBrush(BrushViewModel brushViewModel)
     public void DuplicateBrush(BrushViewModel brushViewModel)
     {
     {
-        if (brushViewModel == null || brushViewModel.IsReadOnly || brushViewModel.Brush == null)
+        if (brushViewModel == null || !brushViewModel.IsDuplicable || brushViewModel.Brush == null)
             return;
             return;
 
 
         if (File.Exists(brushViewModel.Brush.FilePath))
         if (File.Exists(brushViewModel.Brush.FilePath))
@@ -170,6 +170,12 @@ internal class BrushesViewModel : SubViewModel<ViewModelMain>
             File.Copy(brushViewModel.Brush.FilePath, newFilePath);
             File.Copy(brushViewModel.Brush.FilePath, newFilePath);
             Owner.DocumentManagerSubViewModel.OpenDocument(newFilePath);
             Owner.DocumentManagerSubViewModel.OpenDocument(newFilePath);
         }
         }
+        else if(brushViewModel.Brush.Document is DocumentViewModel dvm)
+        {
+            string uniqueName = FileHelper.GetUniqueFileName(
+                Path.Combine(Paths.PathToBrushesFolder, $"{brushViewModel.Brush.Name}_clone.pixi"));
+            Exporter.TrySave(dvm, uniqueName, new ExportConfig(dvm.SizeBindable), null);
+        }
     }
     }
 
 
     [Command.Basic("PixiEditor.Brushes.OpenBrushesFolder", "OPEN_BRUSHES_FOLDER", "OPEN_BRUSHES_FOLDER_DESCRIPTIVE",
     [Command.Basic("PixiEditor.Brushes.OpenBrushesFolder", "OPEN_BRUSHES_FOLDER", "OPEN_BRUSHES_FOLDER_DESCRIPTIVE",