/// <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; }
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); } }
/// <summary> /// Обновить представление /// </summary> public virtual void RenderData() { if ((foldingManager != null) && (FoldingStrategy != null)) { FoldingStrategy.UpdateFoldings(foldingManager, textEditor.Document); } textEditor.TextArea.TextView.Redraw(); }
/// <summary> /// Central routine of the folding strategy. Uses the document's syntax tree /// to calculate all folding positions. /// </summary> /// <returns> /// Enumeration of foldings. /// </returns> public IEnumerable <NewFolding> GetNewFoldings() { var document = Workspace.CurrentSolution.GetDocument(DocumentId); //var text = document.GetTextAsync().Result; var syntaxTree = document.GetSyntaxTreeAsync().Result; return(FoldingStrategy?.GetNewFoldings(syntaxTree)); }
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); }
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); }
/// <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; } } }
protected override void OnTextChanged(EventArgs e) { SetCurrentValue(DocumentTextProperty, base.Text); FoldingStrategy.UpdateFoldings(FoldingManager, Document); base.OnTextChanged(e); }
private void UpdateFoldings() { FoldingStrategy.UpdateFoldings(_foldingManager, CodeEditor.Document); }
private void TextBox_TextChanged(object sender, EventArgs e) { FoldingStrategy.UpdateFoldings(FoldingManager, TextBox.Document); }