private void SetContentForFile(string filePath, string searchPattern, FormatSearchResultLine formatLine = null, string prefix = "", StreamWriter logWriter = null)
        {
            List <string> extractedLines;

            if (this.IsRegEx.IsChecked ?? false)
            {
                extractedLines = FileTools.ExtractLinesMatchingRegEx(filePath, searchPattern) as List <string>;
            }
            else
            {
                extractedLines = FileTools.ExtractLinesContainingSearchPattern(filePath, searchPattern) as List <string>;
            }

            var omitPrefix       = this.OmitPrefix.IsChecked ?? false;
            var omitLineBreak    = this.OmitLineBreak.IsChecked ?? false;
            var removeDuplicates = this.RemoveDuplicates.IsChecked ?? false;

            if (removeDuplicates)
            {
                extractedLines = extractedLines.Distinct().ToList();
            }

            var sorting = this.Sorting.SelectedValue.ToString();

            switch (sorting)
            {
            case "Content ASC":
                extractedLines.Sort();
                break;

            case "Content DESC":
                extractedLines = extractedLines.OrderByDescending(x => x).ToList();
                break;

            default:
                break;
            }

            var searchRegex    = new Regex(searchPattern);
            var replacePattern = this.ReplacePattern.Text;

            foreach (var line in extractedLines)
            {
                var lineContent = line;

                if (!string.IsNullOrEmpty(replacePattern))
                {
                    lineContent = searchRegex.Replace(line, replacePattern);
                }

                if (logWriter != null)
                {
                    logWriter.WriteLine(
                        string.Format(
                            CultureInfo.InvariantCulture,
                            "{0}{1}{2}",
                            omitPrefix ? string.Empty : prefix + (string.IsNullOrEmpty(prefix) ? string.Empty : " - "),
                            formatLine != null ? formatLine(lineContent) : lineContent,
                            omitLineBreak ? string.Empty : "\r\n"));
                }
                else
                {
                    this.Output.Text += string.Format(
                        CultureInfo.InvariantCulture,
                        "{0}{1}{2}",
                        omitPrefix ? string.Empty : prefix + (string.IsNullOrEmpty(prefix) ? string.Empty : " - "),
                        formatLine != null ? formatLine(lineContent) : lineContent,
                        omitLineBreak ? string.Empty : "\r\n");
                }
            }
        }
 private void CalculateChecksum_Click(object sender, RoutedEventArgs e)
 {
     this.Output.Text = FileTools.CalculateChecksum(this.ChecksumType.Text, this.FilePath.Text);
 }