Beispiel #1
0
        private void buttonSearcherOpen_Click(object sender, RoutedEventArgs e)
        {
            SearchFile searchFile = (SearchFile)dataGridSearcher.SelectedItem;

            if (null != searchFile)
            {
                MainWindow.MarkedForOpen.Enqueue(searchFile.FilePath);
            }
        }
Beispiel #2
0
        private void dataGridSearcher_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            SearchFile searchFile = (SearchFile)dataGridSearcher.SelectedItem;

            if (null != searchFile)
            {
                DisplayFile(searchFile);
            }
        }
Beispiel #3
0
        private void DisplayFile(SearchFile searchFile)
        {
            WindowsFormsHost host = new WindowsFormsHost();
            SBDocument       doc  = new SBDocument();

            host.Child        = doc.TextArea;
            doc.TextArea.Text = File.ReadAllText(searchFile.FilePath);
            gridSearcherPreview.Children.Add(host);
            doc.WrapMode          = MainWindow.wrap ? WrapMode.Whitespace : WrapMode.None;
            doc.IndentationGuides = MainWindow.indent ? IndentView.LookBoth : IndentView.None;
            doc.ViewWhitespace    = MainWindow.whitespace ? WhitespaceMode.VisibleAlways : WhitespaceMode.Invisible;
            doc.TextArea.Zoom     = MainWindow.zoom;
            doc.Theme             = MainWindow.theme;

            doc.TextArea.ReadOnly                = true;
            doc.TextArea.SearchFlags             = SearchFlags.None;
            doc.TextArea.Indicators[0].ForeColor = SBDocument.IntToColor(MainWindow.FIND_HIGHLIGHT_COLOR);
            doc.TextArea.Indicators[0].Style     = IndicatorStyle.RoundBox;
            if (textBoxSearcherText.Text != "")
            {
                doc.TextArea.TargetStart = 0;
                doc.TextArea.TargetEnd   = doc.TextArea.TextLength;

                string          keyword       = textBoxSearcherText.Text;
                RegexOptions    caseSensitive = (bool)checkBoxSearcherCase.IsChecked ? RegexOptions.None : RegexOptions.IgnoreCase;
                string          wholeWord     = (bool)checkBoxSearcherWord.IsChecked ? "\\b" + keyword + "\\b" : keyword;
                MatchCollection matches       = Regex.Matches(doc.TextArea.Text, wholeWord, caseSensitive);
                foreach (Match match in matches)
                {
                    doc.TextArea.IndicatorFillRange(match.Index, match.Length);
                }
                textBoxMatches.Text = matches.Count + " matches found";
            }
            else
            {
                textBoxMatches.Text = "";
            }
            doc.TextArea.CurrentPosition = 0;
            doc.TextArea.ScrollCaret();
        }