Ejemplo n.º 1
0
 private void Add(SKDocument pdf, IPageContainer container)
 {
     using (var canvas = pdf.BeginPage((float)container.Template.Width, (float)container.Template.Height))
     {
         _presenter.Render(canvas, _renderer, container, 0, 0);
     }
 }
Ejemplo n.º 2
0
 /// <inheritdoc/>
 public void Save(Stream stream, IPageContainer container)
 {
     using var wstream = new SKManagedWStream(stream);
     using var writer  = new SKXmlStreamWriter(wstream);
     using var canvas  = SKSvgCanvas.Create(SKRect.Create(0, 0, (int)container.Width, (int)container.Height), writer);
     _presenter.Render(canvas, _renderer, container, 0, 0);
 }
Ejemplo n.º 3
0
 public void Save(Stream stream, PageContainerViewModel container)
 {
     using var pictureRecorder = new SKPictureRecorder();
     using var canvas          = pictureRecorder.BeginRecording(SKRect.Create(0, 0, (int)container.Template.Width, (int)container.Template.Height));
     _presenter.Render(canvas, _renderer, null, container, 0, 0);
     using var picture = pictureRecorder.EndRecording();
     picture.Serialize(stream);
 }
Ejemplo n.º 4
0
    private static void DrawExport(RenderState renderState, object context)
    {
        if (renderState.Container is null || renderState.Renderer is null)
        {
            return;
        }

        s_exportPresenter.Render(context, renderState.Renderer, renderState.Selection, renderState.Container, 0.0, 0.0);
    }
Ejemplo n.º 5
0
 private void Save(string path, IPageContainer 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);
             }
 }
Ejemplo n.º 6
0
    private static void DrawEditor(RenderState renderState, object context)
    {
        if (renderState.Container is null || renderState.Renderer is null)
        {
            return;
        }

        s_editorPresenter.Render(context, renderState.Renderer, renderState.Selection, renderState.Container, 0.0, 0.0);

        renderState.Container?.Invalidate();
        renderState.Renderer.State?.PointStyle?.Invalidate();
        renderState.Renderer.State?.SelectedPointStyle?.Invalidate();
    }
Ejemplo n.º 7
0
        /// <inheritdoc/>
        public void Save(Stream stream, IPageContainer 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.Webp, 100);
            data.SaveTo(stream);
        }
Ejemplo n.º 8
0
        /// <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)
                {
                    s_templatePresenter.Render(context, Renderer, Container, 0.0, 0.0);
                    s_editorPresenter.Render(context, Renderer, Container, 0.0, 0.0);
                }
                else
                {
                    var renderer = GetValue(RendererOptions.RendererProperty);
                    if (renderer != null)
                    {
                        s_templatePresenter.Render(context, renderer, Container, 0.0, 0.0);
                        s_editorPresenter.Render(context, renderer, Container, 0.0, 0.0);
                    }
                }
            }
        }
Ejemplo n.º 9
0
        private PdfPage Add(PdfDocument pdf, PageContainerViewModel container, IContainerPresenter presenter)
        {
            // Create A3 page size with Landscape orientation.
            var pdfPage = pdf.AddPage();

            pdfPage.Size        = PageSize.A3;
            pdfPage.Orientation = PageOrientation.Landscape;

            var dataFlow = _serviceProvider.GetService <DataFlow>();
            var db       = (object)container.Properties;
            var record   = (object)container.Record;

            dataFlow.Bind(container.Template, db, record);
            dataFlow.Bind(container, db, record);

            using (XGraphics gfx = XGraphics.FromPdfPage(pdfPage))
            {
                // Calculate x and y page scale factors.
                double scaleX = pdfPage.Width.Value / container.Template.Width;
                double scaleY = pdfPage.Height.Value / container.Template.Height;
                double scale  = Math.Min(scaleX, scaleY);

                // Set scaling function.
                _scaleToPage = (value) => value * scale;

                // Draw container template contents to pdf graphics.
                Fill(gfx, 0, 0, pdfPage.Width.Value / scale, pdfPage.Height.Value / scale, container.Template.Background);


                // Draw template contents to pdf graphics.
                presenter.Render(gfx, this, null, container.Template, 0, 0);

                // Draw page contents to pdf graphics.
                presenter.Render(gfx, this, null, container, 0, 0);
            }

            return(pdfPage);
        }
Ejemplo n.º 10
0
        public void Save(Stream stream, PageContainerViewModel container)
        {
            var info = new SKImageInfo((int)container.Template.Width, (int)container.Template.Height, SKImageInfo.PlatformColorType, SKAlphaType.Unpremul);

            using var bitmap = new SKBitmap(info);
            using (var canvas = new SKCanvas(bitmap))
            {
                canvas.Clear();
                _presenter.Render(canvas, _renderer, null, container, 0, 0);
            }
            using var image = SKImage.FromBitmap(bitmap);
            using var data  = image.Encode(SKEncodedImageFormat.Png, 100);
            data.SaveTo(stream);
        }
Ejemplo n.º 11
0
    private static void DrawTemplate(RenderState renderState, object context)
    {
        if (renderState.Container is null || renderState.Renderer is null)
        {
            return;
        }

        s_templatePresenter.Render(context, renderState.Renderer, renderState.Selection, renderState.Container, 0.0, 0.0);

        if (renderState.Container is PageContainerViewModel page)
        {
            page.Template?.Invalidate();
        }
    }
Ejemplo n.º 12
0
        private void Save(string path, IPageContainer 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.Png, 100))
                        using (var stream = File.OpenWrite(path))
                        {
                            data.SaveTo(stream);
                        }
            }
        }
Ejemplo n.º 13
0
 public void Save(Stream stream, PageContainerViewModel container)
 {
     using var wstream = new SKManagedWStream(stream);
     using var canvas  = SKSvgCanvas.Create(SKRect.Create(0, 0, (int)container.Template.Width, (int)container.Template.Height), stream);
     _presenter.Render(canvas, _renderer, null, container, 0, 0);
 }
Ejemplo n.º 14
0
 private void Add(SKDocument pdf, PageContainerViewModel container)
 {
     using var canvas = pdf.BeginPage((float)container.Template.Width, (float)container.Template.Height);
     _presenter.Render(canvas, _renderer, null, container, 0, 0);
 }