private void Display(Documentation.Document document)
        {
            _document = document;
            var flowDocument = CreateDocument();
            var visitor      = new DocumentationViewVisitor()
            {
                HeadingLevel = 1,
                BaseFontSize = flowDocument.FontSize
            };

            if (!string.IsNullOrEmpty(document.Title))
            {
                flowDocument.Blocks.Add(new Paragraph(new Run(document.Title))
                {
                    FontSize = flowDocument.FontSize * 2.25,
                    Margin   = new Thickness(0)
                });
            }
            if (!string.IsNullOrEmpty(document.SubTitle))
            {
                flowDocument.Blocks.Add(new Paragraph(new Run(document.SubTitle))
                {
                    Foreground = Brushes.Gray
                });
            }
            flowDocument.Blocks.AddRange(visitor.GetBlocks(document.Content.Select(e => e.Visit(visitor))));
            Display(flowDocument);
        }
        /// <summary>
        /// Starts the export operation using the selected settings.s
        /// </summary>
        private void ExportDocumentation()
        {
            this.Cursor = Cursors.AppStarting;

            //this.exportSelection.Visibility = Visibility.Hidden;
            this.settings.Visibility = Visibility.Collapsed;
            this.export.Visibility   = Visibility.Collapsed;
            this.finish.Visibility   = Visibility.Visible;
            System.Windows.Forms.Application.DoEvents();

            LiveDocumentorFile.Singleton.OutputLocation = this.publishTo.Text;             // store the users output selection

            // animate the hiding of the options and displaying of the progress bar
            this.exportSelection.BeginAnimation(OpacityProperty, (AnimationTimeline)this.FindResource("OptionsHide"));
            this.BeginAnimation(HeightProperty, (AnimationTimeline)this.FindResource("ShrinkWindow"));
            this.exportProgress.BeginAnimation(OpacityProperty, (AnimationTimeline)this.FindResource("OptionsShow"));
            System.Windows.Forms.Application.DoEvents();
            this.exportSelection.Visibility = System.Windows.Visibility.Hidden;             // now make the options invisible to fix issue #191

            Documentation.Exporting.Exporter exporter = null;
            ExportConfigFile config = (ExportConfigFile)this.outputSelection.SelectedItem;

            this.exportDescription.Text = config.Description;

            ExportSettings settings = new ExportSettings();

            settings.PublishDirectory = this.publishTo.Text.EndsWith("\\") || string.IsNullOrEmpty(this.publishTo.Text)
                                ? this.publishTo.Text
                                : this.publishTo.Text + "\\";
            settings.Settings = new Documentation.DocumentSettings();
            foreach (PrivacyFilter filter in this.PrivacyFilters)
            {
                if (filter.IsSelected)
                {
                    settings.Settings.VisibilityFilters.Add(filter.Visibility);
                }
            }

            TheBoxSoftware.Documentation.Document document = new Documentation.Document(LiveDocumenter.LiveDocumentorFile.Singleton.LiveDocument.Assemblies);
            document.Settings = settings.Settings;
            document.UpdateDocumentMap();

            exporter = Documentation.Exporting.Exporter.Create(document, settings, config);

            exporter.ExportCalculated += new ExportCalculatedEventHandler(exporter_ExportCalculated);
            exporter.ExportStep       += new ExportStepEventHandler(exporter_ExportStep);
            exporter.ExportException  += new ExportExceptionHandler(exporter_ExportException);

            if (exporter != null)
            {
                worker                     = new System.ComponentModel.BackgroundWorker();
                worker.DoWork             += new System.ComponentModel.DoWorkEventHandler(this.ThreadedExport);
                worker.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);

                this.exportStartTime = DateTime.Now;
                worker.RunWorkerAsync(exporter);
            }
        }
        private async Task <bool> Navigate(DocumentUrl documentUrl)
        {
            SetMessage("Loading...");
            try
            {
                UpdateAddressBar(documentUrl);

                var options = new Documentation.DocumentOptions();
                switch (documentUrl.Category.ToUpperInvariant())
                {
                case "HELP":
                    if (_topics.TryGetValue(documentUrl.Name, out var generator))
                    {
                        _document = null;
                        Display(generator());
                        return(true);
                    }
                    break;

                case "ITEMTYPE":
                    await _metadata.ReloadTask();

                    if (_metadata.ItemTypeByName(documentUrl.Name, out var itemType))
                    {
                        await Task.WhenAll(_metadata.GetClassPaths(itemType).ToTask(), _metadata.GetProperties(itemType).ToTask());

                        Display(Documentation.Document.FromItemType(itemType, options));
                        return(true);
                    }
                    break;

                case "METHOD":
                    await _metadata.ReloadTask();

                    var method = _metadata.Methods.FirstOrDefault(m => string.Equals(m.KeyedName, documentUrl.Name, StringComparison.OrdinalIgnoreCase));
                    if (method != null)
                    {
                        Display(Documentation.Document.FromMethod(method, options));
                        return(true);
                    }
                    break;
                }
                SetMessage("Can't load document");
            }
            catch (Exception ex)
            {
                SetMessage("Can't load document\r\n" + ex.ToString());
            }

            return(false);
        }
        private void SetMessage(string message)
        {
            if (!Dispatcher.CheckAccess())
            {
                Dispatcher.Invoke(() => SetMessage(message));
                return;
            }

            _document = null;
            var flowDocument = CreateDocument();

            flowDocument.Blocks.Add(new Paragraph(new Run(message)));
            this.flowViewer.Document = flowDocument;
        }
        private void outputSelection_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ExportConfigFile o = (ExportConfigFile)this.outputSelection.SelectedItem;

            this.exportDescription.Text = o.Description;
            this.exportVersion.Text     = "v " + o.Version;

            switch (o.Exporter)
            {
            case Exporters.Website:
                this.exportType.Text = "Website exporter";
                break;

            case Exporters.Html1:
                this.exportType.Text = "HTML Help 1 exporter";
                break;

            case Exporters.Html2:
                this.exportType.Text = "HTML Help 2 exporter";
                break;

            case Exporters.HelpViewer1:
                this.exportType.Text = "MS Help Viewer 1";
                break;

            case Exporters.XML:
                this.exportType.Text = "XML";
                break;
            }

            if (o.HasScreenshot)
            {
                System.Windows.Media.Imaging.BitmapImage image = new System.Windows.Media.Imaging.BitmapImage();
                image.BeginInit();
                image.StreamSource = o.GetScreenshot();
                image.EndInit();
                this.exportImage.Source = image;
            }
            else
            {
                this.exportImage.Source = null;
            }

            // create an instance of the exporter in the dummy format to allow it to test if it
            // is able to execute.
            Documentation.Exporting.Exporter      exporter = null;
            TheBoxSoftware.Documentation.Document document = new Documentation.Document(LiveDocumenter.LiveDocumentorFile.Singleton.LiveDocument.Assemblies);
            exporter = Documentation.Exporting.Exporter.Create(document, new ExportSettings(), o);
            List <Issue> issues = exporter.GetIssues();

            if (issues.Count > 0)
            {
                this.exportLogo.Visibility   = Visibility.Hidden;
                this.warningImage.Visibility = Visibility.Visible;
                this.exportDescription.Text  = string.Empty;
                foreach (Issue current in issues)
                {
                    this.exportDescription.Text += current.Description + "\n";
                }
                this.exportType.Text    = "Information!";
                this.exportVersion.Text = string.Empty;
                this.export.IsEnabled   = false;
            }
            else
            {
                this.exportLogo.Visibility   = Visibility.Visible;
                this.warningImage.Visibility = Visibility.Hidden;
                this.export.IsEnabled        = true;
            }
        }