Ejemplo n.º 1
0
        private void Unbind(Cell cell, bool recycle)
        {
            if (cell == null)
            {
                throw new ArgumentNullException("cell");
            }

            if (!VirtualizingCellCollection.IsFreeCell(cell))
            {
                m_bindedCells.Remove(cell.FieldName);
            }
            else
            {
                Debug.Fail("Should always have a field name");
            }

            if (recycle)
            {
                // Put the cell into the appropriate recycle bin.
                var recyclingGroup = this.GetRecyclingGroup(this.GetColumn(cell));
                var recycleBin     = this.GetRecycleBinOrNew(recyclingGroup);

                // A released cell shouldn't be in the recycle bin already.
                Debug.Assert(!recycleBin.Contains(cell));
                recycleBin.Add(cell);
            }
            else
            {
                m_cells.Remove(cell);
            }
        }
Ejemplo n.º 2
0
            private void OnRequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
            {
                if (e.Handled)
                {
                    return;
                }

                var targetCell = ( Cell )sender;

                Debug.Assert(targetCell != null);
                Debug.Assert(m_collection.Contains(targetCell));

                if ((targetCell != e.TargetObject) && !targetCell.IsAncestorOf(e.TargetObject))
                {
                    return;
                }

                // Do not process the bring into view for a templated cell.
                if (VirtualizingCellCollection.IsTemplatedCell(targetCell))
                {
                    return;
                }

                var targetRow = targetCell.ParentRow;

                Debug.Assert((targetRow == null) || (targetRow == m_parentRow));

                var targetHost = (targetRow != null) ? targetRow.CellsHostPanel as IVirtualizingCellsHost : null;

                e.Handled = (targetHost != null) &&
                            (targetHost.BringIntoView(targetCell, e));
            }
        private void ReleaseCore(Cell cell)
        {
            Debug.Assert(!VirtualizingCellCollection.IsFreeCell(cell), "Should always have a field name");

            m_bindedCells.Remove(cell.FieldName);

            switch (this.VirtualizationMode)
            {
            case ColumnVirtualizationMode.None:
            {
                //Not virtualizing
                this.InternalRemoveCore(cell);
                break;
            }

            case ColumnVirtualizationMode.Recycling:
            {
                // If recycling, put the cell into the appropriate recycle bin.
                var recyclingGroup = this.GetRecyclingGroup(this.GetColumn(cell));
                var recycleBin     = this.GetRecycleBinOrNew(recyclingGroup);

                // A released cell shouldn't be in the recycle bin already.
                Debug.Assert(!recycleBin.Contains(cell));
                recycleBin.Add(cell);
                break;
            }

            case ColumnVirtualizationMode.Virtualizing:
            {
                //Virtualizing with no recycling
                m_unbindedCells.Add(cell.FieldName, cell);
                break;
            }
            }
        }
Ejemplo n.º 4
0
        protected override void StopListening(object source)
        {
            VirtualizingCellCollection virtualizingCellCollection = source as VirtualizingCellCollection;

            if (source == null)
            {
                throw new InvalidOperationException("An attempt was made to use a source other than a VirtualizingCellCollection");
            }

            virtualizingCellCollection.CollectionChanged -= this.OnVirtualizingCellCollectionChanged;
        }
            internal VirtualizingCellCollectionEnumerator(VirtualizingCellCollection collection)
            {
                if (collection == null)
                {
                    throw new ArgumentNullException("collection");
                }

                m_collection = collection;

                this.Reset();
            }
Ejemplo n.º 6
0
        internal void Release(Cell cell)
        {
            // Make sure the cell is allowed to be recycled.
            if ((cell == null) || (!VirtualizingCellCollection.IsRecyclableCell(cell)))
            {
                return;
            }

            // Remove the target cell from the binded cells.
            this.Unbind(cell, true);

            cell.Visibility = Visibility.Collapsed;
        }
            internal void SetParent(VirtualizingCellCollection collection)
            {
                if (collection == null)
                {
                    throw new ArgumentNullException("collection");
                }

                if (m_collection != null)
                {
                    throw new InvalidOperationException();
                }

                m_collection = collection;
            }
        private void InternalRemoveCore(Cell cell, bool unbind = false)
        {
            Debug.Assert(!VirtualizingCellCollection.IsFreeCell(cell), "Should always have a field name");

            if (unbind)
            {
                m_bindedCells.Remove(cell.FieldName);
            }

            m_cells.Remove(cell);
            m_parentRow.RemoveFromVisualTree(cell);

            //This must absolutely be done once every collection has removed the cell, for the ParentColumn will be set to null, thus the FieldName will be lost.
            cell.CleanUpOnRemove();
        }
Ejemplo n.º 9
0
        private void Bind(Cell cell, bool overwrite)
        {
            if (cell == null)
            {
                throw new ArgumentNullException("cell");
            }

            if (!VirtualizingCellCollection.IsFreeCell(cell))
            {
                string fieldName = cell.FieldName;

                Cell oldCell;
                if (m_bindedCells.TryGetValue(fieldName, out oldCell))
                {
                    if (cell == oldCell)
                    {
                        return;
                    }

                    if (!overwrite)
                    {
                        this.ThrowCellBinded(fieldName);
                    }

                    this.InternalRemove(oldCell);
                }

                m_bindedCells.Add(fieldName, cell);
            }
            else
            {
                if (m_freeCells == null)
                {
                    m_freeCells = new List <Cell>(1);
                }

                m_freeCells.Add(cell);
            }

            m_cells.Add(cell);
        }
Ejemplo n.º 10
0
 internal static void RemoveListener(VirtualizingCellCollection source, IWeakEventListener listener)
 {
     VirtualizingCellCollectionChangedEventManager.CurrentManager.ProtectedRemoveListener(source, listener);
 }
Ejemplo n.º 11
0
 private static bool IsRecyclableCell(Cell cell)
 {
     return((cell != null) &&
            !VirtualizingCellCollection.IsTemplatedCell(cell));
 }