public FormattedGrepResult(GrepSearchResult result, string folderPath) { GrepResult = result; searchFolderPath = folderPath; bool isFileReadOnly = SetLabel(); if (isFileReadOnly) { GrepResult.ReadOnly = true; Style = "ReadOnly"; } if (!GrepResult.IsSuccess) { Style = "Error"; } if (!string.IsNullOrEmpty(GrepResult.FileInfo.ErrorMsg)) { Style = "Error"; } FormattedLines = new LazyResultsList(result, this); FormattedLines.LineNumberColumnWidthChanged += FormattedLines_PropertyChanged; FormattedLines.LoadFinished += FormattedLines_LoadFinished; }
public FormattedGrepResult(GrepSearchResult result, string folderPath) { grepResult = result; fileInfo = new FileInfo(grepResult.FileNameReal); bool isFileReadOnly = Utils.IsReadOnly(grepResult); bool isSuccess = grepResult.IsSuccess; string basePath = Utils.GetBaseFolder(folderPath).TrimEnd('\\'); string displayedName = Path.GetFileName(grepResult.FileNameDisplayed); if (GrepSettings.Instance.Get <bool>(GrepSettings.Key.ShowFilePathInResults) && grepResult.FileNameDisplayed.Contains(basePath)) { displayedName = grepResult.FileNameDisplayed.Substring(basePath.Length + 1).TrimStart('\\'); } int matchCount = (grepResult.Matches == null ? 0 : grepResult.Matches.Count); if (matchCount > 0) { if (GrepSettings.Instance.Get <bool>(GrepSettings.Key.ShowVerboseMatchCount)) { var lineCount = grepResult.Matches.Where(r => r.LineNumber > 0) .Select(r => r.LineNumber).Distinct().Count(); displayedName = string.Format("{0} ({1} matches on {2} lines)", displayedName, matchCount, lineCount); } else { displayedName = string.Format("{0} ({1})", displayedName, matchCount); } } if (isFileReadOnly) { result.ReadOnly = true; displayedName = displayedName + " [read-only]"; } label = displayedName; if (isFileReadOnly) { style = "ReadOnly"; } if (!isSuccess) { style = "Error"; } formattedLines = new LazyResultsList(result, this); formattedLines.LineNumberColumnWidthChanged += formattedLines_PropertyChanged; formattedLines.LoadFinished += formattedLines_LoadFinished; if (GrepSettings.Instance.Get <bool>(GrepSettings.Key.ExpandResults)) { IsExpanded = true; } }
public FormattedGrepResult(GrepSearchResult result, string folderPath) { grepResult = result; fileInfo = new FileInfo(grepResult.FileNameReal); bool isFileReadOnly = Utils.IsReadOnly(grepResult); bool isSuccess = grepResult.IsSuccess; string displayedName = Path.GetFileName(grepResult.FileNameDisplayed); if (GrepSettings.Instance.Get <bool>(GrepSettings.Key.ShowFilePathInResults) && grepResult.FileNameDisplayed.Contains(Utils.GetBaseFolder(folderPath) + "\\")) { displayedName = grepResult.FileNameDisplayed.Substring(Utils.GetBaseFolder(folderPath).Length + 1); } int lineCount = (grepResult.Matches == null ? 0 : grepResult.Matches.Count); if (lineCount > 0) { displayedName = string.Format("{0} ({1})", displayedName, lineCount); } if (isFileReadOnly) { result.ReadOnly = true; displayedName = displayedName + " [read-only]"; } label = displayedName; if (isFileReadOnly) { style = "ReadOnly"; } if (!isSuccess) { style = "Error"; } formattedLines = new LazyResultsList(result, this); formattedLines.LineNumberColumnWidthChanged += formattedLines_PropertyChanged; formattedLines.LoadFinished += formattedLines_LoadFinished; if (GrepSettings.Instance.Get <bool>(GrepSettings.Key.ExpandResults)) { IsExpanded = true; } }
public FormattedGrepResult(GrepSearchResult result, string folderPath) { GrepResult = result; bool isFileReadOnly = Utils.IsReadOnly(GrepResult); bool isSuccess = GrepResult.IsSuccess; string basePath = string.IsNullOrWhiteSpace(folderPath) ? string.Empty : folderPath.TrimEnd('\\'); string displayedName = Path.GetFileName(GrepResult.FileNameDisplayed); if (GrepSettings.Instance.Get <bool>(GrepSettings.Key.ShowFilePathInResults) && GrepResult.FileNameDisplayed.Contains(basePath, StringComparison.CurrentCultureIgnoreCase)) { if (!string.IsNullOrWhiteSpace(basePath)) { displayedName = GrepResult.FileNameDisplayed.Substring(basePath.Length + 1).TrimStart('\\'); } else { displayedName = GrepResult.FileNameDisplayed; } } if (!string.IsNullOrWhiteSpace(GrepResult.AdditionalInformation)) { displayedName += " " + GrepResult.AdditionalInformation + " "; } int matchCount = (GrepResult.Matches == null ? 0 : GrepResult.Matches.Count); if (matchCount > 0) { if (GrepSettings.Instance.Get <bool>(GrepSettings.Key.ShowVerboseMatchCount)) { var lineCount = GrepResult.Matches.Where(r => r.LineNumber > 0) .Select(r => r.LineNumber).Distinct().Count(); displayedName = string.Format("{0} ({1} matches on {2} lines)", displayedName, matchCount, lineCount); } else { displayedName = string.Format("{0} ({1})", displayedName, matchCount); } } if (isFileReadOnly) { result.ReadOnly = true; displayedName = displayedName + " [read-only]"; } Label = displayedName; if (isFileReadOnly) { Style = "ReadOnly"; } if (!isSuccess) { Style = "Error"; } FormattedLines = new LazyResultsList(result, this); FormattedLines.LineNumberColumnWidthChanged += FormattedLines_PropertyChanged; FormattedLines.LoadFinished += FormattedLines_LoadFinished; }