private void HandleItemReset( GeneratorNode node ) { //these 4 variables will hold the content for the Removal and the re-addition of the items. int countGeneratedRemoved; GeneratorPosition itemGenPos; List<DependencyObject> removedContainers = new List<DependencyObject>(); //by definition, items from a node are contiguous... itemGenPos = this.FindFirstRealizedItemsForNode( node ); int removeIndex = ( itemGenPos.Offset == 0 ) ? m_genPosToIndex[ itemGenPos.Index ] : -1; countGeneratedRemoved = this.RemoveGeneratedItems( node, removedContainers ); // ensure that the mapping of the details to that node are removed! ItemsGeneratorNode itemsNode = node as ItemsGeneratorNode; if( ( itemsNode != null ) && ( itemsNode.Details != null ) ) { int detailCount = 0; foreach( List<DetailGeneratorNode> detailList in itemsNode.Details.Values ) { foreach( DetailGeneratorNode detailNode in detailList ) { detailCount += detailNode.ItemCount; } } #if LOG Log.WriteLine( this, "details.Clear - IN" + itemsNode.GetHashCode().ToString() ); #endif itemsNode.Details.Clear(); itemsNode.Details = null; node.AdjustItemCount( -detailCount ); } //send the removal notification to the panel... this.IncrementCurrentGenerationCount(); if( countGeneratedRemoved > 0 ) { this.SendRemoveEvent( itemGenPos, removeIndex, 0, countGeneratedRemoved, removedContainers ); } }
private void HandleItemAddition( GeneratorNode node, NotifyCollectionChangedEventArgs e ) { GeneratorNodeHelper nodeHelper = new GeneratorNodeHelper( node, 0, 0 ); //index not important for now. node.AdjustItemCount( e.NewItems.Count ); ItemsGeneratorNode itemsNode = node as ItemsGeneratorNode; if( itemsNode != null ) { itemsNode.AdjustLeafCount( e.NewItems.Count ); this.OffsetDetails( itemsNode, e.NewStartingIndex, e.NewItems.Count ); } //if the node is totally expanded if( node.IsComputedExpanded ) { nodeHelper.ReverseCalculateIndex(); //invalidate the indexes this.IncrementCurrentGenerationCount(); int startIndex = nodeHelper.Index + e.NewStartingIndex; GeneratorPosition addGenPos = this.GeneratorPositionFromIndex( startIndex ); //and send notification message this.SendAddEvent( addGenPos, startIndex, e.NewItems.Count ); } }