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(); }
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(); }
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); } }
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); }
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; } } } }
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 { })