Ejemplo n.º 1
0
        public override Visual UpdateVisual(IRenderContext context, Visual oldVisual)
        {
            VisualGroup container = oldVisual as VisualGroup;

            if (container == null || container.Children.Count != 1)
            {
                return(CreateVisual(context));
            }
            var rectangle = container.Children.ElementAt(0) as Rectangle;
            var lastState = container.GetRenderDataCache <PathIconState>();

            if (rectangle == null || lastState == null)
            {
                container.Children.Clear();
                return(CreateVisual(context));
            }

            if (!lastState.Equals(Bounds.Width, Bounds.Height, Pen, Brush))
            {
                UpdateRectangle(rectangle);
                container.SetRenderDataCache(new PathIconState(Bounds.Width, Bounds.Height, Pen, Brush));
            }

            // arrange
            container.SetCanvasArrangeRect(Bounds.ToRectD());
            return(container);
        }
Ejemplo n.º 2
0
        public override Visual UpdateVisual(IRenderContext context, Visual oldVisual)
        {
            VisualGroup container = oldVisual as VisualGroup;

            if (container == null || container.Children.Count != 1)
            {
                return(CreateVisual(context));
            }

            var path      = container.Children.ElementAt(0) as Path;
            var lastState = container.GetRenderDataCache <PathIconState>();

            if (path == null || lastState == null || lastState.width != Bounds.Width || lastState.height != Bounds.Height)
            {
                return(CreateVisual(context));
            }

            if (!Equals(lastState.pen, Pen))
            {
                path.SetPen(Pen);
            }
            if (!Equals(lastState.brush, Brush))
            {
                path.Fill = Brush;
            }

            // arrange visual
            container.SetCanvasArrangeRect(Bounds.ToRectD());
            return(container);
        }