public void Refresh()
        {
            DataRefBase <T> currentItem          = (DataRefBase <T>)CurrentItem;
            int             currentPosition      = IsEmpty ? -1 : CurrentPosition;
            bool            isCurrentBeforeFirst = m_IsCurrentBeforeFirst;
            bool            isCurrentAfterLast   = m_IsCurrentAfterLast;

            OnCurrentChanging();
            ClearCache();
            if (isCurrentBeforeFirst || IsEmpty)
            {
                SetCurrent(null, 0);
            }
            else if (isCurrentAfterLast)
            {
                SetCurrent(null, Count);
            }
            else
            {
                int index = IndexOf(currentItem);
                if (index < 0)
                {
                    SetCurrent(null, -1);
                }
                else
                {
                    SetCurrent(currentItem, index);
                }
            }
            m_NeedsRefresh = false;
            OnCollectionReset();
            OnCurrentChanged();
            if (isCurrentBeforeFirst != m_IsCurrentBeforeFirst)
            {
                OnPropertyChanged(m_IsCurrentBeforeFirstChanged);
            }
            if (isCurrentAfterLast != m_IsCurrentAfterLast)
            {
                OnPropertyChanged(m_IsCurrentAfterLastChanged);
            }
            if (currentPosition != CurrentPosition)
            {
                OnPropertyChanged(m_CurrentPositionChanged);
            }
            if (currentItem != CurrentItem)
            {
                OnPropertyChanged(m_CurrentItemChanged);
            }
        }
 public VirtualListCollectionView(VirtualList <T> list)
     : base(list.NumCacheBlocks, list.NumItemsPerCacheBlock)
 {
     Load = list.Load;
     m_SourceCollection = list;
     // initialize current item and markers
     if (list.Count == 0)
     {
         m_IsCurrentAfterLast = m_IsCurrentBeforeFirst = true;
     }
     else
     {
         m_CurrentPosition = 0;
         m_CurrentItem     = list[0];
     }
     m_NeedsRefresh = true;
 }
 private void SetCurrent(DataRefBase <T> newItem, int newPosition, int count)
 {
     if (newItem != null)
     {
         m_IsCurrentBeforeFirst = m_IsCurrentAfterLast = false;
     }
     else if (count == 0)
     {
         m_IsCurrentBeforeFirst = m_IsCurrentAfterLast = true;
         newPosition            = -1;
     }
     else
     {
         m_IsCurrentBeforeFirst = newPosition < 0;
         m_IsCurrentAfterLast   = newPosition >= count;
     }
     m_CurrentItem     = newItem;
     m_CurrentPosition = newPosition;
 }
        private void SetCurrent(DataRefBase <T> newItem, int newPosition)
        {
            int count = newItem != null ? 0 : Count;

            SetCurrent(newItem, newPosition, count);
        }
Exemple #5
0
 public bool Remove(DataRefBase <T> item)
 {
     throw new NotImplementedException();
 }
Exemple #6
0
 public bool Contains(DataRefBase <T> item)
 {
     return(item != null && ((CachedDataRef)item).List == this);
 }
Exemple #7
0
 public void Add(DataRefBase <T> item)
 {
     throw new NotImplementedException();
 }
Exemple #8
0
 public void Insert(int index, DataRefBase <T> item)
 {
     throw new NotImplementedException();
 }
Exemple #9
0
        public int IndexOf(DataRefBase <T> item)
        {
            CachedDataRef dataRef = item as CachedDataRef;

            return(dataRef != null && dataRef.List == this ? dataRef.Index : -1);
        }