예제 #1
0
        private void ScrollToNextSearchedCell()
        {
            var regexPattern = TextSearchHelper.GetRegexPattern(SearchPhraseTextBox.Text);
            var regex        = BuildSearchRegularExpression(regexPattern);

            var rowIndex = 0;

            foreach (var row in _resultRows)
            {
                var columnIndex = 0;
                foreach (var item in row)
                {
                    var stringValue = (string)CellValueConverter.Instance.Convert(item, null, null, null);
                    var matchCount  = regex.Matches(stringValue).Count;
                    if (matchCount > 0 &&
                        (rowIndex > _lastSearchedCell.Row || (rowIndex == _lastSearchedCell.Row && columnIndex > _lastSearchedCell.Column)))
                    {
                        _lastSearchedCell = new LastSearchedCell(rowIndex, columnIndex);
                        ResultGrid.GetCell(rowIndex, columnIndex);
                        return;
                    }

                    columnIndex++;
                }

                rowIndex++;
            }
        }
예제 #2
0
        private void SearchAndHighlightMatches()
        {
            var regexPattern = TextSearchHelper.GetRegexPattern(SearchPhraseTextBox.Text);

            if (String.IsNullOrEmpty(regexPattern))
            {
                SearchMatchCount = null;
            }
            else
            {
                var totalMatchCount = 0;
                var regex           = BuildSearchRegularExpression(regexPattern);
                foreach (var row in _resultRows)
                {
                    foreach (var item in row)
                    {
                        var stringValue = (string)CellValueConverter.Instance.Convert(item, null, null, null);
                        totalMatchCount += regex.Matches(stringValue).Count;
                    }
                }

                SearchMatchCount = totalMatchCount;
            }

            HighlightSearchedText();
        }
예제 #3
0
        private void HighlightSearchedText()
        {
            var regexPattern = TextSearchHelper.GetRegexPattern(SearchPhraseTextBox.Text);

            _searchedTextHighlightUsed |= !String.IsNullOrEmpty(regexPattern);

            foreach (var row in ResultGrid.GetDataGridRows())
            {
                if (row == null || !ResultGrid.IsInViewport(row))
                {
                    continue;
                }

                row.HighlightTextItems(regexPattern);
            }
        }
예제 #4
0
 private void HighlightText(IEnumerable <string> searchedWords)
 {
     Dispatcher.BeginInvoke(DispatcherPriority.Render, new Action(() => ListHistoryEntries.HighlightTextItems(TextSearchHelper.GetRegexPattern(searchedWords))));
 }