コード例 #1
0
        protected bool SetCurrentPositionCore(
            int newPosition,
            bool forceNotify,
            CurrentChangeReason reason)
        {
            if (newPosition >= this.Count)
            {
                newPosition = this.Count - 1;
            }
            TDataItem dataItem = default(TDataItem);

            if (newPosition >= 0 && newPosition < this.Count)
            {
                dataItem = this.Items[newPosition];
            }
            int num = (object)dataItem != null?dataItem.GetHashCode() : -1;

            if (num != this.currentItemHashCode)
            {
                forceNotify = true;
                this.currentItemHashCode = num;
            }
            if (this.CurrentPosition == newPosition && !forceNotify)
            {
                return(false);
            }
            if (this.update == 0)
            {
                CurrentChangingEventArgs changingEventArgs = new CurrentChangingEventArgs(reason);
                this.OnCurrentChanging((CancelEventArgs)changingEventArgs);
                if (changingEventArgs.Cancel)
                {
                    return(false);
                }
            }
            this.CurrentPosition         = newPosition;
            this.positionChangedInUpdate = this.update > 0;
            if (this.update == 0)
            {
                this.OnCurrentChanged((EventArgs) new CurrentChangedEventArgs(reason));
            }
            return(true);
        }
コード例 #2
0
 public CurrentChangedEventArgs(CurrentChangeReason reason)
 {
     this.reason = reason;
 }