public SearchProgressChangedEventArgs(
     string criteria,
     GridSearchResultCellInfo cell,
     GridSearchResultCellCollection cells,
     bool searchFinished)
 {
     this.searchCriteria = criteria;
     this.cell           = cell;
     this.cells          = cells;
     this.searchFinished = searchFinished;
 }
 protected virtual void ReportSearchProgress(
     int percent,
     GridSearchResultCellInfo resultCell,
     GridSearchResultCellCollection resultCells)
 {
     if (resultCell != null)
     {
         this.searchResult.Add(resultCell);
         if (this.searchResult.Count == 1 && this.AutomaticallySelectFirstResult)
         {
             this.SelectNextSearchResult();
         }
     }
     else if (resultCells != null)
     {
         foreach (GridSearchResultCellInfo resultCell1 in (List <GridSearchResultCellInfo>)resultCells)
         {
             this.searchResult.Add(resultCell1);
         }
     }
     this.OnSearchProgressChanged(new SearchProgressChangedEventArgs(this.searchCriteria, resultCell, resultCells, percent == 100));
 }
        protected virtual void TraverseRows(DoWorkEventArgs e = null)
        {
            if (e != null)
            {
                e.Result = (object)false;
            }
            bool            flag       = false;
            GridViewRowInfo currentRow = this.ViewTemplate.MasterTemplate.Owner.CurrentRow;
            GridSearchResultCellCollection resultCells = (GridSearchResultCellCollection)null;
            IEnumerator enumerator = (IEnumerator)this.CreateTraverser();

            if (this.ViewTemplate.MasterTemplate.EnablePaging)
            {
                enumerator = this.CreatePagedTraverser(this.ViewTemplate.MasterTemplate.EnableGrouping && this.ViewTemplate.MasterTemplate.GroupDescriptors.Count > 0);
            }
            int traverserRowIndex = -1;

            while (enumerator.MoveNext())
            {
                ++traverserRowIndex;
                if (GridViewSearchRowInfo.Cancel && !this.IsSearchAsync)
                {
                    GridViewSearchRowInfo.Cancel = false;
                    e.Result = (object)true;
                    return;
                }
                if (!(enumerator.Current is GridViewTableHeaderRowInfo) && !(enumerator.Current is GridViewNewRowInfo) && (!(enumerator.Current is GridViewFilteringRowInfo) && !(enumerator.Current is GridViewSearchRowInfo)))
                {
                    if (this.SearchFromCurrentPosition)
                    {
                        if (enumerator.Current == currentRow)
                        {
                            flag = true;
                        }
                        if (currentRow != null && !flag)
                        {
                            continue;
                        }
                    }
                    GridViewGroupRowInfo current1 = enumerator.Current as GridViewGroupRowInfo;
                    if (current1 != null)
                    {
                        if (GridViewSearchRowInfo.Cancel && !this.IsSearchAsync)
                        {
                            GridViewSearchRowInfo.Cancel = false;
                            e.Result = (object)true;
                            return;
                        }
                        if (this.MatchesSearchCriteria(this.searchCriteria, (GridViewRowInfo)current1, (GridViewColumn)null))
                        {
                            GridViewColumn groupedColumnInfo = this.GetGroupedColumnInfo(current1);
                            if (current1.SearchCache.ContainsKey((object)groupedColumnInfo))
                            {
                                current1.SearchCache[(object)groupedColumnInfo] = (object)this.searchCriteria;
                            }
                            else
                            {
                                current1.SearchCache.Add((object)groupedColumnInfo, (object)this.searchCriteria);
                            }
                            GridSearchResultCellInfo resultCell = new GridSearchResultCellInfo((GridViewRowInfo)current1, (GridViewColumn)null, traverserRowIndex, 0);
                            if (this.searchResult.Count < this.InitialSearchResultsTreshold)
                            {
                                this.ReportSearchProgress(0, resultCell, (GridSearchResultCellCollection)null);
                            }
                            else
                            {
                                if (resultCells == null)
                                {
                                    resultCells = new GridSearchResultCellCollection(this.SearchResultsGroupSize);
                                }
                                resultCells.Add(resultCell);
                                if (resultCells.Count == this.SearchResultsGroupSize)
                                {
                                    this.ReportSearchProgress(0, (GridSearchResultCellInfo)null, resultCells);
                                    resultCells = (GridSearchResultCellCollection)null;
                                }
                            }
                        }
                    }
                    else
                    {
                        GridViewRowInfo current2             = enumerator.Current as GridViewRowInfo;
                        int             traverserColumnIndex = -1;
                        for (int index = 0; index < current2.ViewTemplate.Columns.Count; ++index)
                        {
                            GridViewColumn column = (GridViewColumn)current2.ViewTemplate.Columns[index];
                            ++traverserColumnIndex;
                            if (GridViewSearchRowInfo.Cancel && !this.IsSearchAsync)
                            {
                                GridViewSearchRowInfo.Cancel = false;
                                e.Result = (object)true;
                                return;
                            }
                            GridViewDataColumn gridViewDataColumn = column as GridViewDataColumn;
                            if ((gridViewDataColumn == null || gridViewDataColumn.AllowSearching) && (column.IsVisible && !column.IsGrouped) && (!(column is GridViewImageColumn) && this.MatchesSearchCriteria(this.searchCriteria, current2, column)))
                            {
                                if (current2.SearchCache.ContainsKey((object)column))
                                {
                                    current2.SearchCache[(object)column] = (object)this.searchCriteria;
                                }
                                else
                                {
                                    current2.SearchCache.Add((object)column, (object)this.searchCriteria);
                                }
                                GridSearchResultCellInfo resultCell = new GridSearchResultCellInfo(current2, column, traverserRowIndex, traverserColumnIndex);
                                if (this.searchResult.Count < this.InitialSearchResultsTreshold)
                                {
                                    this.ReportSearchProgress(0, resultCell, (GridSearchResultCellCollection)null);
                                }
                                else
                                {
                                    if (resultCells == null)
                                    {
                                        resultCells = new GridSearchResultCellCollection();
                                    }
                                    resultCells.Add(resultCell);
                                    if (resultCells.Count == this.SearchResultsGroupSize)
                                    {
                                        this.ReportSearchProgress(0, (GridSearchResultCellInfo)null, resultCells);
                                        resultCells = (GridSearchResultCellCollection)null;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (resultCells != null && resultCells.Count > 0)
            {
                this.ReportSearchProgress(100, (GridSearchResultCellInfo)null, resultCells);
            }
            else
            {
                this.ReportSearchProgress(100, (GridSearchResultCellInfo)null, (GridSearchResultCellCollection)null);
            }
        }
        public virtual void Search(string criteria)
        {
            if (this.IsSearchSuspended)
            {
                return;
            }
            this.searchCriteria         = criteria;
            this.selectionChangedByUser = false;
            if (this.worker.IsBusy)
            {
                if (!this.worker.CancellationPending && !GridViewSearchRowInfo.Cancel)
                {
                    this.worker.CancelAsync();
                    GridViewSearchRowInfo.Cancel = true;
                }
                Application.DoEvents();
            }
            foreach (GridSearchResultCellInfo searchResultCellInfo in (List <GridSearchResultCellInfo>) this.searchResult)
            {
                searchResultCellInfo.RowInfo.SearchCache.Clear();
            }
            string cacheKey = this.GetCacheKey();

            if (this.cache.ContainsKey((object)cacheKey))
            {
                this.searchResult             = new GridSearchResultCellCollection((IEnumerable <GridSearchResultCellInfo>)(this.cache[(object)cacheKey] as GridSearchResultCellCollection));
                this.searchResultCurrentIndex = -1;
                foreach (GridSearchResultCellInfo searchResultCellInfo in (List <GridSearchResultCellInfo>) this.searchResult)
                {
                    GridViewGroupRowInfo rowInfo        = searchResultCellInfo.RowInfo as GridViewGroupRowInfo;
                    GridViewColumn       gridViewColumn = searchResultCellInfo.ColumnInfo;
                    if (rowInfo != null)
                    {
                        gridViewColumn = this.GetGroupedColumnInfo(rowInfo);
                    }
                    GridViewDataColumn gridViewDataColumn = gridViewColumn as GridViewDataColumn;
                    if (gridViewDataColumn == null || gridViewDataColumn.AllowSearching)
                    {
                        if (searchResultCellInfo.RowInfo.SearchCache.ContainsKey((object)gridViewColumn))
                        {
                            searchResultCellInfo.RowInfo.SearchCache[(object)gridViewColumn] = (object)criteria;
                        }
                        else
                        {
                            searchResultCellInfo.RowInfo.SearchCache.Add((object)gridViewColumn, (object)criteria);
                        }
                    }
                }
                if (this.searchResult.Count > 0 && this.AutomaticallySelectFirstResult)
                {
                    this.SelectNextSearchResult();
                }
                this.OnSearchProgressChanged(new SearchProgressChangedEventArgs(this.searchCriteria, (GridSearchResultCellInfo)null, this.searchResult, true));
            }
            else
            {
                while (this.worker.IsBusy)
                {
                    Application.DoEvents();
                }
                this.searchResult.Clear();
                this.searchResultCurrentIndex = -1;
                GridViewSearchRowInfo.Cancel  = false;
                if (!string.IsNullOrEmpty(criteria))
                {
                    this.isSearching = true;
                    if (this.IsSearchAsync)
                    {
                        this.worker.RunWorkerAsync((object)criteria);
                    }
                    else
                    {
                        this.TraverseRows((DoWorkEventArgs)null);
                    }
                }
                else
                {
                    this.OnSearchProgressChanged(new SearchProgressChangedEventArgs(this.searchCriteria, (GridSearchResultCellInfo)null, this.searchResult, true));
                }
            }
        }