private void SetCurrent(VirtualListItem <T> newItem, int newPosition)
        {
            var isCurrentBeforeFirst = _isCurrentBeforeFirst;
            var isCurrentAfterLast   = _isCurrentAfterLast;
            var currentItem          = _currentItem;
            var 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);
            }
        }
Esempio n. 2
0
 public VirtualListItem <T> this[int index]
 {
     get
     {
         try
         {
             if (_list != null && _list[index] == null)// && _list.Length <= index
             {
                 _list[index] = new VirtualListItem <T>(this, index);
             }
             return(_list != null ? _list[index] : null);
         }
         catch (Exception)
         {
             throw;
         }
     }
     set
     {
         throw new NotSupportedException();
     }
 }
Esempio n. 3
0
        private void PopulatePageData(int startIndex, IList <T> pageData, int overallCount)
        {
            var flagRefresh = false;

            if (_list == null || _list.Length != overallCount || overallCount == 0)
            {
                _list       = new VirtualListItem <T> [overallCount];
                flagRefresh = true;
            }
            for (var i = 0; i < pageData.Count; i++)
            {
                var index = startIndex + i;
                if (index >= _list.Count())
                {
                    continue;
                }
                if (_list.Count() == index || _list[index] == null)
                {
                    _list[index] = new VirtualListItem <T>(this, index, pageData[i]);
                }
                else
                {
                    _list[index].Data = pageData[i];
                }
            }
            if (flagRefresh)
            {
                if (_synchronizationContext == null || SynchronizationContext.Current != null)
                {
                    FireCollectionReset(null);
                }
                else
                {
                    _synchronizationContext.Post(FireCollectionReset, null);
                }
            }
        }
Esempio n. 4
0
 bool ICollection <VirtualListItem <T> > .Remove(VirtualListItem <T> item)
 {
     throw new NotSupportedException();
 }
Esempio n. 5
0
 void ICollection <VirtualListItem <T> > .Add(VirtualListItem <T> item)
 {
     throw new NotSupportedException();
 }
Esempio n. 6
0
 void IList <VirtualListItem <T> > .Insert(int index, VirtualListItem <T> item)
 {
     throw new NotSupportedException();
 }
Esempio n. 7
0
 public int IndexOf(VirtualListItem <T> item)
 {
     return(item == null || item.List != this ? -1 : item.Index);
 }
Esempio n. 8
0
 public bool Contains(VirtualListItem <T> item)
 {
     return(IndexOf(item) != -1);
 }