Пример #1
0
        /// <summary>
        /// Updates the foldings using the current <see cref="FoldingStrategy"/>.
        /// </summary>
        /// <remarks>
        /// If a <see cref="FoldingStrategy"/> is set, this method is automatically called periodically
        /// (see <see cref="FoldingUpdateInterval"/>). This method can also be called manually to
        /// update the foldings.
        /// </remarks>
        public void UpdateFoldings()
        {
            if (FoldingManager == null)
            {
                return;
            }

            Debug.Assert(EnableFolding, "Folding manager should be null if folding is disabled.");

            if (_foldingValid)
            {
                return;
            }

            if (FoldingStrategy != null)
            {
                FoldingStrategy.UpdateFoldings(FoldingManager, Document);
            }
            else if (FoldingManager.AllFoldings.Any())
            {
                FoldingManager.Clear();
            }

            _foldingValid = true;
        }
Пример #2
0
        private void EditorDocumentChanged()
        {
            if (FoldingStrategy == null)
            {
                return;
            }

            _currentDocument = new WeakReference <TextDocument>(AssociatedObject.Document);

            TextDocument document;

            if (_currentDocument.TryGetTarget(out document))
            {
                _currentFoldingManager = FoldingManager.Install(AssociatedObject.TextArea);
                FoldingStrategy.UpdateFoldings(_currentFoldingManager, document);

                IEnumerable <NewFolding> foldings;
                if (_documents.TryGetValue(document, out foldings))
                {
                    _currentFoldingManager.UpdateFoldings(foldings, -1);
                }
                else
                {
                    _documents.Add(document, Enumerable.Empty <NewFolding>());
                }

                WeakEventManager <TextDocument, DocumentChangeEventArgs> .AddHandler(document, "Changed", document_Changed);
            }
        }
Пример #3
0
 /// <summary>
 /// Обновить  представление
 /// </summary>
 public virtual void RenderData()
 {
     if ((foldingManager != null) && (FoldingStrategy != null))
     {
         FoldingStrategy.UpdateFoldings(foldingManager, textEditor.Document);
     }
     textEditor.TextArea.TextView.Redraw();
 }
Пример #4
0
        public JsonViewerWindow()
        {
            InitializeComponent();

            TextBox.SyntaxHighlighting = ICSharpCode.AvalonEdit.Highlighting.HighlightingManager.Instance.GetDefinition("Json");
            FoldingManager             = FoldingManager.Install(TextBox.TextArea);
            FoldingStrategy.UpdateFoldings(FoldingManager, TextBox.Document);
            SearchPanel = SearchPanel.Install(TextBox.TextArea);
        }
Пример #5
0
        void document_Changed(object sender, DocumentChangeEventArgs e)
        {
            var document = sender as TextDocument;

            if (document == null)
            {
                return;
            }

            if (document != AssociatedObject.Document)
            {
                return;
            }

            FoldingStrategy.UpdateFoldings(_currentFoldingManager, document);
        }
Пример #6
0
 /// <summary>
 /// Обновление foldingManager
 /// </summary>
 protected void UpdateFolding()
 {
     if (FoldingStrategy != null)
     {
         if (foldingManager == null)
         {
             foldingManager = FoldingManager.Install(textEditor.TextArea);
         }
         FoldingStrategy.UpdateFoldings(foldingManager, textEditor.Document);
     }
     else
     {
         if (foldingManager != null)
         {
             FoldingManager.Uninstall(foldingManager);
             foldingManager = null;
         }
     }
 }
Пример #7
0
 protected override void OnTextChanged(EventArgs e)
 {
     SetCurrentValue(DocumentTextProperty, base.Text);
     FoldingStrategy.UpdateFoldings(FoldingManager, Document);
     base.OnTextChanged(e);
 }
Пример #8
0
 private void UpdateFoldings()
 {
     FoldingStrategy.UpdateFoldings(_foldingManager, CodeEditor.Document);
 }
Пример #9
0
 private void UpdateFoldings()
 {
     _foldingStrategy.FoldingManager = _foldingStrategy.FoldingManager ?? FoldingManager.Install(Editor.TextArea);
     _foldingStrategy.UpdateFoldings(Editor.Document);
 }
Пример #10
0
 private void TextBox_TextChanged(object sender, EventArgs e)
 {
     FoldingStrategy.UpdateFoldings(FoldingManager, TextBox.Document);
 }