Răsfoiți Sursa

PR comments

Eli Arbel 8 ani în urmă
părinte
comite
c434cb215a

+ 9 - 9
src/Avalonia.Controls/DrawingPresenter.cs

@@ -6,9 +6,18 @@ namespace Avalonia.Controls
 {
     public class DrawingPresenter : Control
     {
+        static DrawingPresenter()
+        {
+            AffectsMeasure(DrawingProperty);
+            AffectsRender(DrawingProperty);
+        }
+
         public static readonly StyledProperty<Drawing> DrawingProperty =
             AvaloniaProperty.Register<DrawingPresenter, Drawing>(nameof(Drawing));
 
+        public static readonly StyledProperty<Stretch> StretchProperty =
+            AvaloniaProperty.Register<DrawingPresenter, Stretch>(nameof(Stretch), Stretch.Uniform);
+
         [Content]
         public Drawing Drawing
         {
@@ -16,21 +25,12 @@ namespace Avalonia.Controls
             set => SetValue(DrawingProperty, value);
         }
 
-        public static readonly StyledProperty<Stretch> StretchProperty =
-            AvaloniaProperty.Register<DrawingPresenter, Stretch>(nameof(Stretch), Stretch.Uniform);
-
         public Stretch Stretch
         {
             get => GetValue(StretchProperty);
             set => SetValue(StretchProperty, value);
         }
 
-        static DrawingPresenter()
-        {
-            AffectsMeasure(DrawingProperty);
-            AffectsRender(DrawingProperty);
-        }
-
         private Matrix _transform = Matrix.Identity;
 
         protected override Size MeasureOverride(Size availableSize)

+ 1 - 1
src/Avalonia.Visuals/Matrix.cs

@@ -302,7 +302,7 @@ namespace Avalonia
         /// </summary>
         /// <param name="s">The string.</param>
         /// <param name="culture">The current culture.</param>
-        /// <returns>The <see cref="Thickness"/>.</returns>
+        /// <returns>The <see cref="Matrix"/>.</returns>
         public static Matrix Parse(string s, CultureInfo culture)
         {
             var parts = s.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries)

+ 6 - 6
src/Avalonia.Visuals/Media/DrawingGroup.cs

@@ -5,27 +5,27 @@ namespace Avalonia.Media
 {
     public class DrawingGroup : Drawing
     {
-        [Content]
-        public AvaloniaList<Drawing> Children { get; } = new AvaloniaList<Drawing>();
-
         public static readonly StyledProperty<double> OpacityProperty =
             AvaloniaProperty.Register<DrawingGroup, double>(nameof(Opacity), 1);
 
+        public static readonly StyledProperty<Transform> TransformProperty =
+            AvaloniaProperty.Register<DrawingGroup, Transform>(nameof(Transform));
+
         public double Opacity
         {
             get => GetValue(OpacityProperty);
             set => SetValue(OpacityProperty, value);
         }
 
-        public static readonly StyledProperty<Transform> TransformProperty =
-            AvaloniaProperty.Register<DrawingGroup, Transform>(nameof(Transform));
-
         public Transform Transform
         {
             get => GetValue(TransformProperty);
             set => SetValue(TransformProperty, value);
         }
 
+        [Content]
+        public AvaloniaList<Drawing> Children { get; } = new AvaloniaList<Drawing>();
+
         public override void Draw(DrawingContext context)
         {
             using (context.PushPreTransform(Transform?.Value ?? Matrix.Identity))

+ 7 - 11
src/Avalonia.Visuals/Media/PolylineGeometry.cs

@@ -26,13 +26,15 @@ namespace Avalonia.Media
         public static readonly AvaloniaProperty<bool> IsFilledProperty =
             AvaloniaProperty.Register<PolylineGeometry, bool>(nameof(IsFilled));
 
+        private Points _points;
+        private bool _isDirty;
+        private IDisposable _pointsObserver;
+
         static PolylineGeometry()
         {
-            PointsProperty.Changed.Subscribe(onNext: v =>
-            {
-                (v.Sender as PolylineGeometry)?.OnPointsChanged(v.OldValue as Points, v.NewValue as Points);
-            });
-            IsFilledProperty.Changed.AddClassHandler<PolylineGeometry>(x => a => x.NotifyChanged());
+            PointsProperty.Changed.AddClassHandler<PolylineGeometry>((s, e) =>
+                s.OnPointsChanged(e.OldValue as Points, e.NewValue as Points));
+            IsFilledProperty.Changed.AddClassHandler<PolylineGeometry>((s, _) => s.NotifyChanged());
         }
 
         /// <summary>
@@ -53,8 +55,6 @@ namespace Avalonia.Media
         {
             Points.AddRange(points);
             IsFilled = isFilled;
-
-            PrepareIfNeeded();
         }
 
         public void PrepareIfNeeded()
@@ -109,10 +109,6 @@ namespace Avalonia.Media
             protected set => base.PlatformImpl = value;
         }
 
-        private Points _points;
-        private bool _isDirty;
-        private IDisposable _pointsObserver;
-
         /// <inheritdoc/>
         public override Geometry Clone()
         {