Esempio n. 1
0
        private IDisposable SetBrush(IBrush brush, Size destinationSize)
        {
            _context.Save();

            var       solid = brush as SolidColorBrush;
            var       linearGradientBrush = brush as LinearGradientBrush;
            var       radialGradientBrush = brush as RadialGradientBrush;
            var       imageBrush          = brush as ImageBrush;
            var       visualBrush         = brush as VisualBrush;
            BrushImpl impl = null;

            if (solid != null)
            {
                impl = new SolidColorBrushImpl(solid, opacityOverride);
            }
            else if (linearGradientBrush != null)
            {
                impl = new LinearGradientBrushImpl(linearGradientBrush, destinationSize);
            }
            else if (radialGradientBrush != null)
            {
                impl = new RadialGradientBrushImpl(radialGradientBrush, destinationSize);
            }
            else if (imageBrush != null)
            {
                impl = new ImageBrushImpl(imageBrush, destinationSize);
            }
            else if (visualBrush != null)
            {
                impl = new VisualBrushImpl(visualBrush, destinationSize);
            }
            else
            {
                impl = new SolidColorBrushImpl(null, opacityOverride);
            }

            _context.SetSource(impl.PlatformBrush);
            return(Disposable.Create(() =>
            {
                impl.Dispose();
                _context.Restore();
            }));
        }
Esempio n. 2
0
        private BrushImpl CreateBrushImpl(IBrush brush, Size destinationSize)
        {
            var       solid = brush as ISolidColorBrush;
            var       linearGradientBrush = brush as ILinearGradientBrush;
            var       radialGradientBrush = brush as IRadialGradientBrush;
            var       imageBrush          = brush as IImageBrush;
            var       visualBrush         = brush as IVisualBrush;
            BrushImpl impl = null;

            if (solid != null)
            {
                impl = new SolidColorBrushImpl(solid, opacityOverride);
            }
            else if (linearGradientBrush != null)
            {
                impl = new LinearGradientBrushImpl(linearGradientBrush, destinationSize);
            }
            else if (radialGradientBrush != null)
            {
                impl = new RadialGradientBrushImpl(radialGradientBrush, destinationSize);
            }
            else if (imageBrush != null)
            {
                impl = new ImageBrushImpl(imageBrush, destinationSize);
            }
            else if (visualBrush != null)
            {
                impl = new VisualBrushImpl(visualBrush, destinationSize);
            }
            else
            {
                impl = new SolidColorBrushImpl(null, opacityOverride);
            }

            return(impl);
        }
Esempio n. 3
0
        private BrushImpl CreateBrushImpl(IBrush brush, Size destinationSize)
        {
            var solid = brush as SolidColorBrush;
            var linearGradientBrush = brush as LinearGradientBrush;
            var radialGradientBrush = brush as RadialGradientBrush;
            var imageBrush = brush as ImageBrush;
            var visualBrush = brush as VisualBrush;
            BrushImpl impl = null;

            if (solid != null)
            {
                impl = new SolidColorBrushImpl(solid, opacityOverride);
            }
            else if (linearGradientBrush != null)
            {
                impl = new LinearGradientBrushImpl(linearGradientBrush, destinationSize);
            }
            else if (radialGradientBrush != null)
            {
                impl = new RadialGradientBrushImpl(radialGradientBrush, destinationSize);
            }
            else if (imageBrush != null)
            {
                impl = new ImageBrushImpl(imageBrush, destinationSize);
            }
            else if (visualBrush != null)
            {
                impl = new VisualBrushImpl(visualBrush, destinationSize);
            }
            else
            {
                impl = new SolidColorBrushImpl(null, opacityOverride);
            }

            return impl;
        }