private void ViewSelectedContext() { List <FileContext> MatchFiles = new List <FileContext>(); string Title = "Context"; string SearchString = txtSearchString.Text; string tempSearch = chkFilterMatchCase.Checked ? SearchString : SearchString.ToUpper(); int C = 0; int MC = 0; foreach (DataGridViewRow Row in grdResults.Rows) { string FilePath = Path.Combine(Row.Cells["Path"].Value.ToString(), Row.Cells["Name"].Value.ToString()); int[] MatchLines = new int[0]; if (chkSearchRegex.Checked) { MatchLines = GetFileContextsRegex(FilePath); } else { MatchLines = GetFileContexts(FilePath); } MatchFiles.Add(GetContexts(MatchLines, FilePath, properties.ContextSize)); MC += MatchLines.Length; lblStatus.Text = string.Format("{0} files searched; {1} total matches", ++C, MC); } TextViewer TV = new TextViewer(properties); TV.ShowContexts(Title, MatchFiles, tempSearch, chkSearchRegex.Checked); }
private void ViewSelectedContext() { var matchFiles = new List <FileContext>(); const string title = "Context"; var searchString = txtSearchString.Text; var c = 0; var mc = 0; foreach (DataGridViewRow row in grdResults.Rows) { if (!row.Visible) { continue; } var filePath = Path.Combine(row.Cells["Directory"].Value.ToString(), row.Cells["Name"].Value.ToString()); var matchLines = chkSearchRegex.Checked ? GetFileContextsRegex(filePath) : GetFileContexts(filePath); matchFiles.Add(GetContexts(matchLines, filePath, _properties.ContextSize)); mc += matchLines.Length; // ReSharper disable once LocalizableElement lblStatus.Text = $"{++c} files searched; {mc} total matches"; } var tv = new TextViewer(); tv.ShowContexts(title, matchFiles, searchString, chkSearchRegex.Checked); }
private void ViewSelectedItems() { List <string> Files = new List <string>(); foreach (DataGridViewRow Row in grdResults.SelectedRows) { string FilePath = Path.Combine(Row.Cells["Path"].Value.ToString(), Row.Cells["Name"].Value.ToString()); if (File.Exists(FilePath)) { Files.Add(FilePath); } } if (properties.ExternalEditor) { foreach (string FilePath in Files) { string tempSearch = chkFilterMatchCase.Checked ? txtSearchString.Text : txtSearchString.Text.ToUpper(); System.Diagnostics.Process.Start(properties.TextEditor, FilePath); } } else if (Files.Count > 0) { TextViewer tv = new TextViewer(properties); tv.ShowFiles("Selected Files", Files, txtSearchString.Text, chkSearchRegex.Checked); } }
private void ViewSelectedItems() { var files = new List <string>(); foreach (DataGridViewRow row in grdResults.SelectedRows) { if (!row.Visible) { continue; } var filePath = Path.Combine(row.Cells["Directory"].Value.ToString(), row.Cells["Name"].Value.ToString()); if (File.Exists(filePath)) { files.Add(filePath); } } if (_properties.ExternalEditor) { foreach (var filePath in files) { try { System.Diagnostics.Process.Start(_properties.TextEditor, filePath); } catch (Exception x) { AddError($"Error opening text Text Editor '{_properties.TextEditor}'"); AddError(x.Message); break; } } } else if (files.Count > 0) { var tv = new TextViewer(); tv.ShowFiles("Selected Files", files, txtSearchString.Text); } }