コード例 #1
0
        private void ActivateResult(IProjectItem projectItem, FindInFilesResult result)
        {
            if (projectItem == null)
            {
                return;
            }
            if (this.FindInFile(projectItem, new FindInFilesDialog.ProcessResult(this.UpdateResult), result))
            {
                result.Line   = -1;
                result.Column = -1;
                this.FindInFile(projectItem, new FindInFilesDialog.ProcessResult(this.UpdateToLastResult), result);
            }
            if (result.Line == -1 || result.Column == -1)
            {
                return;
            }
            IDocumentView documentView = projectItem.OpenView(true);

            if (documentView == null)
            {
                return;
            }
            ISetCaretPosition setCaretPosition = documentView as ISetCaretPosition;

            if (setCaretPosition == null)
            {
                return;
            }
            setCaretPosition.SetCaretPosition(result.Line, result.Column);
        }
コード例 #2
0
        private bool SaveResult(IProjectItem projectItem, int line, int column, string lineContent, FindInFilesResult previousResult)
        {
            FindInFilesResult result = new FindInFilesResult();

            result.Column        = column;
            result.Line          = line;
            result.LineContent   = lineContent;
            result.Project       = projectItem.Project.Name;
            result.Image         = projectItem.DocumentType.Image;
            result.FileName      = projectItem.DocumentReference.DisplayName;
            result.InvokeCommand = new DelegateCommand((DelegateCommand.SimpleEventHandler)(() => this.ActivateResult(projectItem, result)));
            this.searchResults.Add(result);
            return(true);
        }
コード例 #3
0
 private bool UpdateToLastResult(IProjectItem projectItem, int line, int column, string lineContent, FindInFilesResult previousResult)
 {
     previousResult.Line   = line;
     previousResult.Column = column;
     return(true);
 }
コード例 #4
0
 private bool UpdateResult(IProjectItem projectItem, int line, int column, string lineContent, FindInFilesResult previousResult)
 {
     if (line < previousResult.Line || column < previousResult.Column)
     {
         return(true);
     }
     if (line > previousResult.Line)
     {
         previousResult.Line   = line;
         previousResult.Column = column;
     }
     else if (column > previousResult.Column)
     {
         previousResult.Column = column;
     }
     return(false);
 }
コード例 #5
0
        private bool SearchText(IProjectItem projectItem, TextReader textReader, FindInFilesDialog.ProcessResult callback, FindInFilesResult previousResult)
        {
            string str1 = string.Empty;
            int    num1 = -1;
            string str2;
            int    num2;

            do
            {
                ++num1;
                str2 = textReader.ReadLine();
                if (str2 != null)
                {
                    num2 = str2.IndexOf(this.FindString, this.comparison);
                }
                else
                {
                    goto label_4;
                }
            }while (num2 < 0 || callback(projectItem, num1 + 1, num2 + 1, str2.Trim(), previousResult));
            return(false);

label_4:
            return(true);
        }
コード例 #6
0
 private bool FindInFile(IProjectItem projectItem, FindInFilesDialog.ProcessResult callback, FindInFilesResult previousResult)
 {
     if (!this.IsTargetExtension(projectItem.DocumentType.DefaultFileExtension))
     {
         return(false);
     }
     try
     {
         if (Microsoft.Expression.Framework.Documents.PathHelper.FileExists(projectItem.DocumentReference.Path))
         {
             if (!projectItem.IsDirty)
             {
                 using (TextReader textReader = (TextReader) new StreamReader((Stream) new FileStream(projectItem.DocumentReference.Path, FileMode.Open, FileAccess.Read)))
                 {
                     if (!this.SearchText(projectItem, textReader, callback, previousResult))
                     {
                         return(false);
                     }
                 }
             }
             else
             {
                 string s = (string)null;
                 IReadableTextBuffer readableTextBuffer = projectItem.Document as IReadableTextBuffer;
                 if (readableTextBuffer != null)
                 {
                     s = readableTextBuffer.GetText(0, readableTextBuffer.Length);
                 }
                 else
                 {
                     CodeDocument codeDocument = projectItem.Document as CodeDocument;
                     if (codeDocument != null)
                     {
                         s = codeDocument.Document != null ? codeDocument.Document.Text : string.Empty;
                     }
                 }
                 if (s != null)
                 {
                     using (TextReader textReader = (TextReader) new StringReader(s))
                     {
                         if (!this.SearchText(projectItem, textReader, callback, previousResult))
                         {
                             return(false);
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
     }
     return(true);
 }