//------------------------------------------------------ // // Protected Methods // //------------------------------------------------------ #region Protected Methods /// <summary> /// Re-create the view, using any <seealso cref="CollectionView.SortDescriptions"/> and/or <seealso cref="CollectionView.Filter"/>. /// </summary> protected override void RefreshOverride() { bool wasEmpty = IsEmpty; object oldCurrentItem = CurrentItem; bool oldIsCurrentAfterLast = IsCurrentAfterLast; bool oldIsCurrentBeforeFirst = IsCurrentBeforeFirst; int oldCurrentPosition = CurrentPosition; // force currency off the collection (gives user a chance to save dirty information) OnCurrentChanging(); if (SortDescriptions.Count > 0 || Filter != null) { // filter the view list if (Filter == null) { _viewList = new ArrayList(_rawList); } else { // optimized for footprint: initialize to size 0 and let AL amortize cost of growth _viewList = new ArrayList(); for (int k = 0; k < _rawList.Count; ++k) { if (Filter(_rawList[k])) { _viewList.Add(_rawList[k]); } } } // sort the view list if (_sort != null && _sort.Count > 0 && ViewCount > 0) { SortFieldComparer.SortHelper(_viewList, new SortFieldComparer(_sort, Culture)); } } else // no sort or filter { _viewList = _rawList; } if (IsEmpty || oldIsCurrentBeforeFirst) { _MoveCurrentToPosition(-1); } else if (oldIsCurrentAfterLast) { _MoveCurrentToPosition(ViewCount); } else if (oldCurrentItem != null) // set currency back to old current item, or first if not found { int index = _viewList.IndexOf(oldCurrentItem); if (index < 0) { index = 0; } _MoveCurrentToPosition(index); } ClearIsModified(); OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); OnCurrentChanged(); if (IsCurrentAfterLast != oldIsCurrentAfterLast) { OnPropertyChanged(IsCurrentAfterLastPropertyName); } if (IsCurrentBeforeFirst != oldIsCurrentBeforeFirst) { OnPropertyChanged(IsCurrentBeforeFirstPropertyName); } if (oldCurrentPosition != CurrentPosition) { OnPropertyChanged(CurrentPositionPropertyName); } if (oldCurrentItem != CurrentItem) { OnPropertyChanged(CurrentItemPropertyName); } }
// Token: 0x06007815 RID: 30741 RVA: 0x00223A18 File Offset: 0x00221C18 protected override void RefreshOverride() { bool isEmpty = this.IsEmpty; object currentItem = this.CurrentItem; bool isCurrentAfterLast = this.IsCurrentAfterLast; bool isCurrentBeforeFirst = this.IsCurrentBeforeFirst; int currentPosition = this.CurrentPosition; base.OnCurrentChanging(); if (this.SortDescriptions.Count > 0 || this.Filter != null) { if (this.Filter == null) { this._viewList = new ArrayList(this._rawList); } else { this._viewList = new ArrayList(); for (int i = 0; i < this._rawList.Count; i++) { if (this.Filter(this._rawList[i])) { this._viewList.Add(this._rawList[i]); } } } if (this._sort != null && this._sort.Count > 0 && this.ViewCount > 0) { SortFieldComparer.SortHelper(this._viewList, new SortFieldComparer(this._sort, this.Culture)); } } else { this._viewList = this._rawList; } if (this.IsEmpty || isCurrentBeforeFirst) { this._MoveCurrentToPosition(-1); } else if (isCurrentAfterLast) { this._MoveCurrentToPosition(this.ViewCount); } else if (currentItem != null) { int num = this._viewList.IndexOf(currentItem); if (num < 0) { num = 0; } this._MoveCurrentToPosition(num); } this.ClearIsModified(); this.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); this.OnCurrentChanged(); if (this.IsCurrentAfterLast != isCurrentAfterLast) { this.OnPropertyChanged("IsCurrentAfterLast"); } if (this.IsCurrentBeforeFirst != isCurrentBeforeFirst) { this.OnPropertyChanged("IsCurrentBeforeFirst"); } if (currentPosition != this.CurrentPosition) { this.OnPropertyChanged("CurrentPosition"); } if (currentItem != this.CurrentItem) { this.OnPropertyChanged("CurrentItem"); } }