Exemplo n.º 1
0
        private void OnPropertyChanged(ManagedWeakReference instance, DependencyProperty property, DependencyPropertyChangedEventArgs args)
        {
            if (property == FillRuleProperty)
            {
                var rule = FillRule switch
                {
                    FillRule.EvenOdd => "evenodd",
                    FillRule.Nonzero => "nonzero",
                    _ => "evenodd"
                };
                _svgElement.SetAttribute("fill-rule", rule);
            }
            else if (property == ChildrenProperty)
            {
                _svgElement.ClearChildren();

                if (args.OldValue is GeometryCollection oldGeometries)
                {
                    oldGeometries.VectorChanged -= OnGeometriesChanged;
                }

                if (args.NewValue is GeometryCollection newGeometries)
                {
                    newGeometries.VectorChanged += OnGeometriesChanged;

                    newGeometries.SetParent(this);

                    foreach (var child in Children)
                    {
                        _svgElement.AddChild(child.GetSvgElement());
                    }
                }
            }
        }
Exemplo n.º 2
0
        internal override void OnPropertyChanged2(DependencyPropertyChangedEventArgs args)
        {
            base.OnPropertyChanged2(args);

            var property = args.Property;

            if (property == DataProperty)
            {
                _root.ClearChildren();
                _root.AddChild(Data.GetSvgElement());
            }
        }