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

Loading…
Cancel
Save