/// <summary> /// Occurs when the document outline is updated. /// </summary> /// <param name="window">The window that was updated.</param> public void NotifyDocumentOutlineUpdated(EditorDocumentWindow window) { if (window != null) { documentOutlineToolWindow.Title = "Document Outline - " + window.Title; var parseData = window.Editor.Document.ParseData as LLParseData; if ((parseData != null) && (parseData.Ast != null)) { this.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, (Action)(() => { var astString = parseData.Ast.ToTreeString(0); if (astString.Length > 10000) { documentOutlineTextBox.Text = "(AST is too large to display)"; } else { documentOutlineTextBox.Text = astString; } })); return; } } else { documentOutlineToolWindow.Title = "Document Outline"; } documentOutlineTextBox.Text = "(none)"; }
/// <summary> /// Occurs when a search operation occurs in a view. /// </summary> /// <param name="window">The window that was searched.</param> /// <param name="resultSet">An <see cref="ISearchResultSet"/> that contains the search results.</param> public void NotifyEditorViewSearch(EditorDocumentWindow window, ISearchResultSet resultSet) { // Show the results findResultsToolWindow.Title = String.Format("Find Results - {0} match{1}", resultSet.Results.Count, (resultSet.Results.Count == 1 ? String.Empty : "es")); findResultsToolWindow.DataContext = window.Editor; findResultsTextBox.Text = resultSet.ToString(); findResultsTextBox.DataContext = resultSet; if (findResultsToolWindow.IsOpen) { findResultsToolWindow.Activate(false); } if (resultSet.Results.Count > 0) { window.Activate(); } }
/// <summary> /// Creates and activates a new editor document. /// </summary> /// <param name="fileName">The file name.</param> /// <param name="extension">The file extension, used to determine a language.</param> /// <param name="text">The optional text to use.</param> private void CreateSyntaxEditorDocument(string extension, string fileName, string text) { if (fileName != null) { // Load the file's text try { if (File.Exists(fileName)) { text = File.ReadAllText(fileName); } } catch { text = String.Empty; } } else { // Ensure a filename has been set fileName = String.Format("Document{0}{1}", ++documentIndex, extension.ToLowerInvariant()); } // Create document data var data = new DocumentData(); data.FileName = fileName; data.NotifyDocumentOutlineUpdated = this.NotifyDocumentOutlineUpdated; data.NotifySearchAction = this.NotifyEditorViewSearch; // Create the document var documentWindow = new EditorDocumentWindow(data, text); dockSite.DocumentWindows.Add(documentWindow); // Activate the document documentWindow.Activate(); }