Browse Source

Merge pull request #3233 from AvaloniaUI/shape-fix

Simplify Shape AffectsGeometry
pull/3250/head
Benedikt Stebner 7 years ago
committed by GitHub
parent
commit
d40368120e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      src/Avalonia.Controls/Shapes/Shape.cs

15
src/Avalonia.Controls/Shapes/Shape.cs

@ -2,7 +2,6 @@
// Licensed under the MIT license. See licence.md file in the project root for full license information. // Licensed under the MIT license. See licence.md file in the project root for full license information.
using System; using System;
using System.Reflection;
using Avalonia.Collections; using Avalonia.Collections;
using Avalonia.Media; using Avalonia.Media;
@ -166,12 +165,9 @@ namespace Avalonia.Controls.Shapes
{ {
property.Changed.Subscribe(e => property.Changed.Subscribe(e =>
{ {
var senderType = e.Sender.GetType().GetTypeInfo(); if (e.Sender is TShape shape)
var affectedType = typeof(TShape).GetTypeInfo();
if (affectedType.IsAssignableFrom(senderType))
{ {
AffectsGeometryInvalidate(e); AffectsGeometryInvalidate(shape, e);
} }
}); });
} }
@ -322,13 +318,8 @@ namespace Avalonia.Controls.Shapes
return (size, transform); return (size, transform);
} }
private static void AffectsGeometryInvalidate(AvaloniaPropertyChangedEventArgs e) private static void AffectsGeometryInvalidate(Shape control, AvaloniaPropertyChangedEventArgs e)
{ {
if (!(e.Sender is Shape control))
{
return;
}
// If the geometry is invalidated when Bounds changes, only invalidate when the Size // If the geometry is invalidated when Bounds changes, only invalidate when the Size
// portion changes. // portion changes.
if (e.Property == BoundsProperty) if (e.Property == BoundsProperty)

Loading…
Cancel
Save