Exemplo n.º 1
0
        private void PopulatePageData(int startIndex, IList <T> pageData, int overallCount)
        {
            bool flagRefresh = false;

            if (_list == null || _list.Length != overallCount)
            {
                _list       = new VirtualListItem <T> [overallCount];
                flagRefresh = true;
            }
            for (int i = 0; i < pageData.Count; i++)
            {
                int index = startIndex + i;
                if (_list[index] == null)
                {
                    _list[index] = new VirtualListItem <T>(this, index, pageData[i]);
                }
                else
                {
                    _list[index].Data = pageData[i];
                }
            }
            if (flagRefresh)
            {
                if (this._synchronizationContext == null || SynchronizationContext.Current != null)
                {
                    FireCollectionReset(null);
                }
                else
                {
                    _synchronizationContext.Send(FireCollectionReset, null);
                }
            }
        }
Exemplo n.º 2
0
        private void SetCurrent(VirtualListItem <T> newItem, int newPosition)
        {
            bool isCurrentBeforeFirst       = _isCurrentBeforeFirst;
            bool isCurrentAfterLast         = _isCurrentAfterLast;
            VirtualListItem <T> currentItem = _currentItem;
            int currentPosition             = _currentPosition;

            _isCurrentBeforeFirst = newPosition < 0;
            _isCurrentAfterLast   = newPosition >= Count;
            _currentItem          = newItem;
            _currentPosition      = newPosition;

            if (currentItem != _currentItem)
            {
                OnCurrentChanged();
            }

            if (isCurrentBeforeFirst != _isCurrentBeforeFirst)
            {
                OnPropertyChanged(_isCurrentBeforeFirstChanged);
            }
            if (isCurrentAfterLast != _isCurrentAfterLast)
            {
                OnPropertyChanged(_isCurrentAfterLastChanged);
            }
            if (currentItem != _currentItem)
            {
                OnPropertyChanged(_currentItemChanged);
            }
            if (currentPosition != _currentPosition)
            {
                OnPropertyChanged(_currentPositionChanged);
            }
        }
Exemplo n.º 3
0
 public VirtualListItem <T> this[int index]
 {
     get
     {
         if (_list[index] == null)
         {
             _list[index] = new VirtualListItem <T>(this, index);
         }
         return(_list[index]);
     }
     set
     {
         throw new NotSupportedException();
     }
 }
Exemplo n.º 4
0
 bool ICollection <VirtualListItem <T> > .Remove(VirtualListItem <T> item)
 {
     throw new NotSupportedException();
 }
Exemplo n.º 5
0
 void ICollection <VirtualListItem <T> > .Add(VirtualListItem <T> item)
 {
     throw new NotSupportedException();
 }
Exemplo n.º 6
0
 void IList <VirtualListItem <T> > .Insert(int index, VirtualListItem <T> item)
 {
     throw new NotSupportedException();
 }
Exemplo n.º 7
0
 public int IndexOf(VirtualListItem <T> item)
 {
     return(item == null || item.List != this ? -1 : item.Index);
 }
Exemplo n.º 8
0
 public bool Contains(VirtualListItem <T> item)
 {
     return(IndexOf(item) != -1);
 }