예제 #1
0
        private void Find(object sender, RoutedEventArgs e)
        {
            using (TemporaryCursor.SetWaitCursor())
            {
                this.searchResults.Clear();
                FindInFilesDialog.LookIn lookInValue = this.GetLookInValue();
                if (this.FindString == null || this.FindString.Trim().Length <= 0)
                {
                    return;
                }
                ISolution currentSolution = this.projectManager.CurrentSolution;
                if (currentSolution == null)
                {
                    return;
                }
                switch (lookInValue)
                {
                case FindInFilesDialog.LookIn.Solution:
                    using (IEnumerator <IProject> enumerator = currentSolution.Projects.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            this.FindInProject(enumerator.Current);
                        }
                        break;
                    }

                case FindInFilesDialog.LookIn.Project:
                    DocumentView documentView1 = this.viewService.ActiveView as DocumentView;
                    IProject     project1      = documentView1 == null?EnumerableExtensions.SingleOrNull <IProject>(this.projectManager.ItemSelectionSet.SelectedProjects) : currentSolution.FindProjectContainingOpenItem(documentView1.Document.DocumentReference);

                    if (project1 == null)
                    {
                        break;
                    }
                    this.FindInProject(project1);
                    break;

                case FindInFilesDialog.LookIn.OpenDocuments:
                    using (IEnumerator <IView> enumerator = this.viewService.Views.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            DocumentView documentView2 = enumerator.Current as DocumentView;
                            if (documentView2 != null)
                            {
                                this.FindInFile(currentSolution.FindProjectContainingOpenItem(documentView2.Document.DocumentReference).FindItem(documentView2.Document.DocumentReference), new FindInFilesDialog.ProcessResult(this.SaveResult), (FindInFilesResult)null);
                            }
                        }
                        break;
                    }

                case FindInFilesDialog.LookIn.CurrentDocument:
                    DocumentView documentView3 = this.viewService.ActiveView as DocumentView;
                    if (documentView3 != null)
                    {
                        this.FindInFile(currentSolution.FindProjectContainingOpenItem(documentView3.Document.DocumentReference).FindItem(documentView3.Document.DocumentReference), new FindInFilesDialog.ProcessResult(this.SaveResult), (FindInFilesResult)null);
                        break;
                    }
                    IProject      project2     = EnumerableExtensions.SingleOrNull <IProject>(this.projectManager.ItemSelectionSet.SelectedProjects);
                    IDocumentItem documentItem = EnumerableExtensions.SingleOrNull <IDocumentItem>(this.projectManager.ItemSelectionSet.Selection);
                    if (project2 == null || documentItem == null)
                    {
                        break;
                    }
                    this.FindInFile(project2.FindItem(documentItem.DocumentReference), new FindInFilesDialog.ProcessResult(this.SaveResult), (FindInFilesResult)null);
                    break;
                }
            }
        }