예제 #1
0
        public void SetShape(IVisualElementRenderer renderer, IBackgroundShape newShape)
        {
            _renderer = renderer;

            if (_shape != newShape)
            {
                if (_shape != null)
                {
                    _shape.ShapeInvalidateRequested -= OnShapeInvalidateRequested;
                }

                if (newShape != null)
                {
                    newShape.ShapeInvalidateRequested += OnShapeInvalidateRequested;
                }

                _shape = newShape;

                _pathProvider?.Dispose();
                _pathProvider = PathProvidersContainer.Resolve(_shape.GetType());

                if (_pathProvider != null)
                {
                    _pathProvider.SetShape(newShape);
                    _renderer?.NativeView?.FindLayerOfType <GradientStrokeLayer>()?.SetPathProvider(_pathProvider);
                }
            }

            Invalidate();
        }
        public void SetShape(AView view, IBackgroundShape newShape)
        {
            _nativeView = view;

            if (_shape != newShape)
            {
                if (_shape != null)
                {
                    _shape.ShapeInvalidateRequested -= OnShapeInvalidateRequested;
                }

                if (newShape != null)
                {
                    newShape.ShapeInvalidateRequested += OnShapeInvalidateRequested;
                }

                _shape = newShape;

                PathProvider?.Dispose();
                PathProvider = PathProvidersContainer.Resolve(_shape.GetType());

                if (PathProvider != null)
                {
                    PathProvider.SetShape(newShape);
                    _nativeView?.GetGradientDrawable()?.SetPathProvider(PathProvider);
                }
            }

            Invalidate();
        }