Browse Source

Added fallback to resource loading

Krzysztof Krysiński 3 weeks ago
parent
commit
f37a6db8d4

+ 10 - 3
src/PixiEditor/Helpers/Resources/VectorPathResource.cs

@@ -17,12 +17,19 @@ public class VectorPathResource
     public IBrush StrokeColor { get; set; } = new SolidColorBrush(Avalonia.Media.Colors.Black);
     public float StrokeWidth { get; set; } = 1;
     public PathFillType FillType { get; set; } = PathFillType.Winding;
-    
-    public PathVectorData ToVectorPathData()
+
+    public PathVectorData? ToVectorPathData()
     {
+        if (string.IsNullOrWhiteSpace(SvgPath))
+            return null;
+
         VectorPath path = VectorPath.FromSvgPath(SvgPath);
+
+        if (path == null)
+            return null;
+
         path.FillType = FillType;
-        
+
         return new PathVectorData(path)
         {
             StrokeLineCap = StrokeLineCap,

+ 1 - 1
src/PixiEditor/Views/Overlays/Handles/Handle.cs

@@ -96,7 +96,7 @@ public abstract class Handle : IHandle
 
             if (shape is VectorPathResource resource)
             {
-                return resource.ToVectorPathData();
+                return resource.ToVectorPathData() ?? new PathVectorData(VectorPath.FromSvgPath("M 0 0 L 1 0 M 0 0 L 0 1"));
             }
         }