Пример #1
0
 private void Add(SKDocument pdf, PageContainer container)
 {
     using (var canvas = pdf.BeginPage((float)container.Template.Width, (float)container.Template.Height))
     {
         _presenter.Render(canvas, _renderer, container, 0, 0);
     }
 }
Пример #2
0
 void Save(string path, XContainer container)
 {
     using (var stream = new SKFileWStream(path))
         using (var writer = new SKXmlStreamWriter(stream))
             using (var canvas = SKSvgCanvas.Create(SKRect.Create(0, 0, (int)container.Width, (int)container.Height), writer))
             {
                 _presenter.Render(canvas, _renderer, container, 0, 0);
             }
 }
Пример #3
0
        private void OnPaintSurface(SKCanvas canvas, int width, int height)
        {
            var    matrix  = PresentationSource.FromVisual(this).CompositionTarget.TransformToDevice;
            double offsetX = (this.canvas.ActualWidth * matrix.M11 - _container?.Width ?? 0) / 2.0;
            double offsetY = (this.canvas.ActualHeight * matrix.M22 - _container?.Height ?? 0) / 2.0;

            canvas.Clear(SKColors.White);
            _presenter?.Render(canvas, _renderer, _container, offsetX, offsetY);
        }
        /// <summary>
        /// Renders container control contents.
        /// </summary>
        /// <param name="context">The drawing context.</param>
        public override void Render(DrawingContext context)
        {
            base.Render(context);

            if (Container != null)
            {
                if (Renderer != null)
                {
                    _templatePresenter.Render(context, Renderer, Container, 0.0, 0.0);
                    _editorPresenter.Render(context, Renderer, Container, 0.0, 0.0);
                }
                else
                {
                    var renderer = GetValue(RendererOptions.RendererProperty);
                    if (renderer != null)
                    {
                        _templatePresenter.Render(context, renderer, Container, 0.0, 0.0);
                        _editorPresenter.Render(context, renderer, Container, 0.0, 0.0);
                    }
                }
            }
        }
Пример #5
0
        void Save(string path, PageContainer container)
        {
            var info = new SKImageInfo((int)container.Width, (int)container.Height);

            using (var bitmap = new SKBitmap(info))
            {
                using (var canvas = new SKCanvas(bitmap))
                {
                    _presenter.Render(canvas, _renderer, container, 0, 0);
                }
                using (var image = SKImage.FromBitmap(bitmap))
                    using (var data = image.Encode(SKEncodedImageFormat.Ico, 100))
                        using (var stream = File.OpenWrite(path))
                        {
                            data.SaveTo(stream);
                        }
            }
        }