public PreviewWindowUpdateListener(IWpfTextView wpfTextView, MarkdownPackage package, ITextDocument document)
        {
            this.textView = wpfTextView;
            this.package  = package;
            this.document = document;

            EventHandler updateHandler =
                (sender, args) => UDNDocRunningTableMonitor.CurrentUDNDocView.ParsingResultsCache.AsyncForceReparse();

            BufferIdleEventUtil.AddBufferIdleEventListener(wpfTextView.TextBuffer, updateHandler);

            document.FileActionOccurred +=
                (sender, args) => UDNDocRunningTableMonitor.CurrentUDNDocView.ParsingResultsCache.AsyncForceReparse();

            textView.Closed += (sender, args) =>
            {
                ClearPreviewWindow();
                BufferIdleEventUtil.RemoveBufferIdleEventListener(wpfTextView.TextBuffer, updateHandler);
            };

            //On updating the publish flags re-run the preview
            package.PublishFlags.CollectionChanged +=
                (sender, args) => UDNDocRunningTableMonitor.CurrentUDNDocView.ParsingResultsCache.AsyncForceReparse();

            DoxygenHelper.TrackedFilesChanged +=
                () => UDNDocRunningTableMonitor.CurrentUDNDocView.ParsingResultsCache.AsyncForceReparse();

            Templates.TemplatesChanged += () => UpdatePreviewWindow(UDNDocRunningTableMonitor.CurrentUDNDocView.ParsingResultsCache.Results);
            UDNDocRunningTableMonitor.CurrentOutputIsChanged += UpdatePreviewWindow;
        }
        public PreviewWindowUpdateListener(IWpfTextView wpfTextView, MarkdownPackage package, ITextDocument document)
        {
            this.textView = wpfTextView;
            this.package = package;
            this.document = document;

            if (textView.HasAggregateFocus)
                UpdatePreviewWindow(false);

            updateHandler = (sender, args) =>
                {
                    UpdatePreviewWindow(async: true);
                };

            BufferIdleEventUtil.AddBufferIdleEventListener(wpfTextView.TextBuffer, updateHandler);

            textView.Closed += (sender, args) =>
                {
                    ClearPreviewWindow();
                    BufferIdleEventUtil.RemoveBufferIdleEventListener(wpfTextView.TextBuffer, updateHandler);
                };

            textView.GotAggregateFocus += (sender, args) =>
                {
                    var window = GetPreviewWindow(false);
                    if (window != null)
                    {
                        if (window.CurrentSource == null || window.CurrentSource != this)
                            UpdatePreviewWindow(false);
                    }
                };
        }
Exemple #3
0
        public Margin(IWpfTextView wpfTextView, MarkdownPackage package, ITextDocumentFactoryService textDocumentFactoryService)
        {
            this.textView = wpfTextView;
            this.package  = package;

            this.Orientation = System.Windows.Controls.Orientation.Horizontal;
            this.Background  = Brushes.SlateGray;
            this.Height      = 25;

            Button showPreview = new Button()
            {
                Content = "Show preview window"
            };

            showPreview.Click += HandleShowPreviewClick;

            this.Children.Add(showPreview);

            sectionCombo = new ComboBox();
            sectionCombo.SelectionChanged += HandleSectionComboSelectionChanged;

            this.Children.Add(sectionCombo);

            backgroundParser = textView.TextBuffer.Properties.GetOrCreateSingletonProperty(typeof(MarkdownBackgroundParser),
                                                                                           () => new MarkdownBackgroundParser(textView.TextBuffer, TaskScheduler.Default, textDocumentFactoryService));

            sections = new List <MarkdownSection>();
            backgroundParser.ParseComplete += HandleBackgroundParseComplete;
            backgroundParser.RequestParse(true);

            textView.Closed += HandleTextViewClosed;
            textView.Caret.PositionChanged += HandleTextViewCaretPositionChanged;
        }
        public PreviewWindowUpdateListener(IWpfTextView wpfTextView, MarkdownPackage package, ITextDocument document)
        {
            this.textView = wpfTextView;
            this.package = package;
            this.document = document;

            EventHandler updateHandler =
                (sender, args) => UDNDocRunningTableMonitor.CurrentUDNDocView.ParsingResultsCache.AsyncForceReparse();

            BufferIdleEventUtil.AddBufferIdleEventListener(wpfTextView.TextBuffer, updateHandler);

            document.FileActionOccurred +=
                (sender, args) => UDNDocRunningTableMonitor.CurrentUDNDocView.ParsingResultsCache.AsyncForceReparse();

            textView.Closed += (sender, args) =>
                {
                    ClearPreviewWindow();
                    BufferIdleEventUtil.RemoveBufferIdleEventListener(wpfTextView.TextBuffer, updateHandler);
                };

            //On updating the publish flags re-run the preview
            package.PublishFlags.CollectionChanged +=
                (sender, args) => UDNDocRunningTableMonitor.CurrentUDNDocView.ParsingResultsCache.AsyncForceReparse();

            DoxygenHelper.TrackedFilesChanged +=
                () => UDNDocRunningTableMonitor.CurrentUDNDocView.ParsingResultsCache.AsyncForceReparse();

            Templates.TemplatesChanged += () => UpdatePreviewWindow(UDNDocRunningTableMonitor.CurrentUDNDocView.ParsingResultsCache.Results);
            UDNDocRunningTableMonitor.CurrentOutputIsChanged += UpdatePreviewWindow;
        }
Exemple #5
0
        public IWpfTextViewMargin CreateMargin(IWpfTextViewHost wpfTextViewHost, IWpfTextViewMargin marginContainer)
        {
            MarkdownPackage package = null;

            // If there is a shell service (which there should be, in VS), force the markdown package to load
            IVsShell shell = GlobalServiceProvider.GetService(typeof(SVsShell)) as IVsShell;

            if (shell != null)
            {
                package = MarkdownPackage.ForceLoadPackage(shell);
            }

            return(new Margin(wpfTextViewHost.TextView, package));
        }
        public PreviewWindowUpdateListener(IWpfTextView wpfTextView, MarkdownPackage package, ITextDocumentFactoryService textDocumentFactoryService)
        {
            this.textView = wpfTextView;
            this.package = package;
            this.backgroundParser = new PreviewWindowBackgroundParser(wpfTextView.TextBuffer, TaskScheduler.Default, textDocumentFactoryService);
            this.backgroundParser.ParseComplete += HandleBackgroundParseComplete;

            if (!textDocumentFactoryService.TryGetTextDocument(wpfTextView.TextDataModel.DocumentBuffer, out document))
                document = null;

            if (textView.HasAggregateFocus)
                UpdatePreviewWindow(string.Empty);

            backgroundParser.RequestParse(true);

            textView.Closed += HandleTextViewClosed;
            textView.GotAggregateFocus += HandleTextViewGotAggregateFocus;
        }
Exemple #7
0
        public void  TextViewCreated(IWpfTextView textView)
        {
            MarkdownPackage package = null;

            // If there is a shell service (which there should be, in VS), force the markdown package to load
            IVsShell shell = GlobalServiceProvider.GetService(typeof(SVsShell)) as IVsShell;

            if (shell != null)
            {
                package = MarkdownPackage.ForceLoadPackage(shell);
            }

            if (package == null)
            {
                return;
            }

            textView.Properties.GetOrCreateSingletonProperty(() => new PreviewWindowUpdateListener(textView, package, TextDocumentFactoryService));
        }
        public void  TextViewCreated(IWpfTextView textView)
        {
            ITextDocument document;

            if (!textView.TextDataModel.DocumentBuffer.Properties.TryGetProperty(typeof(ITextDocument), out document))
            {
                document = null;
            }

            MarkdownPackage package = null;

            // If there is a shell service (which there should be, in VS), force the markdown package to load
            IVsShell shell = GlobalServiceProvider.GetService(typeof(SVsShell)) as IVsShell;

            if (shell != null)
            {
                package = MarkdownPackage.ForceLoadPackage(shell);
            }

            textView.Properties.GetOrCreateSingletonProperty(() => new PreviewWindowUpdateListener(textView, package, document));
        }
Exemple #9
0
        public PreviewWindowUpdateListener(IWpfTextView wpfTextView, MarkdownPackage package, ITextDocumentFactoryService textDocumentFactoryService)
        {
            this.textView         = wpfTextView;
            this.package          = package;
            this.backgroundParser = new PreviewWindowBackgroundParser(wpfTextView.TextBuffer, TaskScheduler.Default, textDocumentFactoryService);
            this.backgroundParser.ParseComplete += HandleBackgroundParseComplete;

            if (!textDocumentFactoryService.TryGetTextDocument(wpfTextView.TextDataModel.DocumentBuffer, out document))
            {
                document = null;
            }

            if (textView.HasAggregateFocus)
            {
                UpdatePreviewWindow(string.Empty);
            }

            backgroundParser.RequestParse(true);

            textView.Closed            += HandleTextViewClosed;
            textView.GotAggregateFocus += HandleTextViewGotAggregateFocus;
        }
Exemple #10
0
        public PreviewWindowUpdateListener(IWpfTextView wpfTextView, MarkdownPackage package, ITextDocument document)
        {
            this.textView = wpfTextView;
            this.package  = package;
            this.document = document;

            if (textView.HasAggregateFocus)
            {
                UpdatePreviewWindow(false);
            }

            updateHandler = (sender, args) =>
            {
                UpdatePreviewWindow(async: true);
            };

            BufferIdleEventUtil.AddBufferIdleEventListener(wpfTextView.TextBuffer, updateHandler);

            textView.Closed += (sender, args) =>
            {
                ClearPreviewWindow();
                BufferIdleEventUtil.RemoveBufferIdleEventListener(wpfTextView.TextBuffer, updateHandler);
            };

            textView.GotAggregateFocus += (sender, args) =>
            {
                var window = GetPreviewWindow(false);
                if (window != null)
                {
                    if (window.CurrentSource == null || window.CurrentSource != this)
                    {
                        UpdatePreviewWindow(false);
                    }
                }
            };
        }
Exemple #11
0
        public Margin(IWpfTextView wpfTextView, MarkdownPackage package)
        {
            this.textView = wpfTextView;
            this.package  = package;

            this.Orientation = System.Windows.Controls.Orientation.Horizontal;
            this.Background  = Brushes.SlateGray;
            this.Height      = 25;

            Button showPreview = new Button()
            {
                Content = "Show preview window"
            };

            showPreview.Click += (sender, args) =>
            {
                if (package != null)
                {
                    var window = package.GetMarkdownPreviewToolWindow(true);
                    ((IVsWindowFrame)window.Frame).ShowNoActivate();
                }
            };

            this.Children.Add(showPreview);

            Button copyHtml = new Button()
            {
                Content = "Copy HTML to clipboard"
            };

            copyHtml.Click += (sender, args) =>
            {
                Clipboard.SetText(GetHTMLText());
            };

            this.Children.Add(copyHtml);

            sectionCombo = new ComboBox();
            sectionCombo.SelectionChanged += (sender, args) =>
            {
                if (ignoreComboChange)
                {
                    return;
                }

                ITextSnapshot snapshot = textView.TextSnapshot;

                int selectedIndex = sectionCombo.SelectedIndex;

                if (selectedIndex == 0)
                {
                    NavigateTo(new SnapshotPoint(snapshot, 0));
                }
                else
                {
                    selectedIndex--;

                    if (selectedIndex >= sections.Count)
                    {
                        Debug.Fail("An item in the combo was selected that isn't a valid section.");
                        return;
                    }

                    NavigateTo(sections[selectedIndex].Span.GetStartPoint(snapshot));
                }
            };
            RefreshComboItems(null, EventArgs.Empty);

            this.Children.Add(sectionCombo);

            BufferIdleEventUtil.AddBufferIdleEventListener(textView.TextBuffer, RefreshComboItems);
            textView.Closed += (sender, args) => BufferIdleEventUtil.RemoveBufferIdleEventListener(textView.TextBuffer, RefreshComboItems);

            textView.Caret.PositionChanged += (sender, args) => SetSectionComboToCaretPosition();
        }
 public MarkdownEditorFactoryWithEncoding(MarkdownPackage package)
     : base(package, true)
 {
 }
Exemple #13
0
        public Margin(IWpfTextView wpfTextView, MarkdownPackage package)
        {
            this.textView = wpfTextView;
            this.package = package;

            this.Orientation = System.Windows.Controls.Orientation.Horizontal;
            this.Background = Brushes.SlateGray;
            this.Height = 25;

            Button showPreview = new Button() { Content = "Show preview window" };
            showPreview.Click += (sender, args) =>
                {
                    if (package != null)
                    {
                        var window = package.GetMarkdownPreviewToolWindow(true);
                        ((IVsWindowFrame)window.Frame).ShowNoActivate();
                    }
                };

            this.Children.Add(showPreview);

            Button copyHtml = new Button() { Content = "Copy HTML to clipboard" };
            copyHtml.Click += (sender, args) =>
                {
                    Clipboard.SetText(GetHTMLText());
                };

            this.Children.Add(copyHtml);

            sectionCombo = new ComboBox();
            sectionCombo.SelectionChanged += (sender, args) =>
                {
                    if (ignoreComboChange)
                        return;

                    ITextSnapshot snapshot = textView.TextSnapshot;

                    int selectedIndex = sectionCombo.SelectedIndex;

                    if (selectedIndex == 0)
                    {
                        NavigateTo(new SnapshotPoint(snapshot, 0));
                    }
                    else
                    {
                        selectedIndex--;

                        if (selectedIndex >= sections.Count)
                        {
                            Debug.Fail("An item in the combo was selected that isn't a valid section.");
                            return;
                        }

                        NavigateTo(sections[selectedIndex].Span.GetStartPoint(snapshot));
                    }
                };
            RefreshComboItems(null, EventArgs.Empty);

            this.Children.Add(sectionCombo);

            BufferIdleEventUtil.AddBufferIdleEventListener(textView.TextBuffer, RefreshComboItems);
            textView.Closed += (sender, args) => BufferIdleEventUtil.RemoveBufferIdleEventListener(textView.TextBuffer, RefreshComboItems);

            textView.Caret.PositionChanged += (sender, args) => SetSectionComboToCaretPosition();
        }
 public MarkdownEditorFactoryWithoutEncoding(MarkdownPackage package)
     : base(package, false)
 {
 }
Exemple #15
0
        public Margin(IWpfTextView wpfTextView, MarkdownPackage package, ITextDocumentFactoryService textDocumentFactoryService)
        {
            this.textView = wpfTextView;
            this.package = package;

            base.Background = Brushes.SlateGray;

            StackPanel outlinePanel = new StackPanel
            {
                Orientation = Orientation.Horizontal,
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Top,
                Height = 25
            };

            Button showPreview = new Button { Content = "Show preview window" };
            showPreview.Click += HandleShowPreviewClick;
            outlinePanel.Children.Add(showPreview);

            Button copyHtml = new Button { Content = "Copy HTML to clipboard" };
            copyHtml.Click += HandleCopyHtmlClick;
            outlinePanel.Children.Add(copyHtml);

            sectionCombo = new ComboBox();
            sectionCombo.SelectionChanged += HandleSectionComboSelectionChanged;
            outlinePanel.Children.Add(sectionCombo);

            backgroundParser = textView.TextBuffer.Properties.GetOrCreateSingletonProperty(typeof(MarkdownBackgroundParser),
                () => new MarkdownBackgroundParser(textView.TextBuffer, TaskScheduler.Default, textDocumentFactoryService));

            StackPanel rulesetPanel = new StackPanel
            {
                Orientation = Orientation.Horizontal
            };

            Label rulesetLabel = new Label
            {
                Content = "Ruleset File:  ",
                Foreground = Brushes.White
            };
            rulesetPanel.Children.Add(rulesetLabel);

            Label rulesetPathLabel = new Label
            {
                Content = string.IsNullOrWhiteSpace(backgroundParser.RulesetFilePath) ? "Not Loaded" : backgroundParser.RulesetFilePath,
                ToolTip = backgroundParser.NoRulesetFileReason,
                Foreground = Brushes.White
            };
            rulesetPanel.Children.Add(rulesetPathLabel);

            Expander optionsExpander = new Expander() {
                Header = outlinePanel,
                Content = rulesetPanel
            };

            this.Children.Add(optionsExpander);

            sections = new List<MarkdownSection>();
            backgroundParser.ParseComplete += HandleBackgroundParseComplete;
            backgroundParser.RequestParse(true);

            textView.Closed += HandleTextViewClosed;
            textView.Caret.PositionChanged += HandleTextViewCaretPositionChanged;
        }