private void CreateTemplatePreview() { Dispatcher.Invoke(() => { ClearPreviewTree(); }); // ANALYSE GetFacts.Facts.Page page = new GetFacts.Facts.Page(Workflow.PageTemplate.Reference); page.Template = Workflow.PageTemplate; page.Parser = AbstractParser.NewInstance(Workflow.PageTemplate.PageType); page.Update(Workflow.DownloadTask.LocalFile); Dispatcher.Invoke(() => { PopulatePreviewTree(page); }); }
private void PopulatePreviewTree(GetFacts.Facts.Page page) { // PAGE ArticleDisplay pageDisplay = new ArticleDisplay(false, 0) { DesiredOrientation = ArticleDisplay.Orientation.Horizontal, Width = PREVIEW_WIDTH, Height = PREVIEW_HEIGHT }; pageDisplay.Update(page); TreeViewItem rootItem = new TreeViewItem() { Header = pageDisplay }; // SECTIONS int sectionsCount = page.SectionsCount; for (int sectionIndex = 0; sectionIndex < sectionsCount; sectionIndex++) { GetFacts.Facts.Section section = page.GetSection(sectionIndex); ArticleDisplay sectionDisplay = new ArticleDisplay(false, 0) { DesiredOrientation = ArticleDisplay.Orientation.Horizontal, Width = PREVIEW_WIDTH, Height = PREVIEW_HEIGHT }; sectionDisplay.Update(section); TreeViewItem sectionItem = new TreeViewItem() { Header = sectionDisplay }; rootItem.Items.Add(sectionItem); sectionItem.IsExpanded = true; // ARTICLES int articlesCount = section.ArticlesCount; for (int articleIndex = 0; articleIndex < articlesCount; articleIndex++) { GetFacts.Facts.Article article = section.GetArticle(articleIndex); ArticleDisplay articleDisplay = new ArticleDisplay(false, 0) { DesiredOrientation = ArticleDisplay.Orientation.Horizontal, Width = PREVIEW_WIDTH, Height = PREVIEW_HEIGHT }; articleDisplay.Update(article); TreeViewItem articleItem = new TreeViewItem() { Header = articleDisplay }; sectionItem.Items.Add(articleItem); } if ((articlesCount > 0) || (section.HasContent == true)) { rootItem.IsExpanded = true; } } PreviewTree.Items.Add(rootItem); //rootItem.ExpandSubtree(); //page.Parser = Parser; //page.Template = PageTemplate; PleaseWaitPanel.Visibility = Visibility.Hidden; }