Ejemplo n.º 1
0
        /// <inheritdoc/>
        void IVisualBrushRenderer.RenderVisualBrush(IDrawingContextImpl context, IVisualBrush brush)
        {
            var childScene = TryGetChildScene(_currentDraw);

            if (childScene != null)
            {
                Render(context, (VisualNode)childScene.Root, null, new Rect(childScene.Size));
            }
        }
Ejemplo n.º 2
0
        /// <inheritdoc/>
        void IVisualBrushRenderer.RenderVisualBrush(IDrawingContextImpl context, IVisualBrush brush)
        {
            var childScene = (_currentDraw.Item as BrushDrawOperation)?.ChildScenes?[brush.Visual];

            if (childScene != null)
            {
                Render(context, (VisualNode)childScene.Root, null, new Rect(childScene.Size));
            }
        }
Ejemplo n.º 3
0
 public void RenderVisualBrush(IDrawingContextImpl context, IVisualBrush brush)
 {
     if (VisualBrushDrawList != null)
     {
         foreach (var cmd in VisualBrushDrawList)
         {
             cmd.Item.Render(context);
         }
     }
 }
Ejemplo n.º 4
0
        public TileBrushImplHelper(ITileBrush brush, Size targetSize)
        {
            _imageBrush  = brush as IImageBrush;
            _visualBrush = brush as IVisualBrush;
            if (_imageBrush != null)
            {
                if (_imageBrush.Source == null)
                {
                    return;
                }
                _imageSize = new Size(_imageBrush.Source.PixelWidth, _imageBrush.Source.PixelHeight);
                IsValid    = true;
            }
            else if (_visualBrush != null)
            {
                var control = _visualBrush.Visual as IControl;

                if (control != null)
                {
                    EnsureInitialized(control);

                    if (control.IsArrangeValid == false)
                    {
                        control.Measure(Size.Infinity);
                        control.Arrange(new Rect(control.DesiredSize));
                    }

                    _imageSize = control.Bounds.Size;
                    IsValid    = true;
                }
            }
            else
            {
                return;
            }

            _tileMode        = brush.TileMode;
            _sourceRect      = brush.SourceRect.ToPixels(_imageSize);
            DestinationRect  = brush.DestinationRect.ToPixels(targetSize);
            _scale           = brush.Stretch.CalculateScaling(DestinationRect.Size, _sourceRect.Size);
            _translate       = CalculateTranslate(brush, _sourceRect, DestinationRect, _scale);
            IntermediateSize = CalculateIntermediateSize(_tileMode, targetSize, DestinationRect.Size);
            _transform       = CalculateIntermediateTransform(
                _tileMode,
                _sourceRect,
                DestinationRect,
                _scale,
                _translate,
                out _drawRect);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Configure paint wrapper to use visual brush.
        /// </summary>
        /// <param name="paintWrapper">Paint wrapper.</param>
        /// <param name="visualBrush">Visual brush.</param>
        /// <param name="visualBrushRenderer">Visual brush renderer.</param>
        /// <param name="tileBrushImage">Tile brush image.</param>
        private void ConfigureVisualBrush(ref PaintWrapper paintWrapper, IVisualBrush visualBrush, IVisualBrushRenderer visualBrushRenderer, ref IDrawableBitmapImpl tileBrushImage)
        {
            if (_visualBrushRenderer == null)
            {
                throw new NotSupportedException("No IVisualBrushRenderer was supplied to DrawingContextImpl.");
            }

            var intermediateSize = visualBrushRenderer.GetRenderTargetSize(visualBrush);

            if (intermediateSize.Width >= 1 && intermediateSize.Height >= 1)
            {
                var intermediate = CreateRenderTarget(intermediateSize);

                using (var ctx = intermediate.CreateDrawingContext(visualBrushRenderer))
                {
                    ctx.Clear(Colors.Transparent);

                    visualBrushRenderer.RenderVisualBrush(ctx, visualBrush);
                }

                tileBrushImage = intermediate;
                paintWrapper.AddDisposable(tileBrushImage);
            }
        }
Ejemplo n.º 6
0
 /// <inheritdoc/>
 Size IVisualBrushRenderer.GetRenderTargetSize(IVisualBrush brush)
 {
     return((_currentDraw.Item as BrushDrawOperation)?.ChildScenes?[brush.Visual]?.Size ?? Size.Empty);
 }
Ejemplo n.º 7
0
        /// <inheritdoc/>
        void IVisualBrushRenderer.RenderVisualBrush(IDrawingContextImpl context, IVisualBrush brush)
        {
            var visual = brush.Visual;

            Render(new DrawingContext(context), visual, visual.Bounds);
        }
Ejemplo n.º 8
0
 /// <inheritdoc/>
 Size IVisualBrushRenderer.GetRenderTargetSize(IVisualBrush brush)
 {
     (brush.Visual as IVisualBrushInitialize)?.EnsureInitialized();
     return(brush.Visual?.Bounds.Size ?? Size.Empty);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ImmutableVisualBrush"/> class.
 /// </summary>
 /// <param name="source">The brush from which this brush's properties should be copied.</param>
 public ImmutableVisualBrush(IVisualBrush source)
     : base(source)
 {
     Visual = source.Visual;
 }
Ejemplo n.º 10
0
 /// <inheritdoc/>
 Size IVisualBrushRenderer.GetRenderTargetSize(IVisualBrush brush)
 {
     return(TryGetChildScene(_currentDraw)?.Size ?? Size.Empty);
 }
Ejemplo n.º 11
0
 public Size GetRenderTargetSize(IVisualBrush brush)
 {
     return(VisualBrushDrawList?.Size ?? Size.Empty);
 }
Ejemplo n.º 12
0
 public VisualBrushImpl(IVisualBrush brush, Size destinationSize)
 {
     this.PlatformBrush = TileBrushes.CreateTileBrush(brush, destinationSize);
 }