public void Draw(object context, double width, double height, double dx, double dy, double zx, double zy, double renderScaling) { using var renderer = new SkiaShapeRenderer(_context, _view, _view.SelectionState); using var disposable = new CompositeDisposable(); using var background = SkiaUtil.ToSKPaint(_view.PrintBackground, null, zx, disposable.Disposables); var canvas = context as SKCanvas; canvas.DrawRect(SkiaUtil.ToSKRect(dx, dy, _view.Width + dx, _view.Height + dy), background); _view.CurrentContainer.Draw(canvas, renderer, dx, dy, zx, null, null); }
public void Draw(object context, double width, double height, double dx, double dy, double zx, double zy, double renderScaling) { using var renderer = new SkiaShapeRenderer(_context, _view, _view.SelectionState); using var disposable = new CompositeDisposable(); using var background = SkiaUtil.ToSKPaint(_view.PrintBackground, null, zx, disposable.Disposables); var canvas = context as SKCanvas; canvas.DrawRect(SkiaUtil.ToSKRect(dx, dy, _view.Width + dx, _view.Height + dy), background); var selected = new List <IBaseShape>(_view.SelectionState?.Shapes); foreach (var shape in selected) { if (IsAcceptedShape(shape)) { shape.Draw(canvas, renderer, dx, dy, zx, null, null); } } }
public void Draw(object context, double width, double height, double dx, double dy, double zx, double zy) { bool isStyleLibraryDirty = _context.DocumentContainer.StyleLibrary.IsTreeDirty(); bool isCurrentContainerDirty = _view.CurrentContainer.IsTreeDirty(); bool isWorkingContainerDirty = _view.WorkingContainer.IsTreeDirty(); bool isPointsCurrentContainerDirty = _view.CurrentContainer.IsPointsTreeDirty(); bool isPointsWorkingContainerDirty = _view.WorkingContainer.IsPointsTreeDirty(); bool isShapesCurrentDirty = isCurrentContainerDirty == true || isPointsCurrentContainerDirty == true || _previousZX != zx || _previousZY != zy; bool isShapesWorkingDirty = isWorkingContainerDirty == true || isPointsWorkingContainerDirty == true || _previousZX != zx || _previousZY != zy; if (_pictureShapesCurrent == null || isShapesCurrentDirty == true || isStyleLibraryDirty == true) { if (_pictureShapesCurrent != null) { _pictureShapesCurrent.Dispose(); } _pictureShapesCurrent = RecordPicture(_view, _skiaRenderer, zx, DrawShapesCurrent); } if (_pictureShapesWorking == null || isShapesWorkingDirty == true || isStyleLibraryDirty == true) { if (_pictureShapesWorking != null) { _pictureShapesWorking.Dispose(); } _pictureShapesWorking = RecordPicture(_view, _skiaRenderer, zx, DrawShapesWorking); } bool isSelectionDirty = _view.SelectionState.IsTreeDirty() == true || isShapesCurrentDirty == true || isShapesWorkingDirty == true; if (_view.SelectionState.IsTreeDirty() == true) { _view.SelectionState.Invalidate(); } if (_pictureDecorators == null || isSelectionDirty == true || isStyleLibraryDirty == true) { if (_pictureDecorators != null) { _pictureDecorators.Dispose(); } _pictureDecorators = RecordPicture(_view, _skiaRenderer, zx, DrawDecorators); } if (_picturePoints == null || isSelectionDirty == true || isStyleLibraryDirty == true) { if (_picturePoints != null) { _picturePoints.Dispose(); } _picturePoints = RecordPicture(_view, _skiaRenderer, zx, DrawPoints); } _previousZX = zx; _previousZY = zy; var canvas = context as SKCanvas; if (_view.InputBackground?.Color != null) { canvas.Clear(SkiaUtil.ToSKColor(_view.InputBackground.Color)); } else { canvas.Clear(); } if (_view.WorkBackground != null) { GetSKPaintFill(_view.WorkBackground, null, 1.0, out var brush); canvas.Save(); canvas.Translate((float)dx, (float)dy); canvas.Scale((float)zx, (float)zy); canvas.DrawRect(SkiaUtil.ToSKRect(0.0, 0.0, _view.Width, _view.Height), brush); canvas.Restore(); } // TODO: Fix grid X and Y position. //DrawGrid(canvas, dx, dy, zx, zy); DrawPicture(canvas, _pictureShapesCurrent, dx, dy, zx, zy); DrawPicture(canvas, _pictureShapesWorking, dx, dy, zx, zy); DrawPicture(canvas, _pictureDecorators, dx, dy, zx, zy); DrawPicture(canvas, _picturePoints, dx, dy, zx, zy); if (_enablePictureCache == false) { _picturePoints.Dispose(); _picturePoints = null; _pictureDecorators.Dispose(); _pictureDecorators = null; _pictureShapesWorking.Dispose(); _pictureShapesWorking = null; _pictureShapesCurrent.Dispose(); _pictureShapesCurrent = null; } if (isCurrentContainerDirty == true) { _view.CurrentContainer?.Invalidate(); } if (isWorkingContainerDirty == true) { _view.WorkingContainer?.Invalidate(); } if (isStyleLibraryDirty == true) { _context.DocumentContainer.StyleLibrary?.Invalidate(); } }