public void Bind(ProjectContainerViewModel project) { foreach (var document in project.Documents) { Bind(document); } }
DocumentContainerViewModel IContainerFactory.GetDocument(ProjectContainerViewModel project, string name) { var factory = _serviceProvider.GetService <IFactory>(); var document = factory.CreateDocumentContainer(name); return(document); }
public static IEnumerable <BaseShapeViewModel> GetAllShapes(this ProjectContainerViewModel project) { return(project.Documents .SelectMany(d => d.Pages) .SelectMany(c => c.Layers) .SelectMany(l => l.Shapes)); }
PageContainerViewModel IContainerFactory.GetPage(ProjectContainerViewModel project, string name) { var factory = _serviceProvider.GetService <IFactory>(); var container = factory.CreatePageContainer(name); container.Template = project.CurrentTemplate ?? (this as IContainerFactory).GetTemplate(project, "Default"); return(container); }
TemplateContainerViewModel IContainerFactory.GetTemplate(ProjectContainerViewModel project, string name) { var factory = _serviceProvider.GetService <IFactory>(); var template = factory.CreateTemplateContainer(name); template.Background = factory.CreateArgbColor(0xFF, 0xFF, 0xFF, 0xFF); return(template); }
public static IEnumerable <T> GetAllShapes <T>(this ProjectContainerViewModel project) { var shapes = project.Documents .SelectMany(d => d.Pages) .SelectMany(c => c.Layers) .SelectMany(l => l.Shapes); return(shapes.GetAllShapes().Where(s => s is T).Cast <T>()); }
PageContainerViewModel?IContainerFactory.GetPage(ProjectContainerViewModel project, string name) { var factory = _serviceProvider.GetService <IViewModelFactory>(); if (factory is null) { return(null); } var container = factory.CreatePageContainer(name); container.Template = project.CurrentTemplate is { }
public void Save(Stream stream, ProjectContainerViewModel project) { using var pdf = SKDocument.CreatePdf(stream, _targetDpi); foreach (var document in project.Documents) { foreach (var container in document.Pages) { Add(pdf, container); } } pdf.Close(); _renderer.ClearCache(); }
public void Save(Stream stream, ProjectContainerViewModel project) { var presenter = new ExportPresenter(); using var pdf = new PdfDocument(); var projectOutline = default(PdfOutline); foreach (var document in project.Documents) { var documentOutline = default(PdfOutline); foreach (var container in document.Pages) { var page = Add(pdf, container, presenter); if (projectOutline is null) { projectOutline = pdf.Outlines.Add( project.Name, page, true, PdfOutlineStyle.Regular, XColors.Black); } if (documentOutline is null) { documentOutline = projectOutline.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(); }
public override object Copy(IDictionary <object, object>?shared) { var styleLibraries = _styleLibraries.CopyShared(shared).ToImmutable(); var groupLibraries = _groupLibraries.CopyShared(shared).ToImmutable(); var databases = _databases.CopyShared(shared).ToImmutable(); var templates = _templates.CopyShared(shared).ToImmutable(); var scripts = _scripts.CopyShared(shared).ToImmutable(); var documents = _documents.CopyShared(shared).ToImmutable(); var currentStyleLibrary = _currentStyleLibrary.GetCurrentItem(ref _styleLibraries, ref styleLibraries); var currentGroupLibrary = _currentGroupLibrary.GetCurrentItem(ref _styleLibraries, ref styleLibraries); var currentDatabase = _currentDatabase.GetCurrentItem(ref _databases, ref databases); var currentTemplate = _currentTemplate.GetCurrentItem(ref _templates, ref templates); var currentScript = _currentScript.GetCurrentItem(ref _scripts, ref scripts); var currentDocument = _currentDocument.GetCurrentItem(ref _documents, ref documents); var currentContainer = _currentContainer switch { PageContainerViewModel page => page.GetCurrentItem(ref _documents, ref documents, x => x.Pages), TemplateContainerViewModel template => template.GetCurrentItem(ref _templates, ref templates), _ => default(FrameContainerViewModel?) }; var copy = new ProjectContainerViewModel(ServiceProvider) { Options = _options?.CopyShared(shared), StyleLibraries = styleLibraries, GroupLibraries = groupLibraries, Databases = databases, Templates = templates, Scripts = scripts, Documents = documents, CurrentStyleLibrary = currentStyleLibrary, CurrentGroupLibrary = currentGroupLibrary, CurrentDatabase = currentDatabase, CurrentTemplate = currentTemplate, CurrentScript = currentScript, CurrentDocument = currentDocument, CurrentContainer = currentContainer }; if (_selected is { } && shared is { })
public void Save(Stream stream, ProjectContainerViewModel project) { throw new NotSupportedException("Saving projects as png drawing is not supported."); }
private TemplateContainerViewModel?CreateDefaultTemplate(IContainerFactory containerFactory, ProjectContainerViewModel project, string name) { var factory = _serviceProvider.GetService <IViewModelFactory>(); if (factory is null) { return(null); } var template = containerFactory.GetTemplate(project, name); if (template is null) { return(null); } template.IsGridEnabled = false; template.IsBorderEnabled = false; template.GridOffsetLeft = 30.0; template.GridOffsetTop = 30.0; template.GridOffsetRight = -30.0; template.GridOffsetBottom = -30.0; template.GridCellWidth = 30.0; template.GridCellHeight = 30.0; template.GridStrokeColor = factory.CreateArgbColor(0xFF, 0xDE, 0xDE, 0xDE); template.GridStrokeThickness = 1.0; return(template); }
public static void AddDocument(this ProjectContainerViewModel project, DocumentContainerViewModel?document) { if (document is { })
public static void AddDocument(this ProjectContainerViewModel project, DocumentContainerViewModel document) { if (project?.Documents is { } && document is { })