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 OutliningTagger(ITextBuffer buffer)
        {
            _buffer   = buffer;
            _sections = new List <MarkdownSection>();

            ReparseFile(null, EventArgs.Empty);
            BufferIdleEventUtil.AddBufferIdleEventListener(buffer, ReparseFile);
        }
Exemple #3
0
        private void ShowToolWindow(object sender, EventArgs e)
        {
            var window = GetToolWindow(true);

            if (window != null)
            {
                BufferIdleEventUtil.BufferChanged((object)CurrentUDNDocView.TextEditorView.TextBuffer);

                IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;
                Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
            }
        }
Exemple #4
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 #5
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 void Dispose()
 {
     BufferIdleEventUtil.RemoveBufferIdleEventListener(_buffer, ReparseFile);
 }