/// <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)); } }
/// <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)); } }
public void RenderVisualBrush(IDrawingContextImpl context, IVisualBrush brush) { if (VisualBrushDrawList != null) { foreach (var cmd in VisualBrushDrawList) { cmd.Item.Render(context); } } }
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); }
/// <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); } }
/// <inheritdoc/> Size IVisualBrushRenderer.GetRenderTargetSize(IVisualBrush brush) { return((_currentDraw.Item as BrushDrawOperation)?.ChildScenes?[brush.Visual]?.Size ?? Size.Empty); }
/// <inheritdoc/> void IVisualBrushRenderer.RenderVisualBrush(IDrawingContextImpl context, IVisualBrush brush) { var visual = brush.Visual; Render(new DrawingContext(context), visual, visual.Bounds); }
/// <inheritdoc/> Size IVisualBrushRenderer.GetRenderTargetSize(IVisualBrush brush) { (brush.Visual as IVisualBrushInitialize)?.EnsureInitialized(); return(brush.Visual?.Bounds.Size ?? Size.Empty); }
/// <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; }
/// <inheritdoc/> Size IVisualBrushRenderer.GetRenderTargetSize(IVisualBrush brush) { return(TryGetChildScene(_currentDraw)?.Size ?? Size.Empty); }
public Size GetRenderTargetSize(IVisualBrush brush) { return(VisualBrushDrawList?.Size ?? Size.Empty); }
public VisualBrushImpl(IVisualBrush brush, Size destinationSize) { this.PlatformBrush = TileBrushes.CreateTileBrush(brush, destinationSize); }