Beispiel #1
0
        public void Save(Stream stream, DocumentContainerViewModel document)
        {
            var presenter = new ExportPresenter();

            using var pdf = new PdfDocument();
            var documentOutline = default(PdfOutline);

            foreach (var container in document.Pages)
            {
                var page = Add(pdf, container, presenter);

                if (documentOutline is null)
                {
                    documentOutline = pdf.Outlines.Add(
                        document.Name,
                        page,
                        true,
                        PdfOutlineStyle.Regular,
                        XColors.Black);
                }

                documentOutline.Outlines.Add(
                    container.Name,
                    page,
                    true,
                    PdfOutlineStyle.Regular,
                    XColors.Black);
            }

            pdf.Save(stream);
            ClearCache();
        }
Beispiel #2
0
        public void Save(Stream stream, PageContainerViewModel container)
        {
            var presenter = new ExportPresenter();

            using var pdf = new PdfDocument();
            Add(pdf, container, presenter);
            pdf.Save(stream);
        }
Beispiel #3
0
        public void TestSetup()
        {
            exportView           = new Mock <IExportView>();
            logger               = new Mock <ILogger>();
            dataMigrationService = new Mock <IDataMigrationService>();

            systemUnderTest = new ExportPresenter(exportView.Object, logger.Object, dataMigrationService.Object);
        }
Beispiel #4
0
    public MemoryStream?MakeMetafileStream(object bitmap, FrameContainerViewModel container, IImageCache ic)
    {
        var g  = default(Graphics);
        var mf = default(Metafile);
        var ms = new MemoryStream();

        if (bitmap is not Bitmap image)
        {
            return(null);
        }

        try
        {
            using (g = Graphics.FromImage(image))
            {
                var hdc = g.GetHdc();
                mf = new Metafile(ms, hdc);
                g.ReleaseHdc(hdc);
            }

            using (g = Graphics.FromImage(mf))
            {
                var p = new ExportPresenter();
                var r = new WinFormsRenderer(_serviceProvider, 72.0 / 96.0);
                r.State.DrawShapeState = ShapeStateFlags.Printable;
                r.State.ImageCache     = ic;

                g.SmoothingMode      = SmoothingMode.HighQuality;
                g.PixelOffsetMode    = PixelOffsetMode.HighQuality;
                g.TextRenderingHint  = TextRenderingHint.ClearTypeGridFit;
                g.CompositingQuality = CompositingQuality.HighQuality;
                g.InterpolationMode  = InterpolationMode.HighQualityBicubic;

                g.PageUnit = GraphicsUnit.Display;

                if (container is PageContainerViewModel page)
                {
                    p.Render(g, r, null, page.Template, 0, 0);
                }
                p.Render(g, r, null, container, 0, 0);

                r.ClearCache();
            }
        }
        finally
        {
            g?.Dispose();

            mf?.Dispose();
        }
        return(ms);
    }
Beispiel #5
0
    public void Save(Stream stream, object?item, object?options)
    {
        if (item is null)
        {
            return;
        }

        var ic = options as IImageCache;

        if (options is null)
        {
            return;
        }

        IShapeRenderer renderer = new SkiaSharpRendererViewModel(_serviceProvider);

        renderer.State.DrawShapeState = ShapeStateFlags.Printable;
        renderer.State.ImageCache     = ic;

        var presenter = new ExportPresenter();

        IProjectExporter exporter = new PdfSkiaSharpExporter(renderer, presenter, 72.0f);

        if (item is PageContainerViewModel page)
        {
            var dataFlow = _serviceProvider.GetService <DataFlow>();
            var db       = (object)page.Properties;
            var record   = (object)page.Record;

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

            exporter.Save(stream, page);
        }
        else if (item is DocumentContainerViewModel document)
        {
            var dataFlow = _serviceProvider.GetService <DataFlow>();

            dataFlow.Bind(document);

            exporter.Save(stream, document);
        }
        else if (item is ProjectContainerViewModel project)
        {
            var dataFlow = _serviceProvider.GetService <DataFlow>();

            dataFlow.Bind(project);

            exporter.Save(stream, project);
        }
    }
Beispiel #6
0
        /// <inheritdoc/>
        void IFileWriter.Save(string path, object item, object options)
        {
            if (string.IsNullOrEmpty(path) || item == null)
            {
                return;
            }

            var ic = options as IImageCache;

            if (options == null)
            {
                return;
            }

            IShapeRenderer renderer = new SkiaSharpRenderer(_serviceProvider, true, 72.0);

            renderer.State.DrawShapeState.Flags = ShapeStateFlags.Printable;
            renderer.State.ImageCache           = ic;

            var presenter = new ExportPresenter();

            IProjectExporter exporter = new PdfSkiaSharpExporter(renderer, presenter, 72.0f);

            if (item is IPageContainer page)
            {
                var dataFlow = _serviceProvider.GetService <IDataFlow>();
                var db       = (object)page.Data.Properties;
                var record   = (object)page.Data.Record;

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

                exporter.Save(path, page);
            }
            else if (item is IDocumentContainer document)
            {
                var dataFlow = _serviceProvider.GetService <IDataFlow>();

                dataFlow.Bind(document);

                exporter.Save(path, document);
            }
            else if (item is IProjectContainer project)
            {
                var dataFlow = _serviceProvider.GetService <IDataFlow>();

                dataFlow.Bind(project);

                exporter.Save(path, project);
            }
        }
Beispiel #7
0
        /// <inheritdoc/>
        public void Save(Stream stream, object item, object options)
        {
            if (item == null)
            {
                return;
            }

            var ic = options as IImageCache;

            if (options == null)
            {
                return;
            }

            var renderer = new SkiaSharpRenderer(_serviceProvider);

            renderer.State.DrawShapeState.Flags = ShapeStateFlags.Printable;
            renderer.State.ImageCache           = ic;

            var presenter = new ExportPresenter();

            IProjectExporter exporter = new SvgSkiaSharpExporter(renderer, presenter);

            if (item is IPageContainer page)
            {
                var dataFlow = _serviceProvider.GetService <IDataFlow>();
                var db       = (object)page.Data.Properties;
                var record   = (object)page.Data.Record;

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

                exporter.Save(stream, page);
            }
            else if (item is IDocumentContainer document)
            {
                throw new NotSupportedException("Saving documents as svg drawing is not supported.");
            }
            else if (item is IProjectContainer project)
            {
                throw new NotSupportedException("Saving projects as svg drawing is not supported.");
            }
        }
        public ExportWizard()
        {
            InitializeComponent();

            logger = new LoggerService(textBoxLogs, SynchronizationContext.Current);

            migratorFactory      = new CrmGenericMigratorFactory();
            logger               = new LoggerService(textBoxLogs, SynchronizationContext.Current);
            dataMigrationService = new DataMigrationService(logger, migratorFactory);
            presenter            = new ExportPresenter(this, logger, dataMigrationService);

            logger.LogVerbose($"ExportPresenter {presenter} successfully instatiated!");
            wizardButtons1.OnExecute += WizardButtons1_OnExecute;
            wizardButtons1.OnCustomNextNavigation     += WizardButtons1_OnNavigateToNextPage;
            wizardButtons1.OnCustomPreviousNavigation += WizardButtons1_OnCustomPreviousNavigation;

            FormatCsvSelected            = false;
            FormatJsonSelected           = true;
            numericUpDownBatchSize.Value = 5000;
        }
 public RequestController(
     IExportUseCase exportUseCase, ExportPresenter exportPresenter,
     IManageRequestUseCase manageRequestUseCase, ManageRequestPresenter manageRequestPresenter,
     IBulkExportUseCase bulkExportUseCase, BulkExportPresenter bulkExportPresenter,
     IGetEachRequestUseCase getEachRequestUseCase, GetEachRequestPresenter getEachRequestPresenter,
     IAuthService authService,
     ICommentRepository commentRepository,
     IRequestRepository requestRepository,
     ICreateCommentUseCase createCommentUseCase,
     ICreateRequestUseCase createRequestUseCase,
     CreateRequestPresenter createRequestPresenter,
     UpdateRequestPresenter updateRequestPresenter,
     IUpdateRequestUseCase updateRequestUseCase,
     ResourcePresenter <DeleteCommentResponse> deleteCommentPresenter,
     IDeleteCommentUseCase deleteCommentUseCase,
     IGetRequestUseCase getRequestUseCase,
     GetRequestPresenter getRequestPresenter,
     ResourcePresenter <CreateCommentResponse> createCommentPresenter)
 {
     _authService             = authService;
     _commentRepository       = commentRepository;
     _requestRepository       = requestRepository;
     _createCommentUseCase    = createCommentUseCase;
     _createRequestUseCase    = createRequestUseCase;
     _createRequestPresenter  = createRequestPresenter;
     _updateRequestUseCase    = updateRequestUseCase;
     _updateRequestPresenter  = updateRequestPresenter;
     _getRequestUseCase       = getRequestUseCase;
     _getRequestPresenter     = getRequestPresenter;
     _getEachRequestUseCase   = getEachRequestUseCase;
     _getEachRequestPresenter = getEachRequestPresenter;
     _exportUseCase           = exportUseCase;
     _exportPresenter         = exportPresenter;
     _manageRequestUseCase    = manageRequestUseCase;
     _manageRequestPresenter  = manageRequestPresenter;
     _bulkExportUseCase       = bulkExportUseCase;
     _bulkExportPresenter     = bulkExportPresenter;
     _createCommentPresenter  = createCommentPresenter;
     _deleteCommentPresenter  = deleteCommentPresenter;
     _deleteCommentUseCase    = deleteCommentUseCase;
 }
Beispiel #10
0
        /// <inheritdoc/>
        void IFileWriter.Save(string path, object item, object options)
        {
            if (string.IsNullOrEmpty(path) || item == null)
            {
                return;
            }

            var ic = options as IImageCache;

            if (options == null)
            {
                return;
            }

            var renderer = new SkiaSharpRenderer(true, 96.0);

            renderer.State.DrawShapeState.Flags = ShapeStateFlags.Printable;
            renderer.State.ImageCache           = ic;

            var presenter = new ExportPresenter();

            IProjectExporter exporter = new SvgSkiaSharpExporter(renderer, presenter);

            if (item is XContainer)
            {
                exporter.Save(path, item as XContainer);
            }
            else if (item is XDocument)
            {
                throw new NotSupportedException("Saving documents as svg drawing is not supported.");
            }
            else if (item is XProject)
            {
                throw new NotSupportedException("Saving projects as svg drawing is not supported.");
            }
        }
Beispiel #11
0
        /// <inheritdoc/>
        void IFileWriter.Save(string path, object item, object options)
        {
            if (string.IsNullOrEmpty(path) || item == null)
            {
                return;
            }

            var ic = options as IImageCache;

            if (options == null)
            {
                return;
            }

            ShapeRenderer renderer = new SkiaSharpRenderer(true, 72.0);

            renderer.State.DrawShapeState.Flags = ShapeStateFlags.Printable;
            renderer.State.ImageCache           = ic;

            var presenter = new ExportPresenter();

            IProjectExporter exporter = new PdfSkiaSharpExporter(renderer, presenter, 72.0f);

            if (item is XContainer)
            {
                exporter.Save(path, item as XContainer);
            }
            else if (item is XDocument)
            {
                exporter.Save(path, item as XDocument);
            }
            else if (item is XProject)
            {
                exporter.Save(path, item as XProject);
            }
        }