Browse Source

Simplify GeometryGroup.Children setter

pull/8326/head
Benedikt Stebner 4 years ago
parent
commit
d64b858273
  1. 25
      src/Avalonia.Base/Media/GeometryGroup.cs

25
src/Avalonia.Base/Media/GeometryGroup.cs

@ -14,7 +14,7 @@ namespace Avalonia.Media
AvaloniaProperty.RegisterDirect<GeometryGroup, GeometryCollection> ( AvaloniaProperty.RegisterDirect<GeometryGroup, GeometryCollection> (
nameof(Children), nameof(Children),
o => o.Children, o => o.Children,
(o, v) => o.Children = v); SetChildren);
public static readonly StyledProperty<FillRule> FillRuleProperty = public static readonly StyledProperty<FillRule> FillRuleProperty =
AvaloniaProperty.Register<GeometryGroup, FillRule>(nameof(FillRule)); AvaloniaProperty.Register<GeometryGroup, FillRule>(nameof(FillRule));
@ -29,18 +29,12 @@ namespace Avalonia.Media
{ {
get => _children; get => _children;
set set
{ {
if(_children is GeometryCollection) _children.Parent = null;
{
_children.Parent = null;
}
if (value is GeometryCollection)
{
value.Parent = this;
}
SetAndRaise(ChildrenProperty, ref _children, value); SetAndRaise(ChildrenProperty, ref _children, value);
_children.Parent = this;
} }
} }
@ -66,6 +60,15 @@ namespace Avalonia.Media
return result; return result;
} }
private static void SetChildren(GeometryGroup geometryGroup, GeometryCollection children)
{
geometryGroup.Children.Parent = null;
children.Parent = geometryGroup;
geometryGroup.Children = children;
}
protected override IGeometryImpl? CreateDefiningGeometry() protected override IGeometryImpl? CreateDefiningGeometry()
{ {
if (_children.Count > 0) if (_children.Count > 0)

Loading…
Cancel
Save