Exemple #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();
        }
Exemple #2
0
 private bool IsContainer(object source)
 {
     return(source switch
     {
         LayerContainerViewModel targetLayer => true,
         FrameContainerViewModel targetPage => true,
         DocumentContainerViewModel targetDocument => true,
         _ => false
     });
 public void Save(Stream stream, DocumentContainerViewModel document)
 {
     using var pdf = SKDocument.CreatePdf(stream, _targetDpi);
     foreach (var container in document.Pages)
     {
         Add(pdf, container);
     }
     pdf.Close();
     _renderer.ClearCache();
 }
Exemple #4
0
        public void Bind(DocumentContainerViewModel document)
        {
            foreach (var container in document.Pages)
            {
                var db = container.Properties;
                var r  = container.Record;

                Bind(container.Template, db, r);
                Bind(container, db, r);
            }
        }
Exemple #5
0
    public override object Copy(IDictionary <object, object>?shared)
    {
        var pages = _pages.CopyShared(shared).ToImmutable();

        var copy = new DocumentContainerViewModel(ServiceProvider)
        {
            Name       = Name,
            IsVisible  = IsVisible,
            IsExpanded = IsExpanded,
            Pages      = pages
        };

        return(copy);
    }
Exemple #6
0
        public static void LoadTab(AppViewModel vm, string[] paths)
        {
            if (paths?.Length == 0 || string.IsNullOrEmpty(paths?[0]))
            {
                return;
            }

            if (paths.Length == 1 && File.Exists(paths[0]))
            {
                IScreen[] viewModels = GetViewModelsByPath(paths[0], true, true);
                if (viewModels?.Length > 0)
                {
                    foreach (IScreen viewModel in viewModels)
                    {
                        vm.Items.Add(viewModel);
                        vm.ActiveItem = viewModel;
                    }
                }
            }
            else
            {
                List <IScreen> viewModels = new List <IScreen>();
                foreach (string path in paths.Where(p => File.Exists(p)))
                {
                    IScreen viewModel = GetViewModelsByPath(path, false, false)?[0];
                    if (viewModel != null)
                    {
                        viewModels.Add(viewModel);
                    }
                }

                if (viewModels.Count > 0)
                {
                    DocumentContainerViewModel documentContainerViewModel = new DocumentContainerViewModel(paths, viewModels.ToArray());
                    if (documentContainerViewModel != null)
                    {
                        vm.ActiveItem = documentContainerViewModel;
                    }
                }
            }
        }
Exemple #7
0
 public void Save(Stream stream, DocumentContainerViewModel document)
 {
     throw new NotSupportedException("Saving documents as png drawing is not supported.");
 }
 public static void AddDocument(this ProjectContainerViewModel project, DocumentContainerViewModel document)
 {
     if (project?.Documents is { } && document is { })