コード例 #1
0
        /// <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();
            }
        }
コード例 #2
0
        /// <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();
        }