internal void removeClip() { if (layer != null) { layer.Dispose(); layer = null; } }
public void EndDraw() { End(); if (_drawingLayer != null) { _drawingLayer.Dispose(); _drawingLayer = null; } }
public void StartGroup(string id, float x, float y, float width, float height, bool clipContent) { if (clipContent) { _layers.Add(id, _activeLayerRect); if (_activeLayer != null) { _activeLayer.Dispose(); _activeLayer = null; _activeLayerRect = Rect.Empty; } if (_session != null) { _activeLayerRect = new Rect(x, y, width, height); _activeLayer = _session.CreateLayer(1.0f, _activeLayerRect); } } }
public void DrawText(FormattedText formattedText, Point point, Rect?clipRect) { var text = formattedText.Text; var vector = new System.Numerics.Vector2((float)point.X, (float)point.Y); var brush = formattedText.Brush.ToWin2D(drawingSession); var canvasTextFormat = new CanvasTextFormat { FontSize = formattedText.FontSize, FontWeight = formattedText.FontWeight.ToWin2D(), FontFamily = formattedText.FontName, }; CanvasActiveLayer layer = null; if (clipRect != null) { layer = drawingSession.CreateLayer(new CanvasSolidColorBrush(drawingSession, Colors.Black.ToWin2D()), clipRect.Value.ToWin2D()); } drawingSession.DrawText(text, vector, brush, canvasTextFormat); layer?.Dispose(); }