public string GetSelectedText() { try { if (this.m_DTE.ActiveDocument != null) { TextSelection text_selection = this.m_DTE.ActiveDocument.Selection as TextSelection; if (text_selection != null) { int start_line = text_selection.AnchorPoint.Line; int end_line = text_selection.ActivePoint.Line; if (start_line == end_line) { TextDocument text_doc = this.m_DTE.ActiveDocument.Object("") as TextDocument; if (text_doc != null) { string line = text_doc.CreateEditPoint(null).GetLines(start_line, start_line + 1); SettingsDialogPage settings_page = VSAnythingPackage.Inst.GetSettingsDialogPage(); string result; if (line.Contains("#include")) { int start = line.IndexOf('"'); if (start != -1) { int end = line.IndexOf('"', start + 1); if (end != -1) { result = Path.GetFileName(line.Substring(start + 1, end - start - 1)); return(result); } } } else if (text_selection.Text.Length == 0 && settings_page.UseCurrentWordAsFindText && text_selection.TextRanges.Count > 0 && text_selection.AnchorPoint.LineCharOffset > 0) { result = Utils.GetWord(line, text_selection.AnchorPoint.LineCharOffset - 1); return(result); } result = text_selection.Text; return(result); } } } } } catch (Exception arg_12D_0) { Utils.LogExceptionQuiet(arg_12D_0); } return(null); }
public FastFindForm(DTE dte, SolutionFiles solution_files, FileFinder file_finder, TextFinder text_finder, GetOpenFilesThread get_open_files_thread, Settings settings, string initial_text) { this.InitializeComponent(); this.m_Settings = settings; base.Size = settings.FastFindFormSize; SettingsDialogPage settings_page = VSAnythingPackage.Inst.GetSettingsDialogPage(); if (string.IsNullOrEmpty(initial_text) && settings_page.RememberLastFind && !string.IsNullOrEmpty(FastFindForm.m_LastFindText)) { initial_text = FastFindForm.m_LastFindText; } bool is_modal = true; this.m_FastFindControl = new FastFindControl(dte, solution_files, file_finder, text_finder, get_open_files_thread, settings, initial_text, FastFindForm.m_LastSelectedItem, is_modal); this.m_FastFindControl.Dock = DockStyle.Fill; this.m_FastFindControl.ControlWantsToClose += new FastFindControl.ControlWantsToCloseHandler(this.FastFindControlWantsToClose); base.Controls.Add(this.m_FastFindControl); this.m_FastFindControl.OnActivated(); }
private List <FindFileResult> FindFilesInSolution(FileFinder.Job job, AsyncTask.Context context) { FileFinder.SolutionFiles solution_files = null; object @lock = this.m_Lock; lock (@lock) { solution_files = this.m_SolutionFiles; } string pattern = job.m_TextBoxValue; if (!this.m_Settings.GetSolutionFilesMatchCase(job.m_IsModal)) { pattern = pattern.ToLower(); } SettingsDialogPage arg_5D_0 = VSAnythingPackage.Inst.GetSettingsDialogPage(); bool match_case = job.m_MatchCase; if (arg_5D_0.SpacesAsWildcardsForFindFile && pattern.Contains(' ')) { pattern = "*" + pattern.Replace(' ', '*') + "*"; } bool use_wildacrd = job.m_UseWildcards && pattern.Contains('*'); if (use_wildacrd) { if (!pattern.StartsWith("*")) { pattern = "*" + pattern; } if (!pattern.EndsWith("*")) { pattern += "*"; } } bool use_full_paths = pattern.Contains("\\"); IEnumerable <string> arg_121_0 = this.m_Settings.GetSolutionFilesMatchCase(job.m_IsModal) ? (use_full_paths ? solution_files.m_SolutionFilePaths : solution_files.m_SolutionFileNames) : (use_full_paths ? solution_files.m_SolutionFilePathsLowerCase : solution_files.m_SolutionFileNamesLowercase); List <FindFileResult> found_files = new List <FindFileResult>(); int i = 0; foreach (string file in arg_121_0) { bool match; if (use_wildacrd) { match = Wildcard.Match(file, pattern); } else if (match_case) { match = file.Contains(pattern); } else { match = Utils.StrStr(file, pattern); } if (match) { string file_path = solution_files.m_SolutionFilePaths[i]; string file_name = solution_files.m_SolutionFileNames[i]; FindFileResult found_file = default(FindFileResult); found_file.m_FilePath = file_path; found_file.m_FileName = file_name; if (Path.IsPathRooted(job.m_RootPath) && Path.IsPathRooted(file_path) && Path.GetPathRoot(job.m_RootPath) == Path.GetPathRoot(file_path) && !Utils.IsSolutionFile(file_path)) { found_file.m_RelativeFilePath = Misc.GetRelativePath(job.m_RootPath, file_path); } else { found_file.m_RelativeFilePath = file_path; } found_file.m_PathMatch = false; found_files.Add(found_file); } i++; if (context.Cancelled) { break; } } return(found_files); }