Beispiel #1
0
        public void Dispose()
        {
            Debug.Assert(!this.IsDisposed);

            Debug.Assert((m_asyncCommitInfoList != null) && (m_asyncCommitInfoList.Count == 0), "Some async commit are not completed while disposing VirtualPage");

            if (m_asyncQueryInfo != null)
            {
                // We must dispose the AsyncQueryInfo to be sure
                // it does not root this VirtualPage instance
                m_asyncQueryInfo.Dispose();
                m_asyncQueryInfo = null;
            }

            this.Clear();
            m_parentVirtualList = null;

            this.IsDisposed = true;
        }
        internal bool IsItemDirty(object item)
        {
            LinkedListNode <VirtualPage> pageNode = m_pageNodes.First;

            while (pageNode != null)
            {
                VirtualList virtualList = pageNode.Value.ParentVirtualList;

                Debug.Assert(m_managedLists.Contains(virtualList));

                if (virtualList.IsItemDirty(item))
                {
                    Debug.Assert(!(item is EmptyDataItem), "An EmptyDataItem should not have been flagged as dirty.");
                    return(true);
                }

                pageNode = pageNode.Next;
            }

            return(false);
        }
        internal bool IsAsyncCommitQueuedForItem(object item)
        {
            LinkedListNode <VirtualPage> pageNode = m_pageNodes.First;

            while (pageNode != null)
            {
                VirtualList virtualList = pageNode.Value.ParentVirtualList;

                Debug.Assert(m_managedLists.Contains(virtualList));

                if (virtualList.IsAsyncCommitQueuedForItem(item))
                {
                    Debug.Assert(!(item is EmptyDataItem), "A commit operation should not have been queued for an EmptyDataItem.");
                    return(true);
                }

                pageNode = pageNode.Next;
            }

            return(false);
        }
        protected override int OnQueryItemCountCore(VirtualList virtualList)
        {
            if (!this.IsConnected)
            {
                return(0);
            }

            DataGridVirtualizingCollectionView collectionView = this.CollectionView as DataGridVirtualizingCollectionView;

            // The VirtualPageManager was Disposed
            if (collectionView == null)
            {
                return(0);
            }

            DataGridVirtualizingCollectionViewGroup collectionViewGroup = this.GetLinkedCollectionViewGroup(virtualList) as DataGridVirtualizingCollectionViewGroup;

            Debug.Assert((collectionViewGroup != null) && (collectionView != null));

            return(collectionView.OnQueryItemCount(collectionViewGroup));
        }
        internal VirtualizedItemValueCollection GetCachedValuesForItem(object item)
        {
            LinkedListNode <VirtualPage> pageNode = m_pageNodes.First;

            while (pageNode != null)
            {
                VirtualList virtualList = pageNode.Value.ParentVirtualList;

                Debug.Assert(m_managedLists.Contains(virtualList));

                int localIndex = virtualList.IndexOf(item);

                if (localIndex != -1)
                {
                    return(virtualList.GetCachedValuesForItemAtIndex(localIndex));
                }

                pageNode = pageNode.Next;
            }

            return(null);
        }
        internal virtual void OnVirtualListRestarted(VirtualList virtualList)
        {
            Debug.Assert(m_managedLists.Contains(virtualList));

            Debug.Assert(this.RestartingManager, "Until CollectionViewGroups can be virtualized, we should not be restarting a leaf list on its own.");

            if (this.RestartingManager)
            {
                m_restartingListsCount--;
            }

            // Make sure that no page nodes belonging to this virtual
            // list are left in the linked list. Remove all remaining ones
            // since after the manager is restarted, its content is
            // completely cleared
            LinkedListNode <VirtualPage> pageNode = m_pageNodes.Last;

            while (pageNode != null)
            {
                LinkedListNode <VirtualPage> previousNode = pageNode.Previous;

                if (pageNode.Value.ParentVirtualList == virtualList)
                {
                    throw new DataGridInternalException("A VirtualPage was not remove from its parent VirtualList after it is restarted");
                }

                pageNode = previousNode;
            }

            this.IncrementVersion();

            // If the manager is restarting, no page left and no more list restarting
            if (this.RestartingManager &&
                (m_pageNodes.Count == 0) &&
                (m_restartingListsCount == 0))
            {
                this.EndRestart();
            }
        }
        public int GetGlobalIndexOf(object item)
        {
            ReadOnlyCollection <VirtualList> virtualItemLists = this.ManagedLists;
            int virtualItemListsCount = virtualItemLists.Count;

            for (int i = 0; i < virtualItemListsCount; i++)
            {
                VirtualList localList  = virtualItemLists[i];
                int         localIndex = localList.IndexOf(item);

                if (localIndex >= 0)
                {
                    Debug.Assert(m_virtualListVSCollectionViewGroupDictionary.ContainsKey(localList));

                    DataGridVirtualizingCollectionViewGroupBase dgvcvg = m_virtualListVSCollectionViewGroupDictionary[localList];

                    return(localIndex + dgvcvg.StartGlobalIndex);
                }
            }

            return(-1);
        }
        internal void ClearCachedValuesForItem(object item)
        {
            LinkedListNode <VirtualPage> pageNode = m_pageNodes.First;

            while (pageNode != null)
            {
                VirtualList virtualList = pageNode.Value.ParentVirtualList;

                Debug.Assert(m_managedLists.Contains(virtualList));

                int localIndex = virtualList.IndexOf(item);

                if (localIndex != -1)
                {
                    virtualList.ClearCachedValuesForItemAtIndex(localIndex);
                    return;
                }

                pageNode = pageNode.Next;
            }

            throw new InvalidOperationException("An attempt was made to leave the edit process on an unknown item.");
        }
 internal virtual void OnVirtualListPageRestarted(VirtualList virtualList, VirtualPage page)
 {
     Debug.Assert(m_managedLists.Contains(virtualList));
     Debug.Assert(m_pageNodes.Contains(page));
     this.RemovePage(page);
 }
        internal virtual void OnVirtualListRestarting(VirtualList virtualList)
        {
            Debug.Assert(m_managedLists.Contains(virtualList));

            Debug.Assert(this.RestartingManager, "Until CollectionViewGroups can be virtualized, we should not be restarting a leaf list on its own.");
        }
 protected abstract int OnQueryItemCountCore(VirtualList virtualList);
 protected internal virtual int OnQueryItemCount(VirtualList virtualList)
 {
     return(this.OnQueryItemCountCore(virtualList));
 }
        public DataGridVirtualizingCollectionViewGroupBase GetLinkedCollectionViewGroup(VirtualList virtualItemList)
        {
            DataGridVirtualizingCollectionViewGroupBase collectionViewGroup;

            m_virtualListVSCollectionViewGroupDictionary.TryGetValue(virtualItemList, out collectionViewGroup);

            return(collectionViewGroup);
        }
 internal override void OnVirtualListRestarted(VirtualList virtualList)
 {
     this.UnlinkVirtualListAndCollectionViewGroup(virtualList);
     base.OnVirtualListRestarted(virtualList);
 }