Browse Source

Merge branch 'master' into api/command-invoke

Krzysztof Krysiński 3 months ago
parent
commit
3290699efa

+ 13 - 3
src/PixiEditor.UI.Common/Rendering/IconImage.cs

@@ -41,16 +41,26 @@ public class IconImage : IImage
 
 
     public void Draw(DrawingContext context, Rect sourceRect, Rect destRect)
     public void Draw(DrawingContext context, Rect sourceRect, Rect destRect)
     {
     {
+        DrawingContext.PushedState[]? pushed = null;
         if (RotationAngle != 0)
         if (RotationAngle != 0)
         {
         {
             double radians = RotationAngle * Math.PI / 180;
             double radians = RotationAngle * Math.PI / 180;
-            context.PushTransform(Matrix.CreateTranslation(destRect.Width, destRect.Height));
-            context.PushTransform(Matrix.CreateRotation(radians));
-            context.PushTransform(Matrix.CreateTranslation(destRect.Width / 4f, destRect.Height / 4f));
+            pushed = new DrawingContext.PushedState[3];
+            pushed[0] = context.PushTransform(Matrix.CreateTranslation(destRect.Width, destRect.Height));
+            pushed[1] = context.PushTransform(Matrix.CreateRotation(radians));
+            pushed[2] = context.PushTransform(Matrix.CreateTranslation(destRect.Width / 4f, destRect.Height / 4f));
         }
         }
         
         
         context.DrawText(
         context.DrawText(
             new FormattedText(Icon, CultureInfo.InvariantCulture, FlowDirection.LeftToRight, _typeface, FontSize, Foreground),
             new FormattedText(Icon, CultureInfo.InvariantCulture, FlowDirection.LeftToRight, _typeface, FontSize, Foreground),
             destRect.TopLeft);
             destRect.TopLeft);
+
+        if (pushed != null)
+        {
+            for (int i = pushed.Length - 1; i >= 0; i--)
+            {
+                pushed[i].Dispose();
+            }
+        }
     }
     }
 }
 }

+ 1 - 1
src/PixiEditor/Models/Commands/Search/ColorSearchResult.cs

@@ -64,7 +64,7 @@ internal class ColorSearchResult : SearchResult
     public static DrawingImage GetIcon(Drawie.Backend.Core.ColorsImpl.Color color)
     public static DrawingImage GetIcon(Drawie.Backend.Core.ColorsImpl.Color color)
     {
     {
         var drawing = new GeometryDrawing() { Brush = new SolidColorBrush(color.ToOpaqueMediaColor()), Pen = new Pen(Brushes.White, 1) };
         var drawing = new GeometryDrawing() { Brush = new SolidColorBrush(color.ToOpaqueMediaColor()), Pen = new Pen(Brushes.White, 1) };
-        var geometry = new EllipseGeometry(new Rect(5, 5,5, 5));
+        var geometry = new EllipseGeometry(new Rect(5, 5, 5, 5));
         drawing.Geometry = geometry;
         drawing.Geometry = geometry;
         return new DrawingImage(drawing);
         return new DrawingImage(drawing);
     }
     }

+ 0 - 1
src/PixiEditor/Views/Main/CommandSearch/SearchResultControl.axaml

@@ -29,7 +29,6 @@
                 <ColumnDefinition Width="Auto" />
                 <ColumnDefinition Width="Auto" />
             </Grid.ColumnDefinitions>
             </Grid.ColumnDefinitions>
             <StackPanel Orientation="Horizontal">
             <StackPanel Orientation="Horizontal">
-                <!--TODO: Below causes heap corruption crash randomly when searching-->
                 <Border Width="25" Margin="0,0,5,0" Padding="1">
                 <Border Width="25" Margin="0,0,5,0" Padding="1">
                     <Image HorizontalAlignment="Center" Source="{Binding EvaluatedIcon}" />
                     <Image HorizontalAlignment="Center" Source="{Binding EvaluatedIcon}" />
                 </Border>
                 </Border>