private void RemoveItemImplementation(int index, bool isPartOfMove) { if (!isPartOfMove) { CheckReentrancy(); //System.Diagnostics.Debug.IndentLevel++; //System.Diagnostics.Debug.Print("BEGIN REMOVE (Single Item)"); } var oldItem = _items[index]; _count--; if (index < _count) { Array.Copy(_items, index + 1, _items, index, _count - index); } _items[_count] = default(T); if (isPartOfMove) { return; } _version++; RecoverFreeSpace(); NotifyPropertyChanged(propertyName: CountString); NotifyPropertyChanged(propertyName: IndexerString); NotifyCollectionChanged(CollectionChangedEventArgsBuilder.CreateSingleItemRemoveAtAction(oldItem, index)); //System.Diagnostics.Debug.Print("END REMOVE (Single Item)"); //System.Diagnostics.Debug.IndentLevel--; }
private void InsertItemImplementation(int index, T item, bool isPartOfMove) { if (!isPartOfMove) { CheckReentrancy(); //System.Diagnostics.Debug.IndentLevel++; //System.Diagnostics.Debug.Print("BEGIN INSERT (Single Item)"); } MakeRoom(1); if (index < _count) { Array.Copy(_items, index, _items, index + 1, _count - index); } _items[index] = item; _count++; if (isPartOfMove) { return; } _version++; NotifyPropertyChanged(propertyName: CountString); NotifyPropertyChanged(propertyName: IndexerString); NotifyCollectionChanged(CollectionChangedEventArgsBuilder.CreateSingleItemInsertAction(item, index)); //System.Diagnostics.Debug.Print("END INSERT (Single Item)"); //System.Diagnostics.Debug.IndentLevel--; }
protected override void OnChildPropertyChanged(object sender, PropertyChangedEventArgs e) { base.OnChildPropertyChanged(sender, e); if (NotifyResetOnChildPropertyChange && e.PropertyName != CountString && e.PropertyName != IndexerString && e.PropertyName != "Capacity") { //System.Diagnostics.Debug.Print("Child Property Change: NOTIFIFYING RESET"); NotifyCollectionChanged(CollectionChangedEventArgsBuilder.CreateResetAction()); } //if (!NotifyResetOnChildPropertyChange) //{ // System.Diagnostics.Debug.Print("Child Property Change: RESET DISABLED"); //} }
private void ReplaceItemImplementation(int index, T item) { CheckReentrancy(); //System.Diagnostics.Debug.IndentLevel++; //System.Diagnostics.Debug.Print("BEGIN REPLACE (Single Item)"); var oldItem = _items[index]; _items[index] = item; _version++; NotifyPropertyChanged(propertyName: IndexerString); NotifyCollectionChanged(CollectionChangedEventArgsBuilder.CreateSingleItemReplaceAtAction(oldItem, item, index)); //System.Diagnostics.Debug.Print("END REPLACE (Single Item)"); //System.Diagnostics.Debug.IndentLevel--; }
private void MoveItemImplementation(int fromIndex, int toIndex) { CheckReentrancy(); //System.Diagnostics.Debug.IndentLevel++; //System.Diagnostics.Debug.Print("BEGIN MOVE (Single Item)"); var itemToMove = _items[fromIndex]; RemoveItemImplementation(fromIndex, true); InsertItemImplementation(toIndex, itemToMove, true); _version++; NotifyPropertyChanged(propertyName: IndexerString); NotifyCollectionChanged( CollectionChangedEventArgsBuilder.CreateSingleItemMoveAction(itemToMove, fromIndex, toIndex)); //System.Diagnostics.Debug.Print("END MOVE (Single Item)"); //System.Diagnostics.Debug.IndentLevel--; }
private void InsertItemsImplementation(int index, IList <T> items, bool isPartOfMove) { if (items.Count == 0) { return; } if (!isPartOfMove) { CheckReentrancy(); //System.Diagnostics.Debug.IndentLevel++; //System.Diagnostics.Debug.Print("BEGIN INSERT (Multiple Items)"); } MakeRoom(items.Count); if (index < _count) { Array.Copy(_items, index, _items, index + items.Count, _count - index); } if (Equals(items, this)) { Array.Copy(_items, 0, _items, index, index); Array.Copy(_items, index + items.Count, _items, index * 2, _count - index); } else { Array.Copy(items.ToArray(), 0, _items, index, items.Count); } _count += items.Count; if (isPartOfMove) { return; } _version++; NotifyPropertyChanged(propertyName: CountString); NotifyPropertyChanged(propertyName: IndexerString); NotifyCollectionChanged(CollectionChangedEventArgsBuilder.CreateMultipleItemInsertAction(items.ToArray(), index)); //System.Diagnostics.Debug.Print("END INSERT (Multiple Items)"); //System.Diagnostics.Debug.IndentLevel--; }
private void ClearItemsImplementation() { CheckReentrancy(); //System.Diagnostics.Debug.IndentLevel++; //System.Diagnostics.Debug.Print("BEGIN CLEAR"); if (_count <= 0) { return; } Array.Clear(_items, 0, _count); _count = 0; _version++; RecoverFreeSpace(); NotifyPropertyChanged(propertyName: CountString); NotifyPropertyChanged(propertyName: IndexerString); NotifyCollectionChanged(CollectionChangedEventArgsBuilder.CreateResetAction()); //System.Diagnostics.Debug.Print("END CLEAR"); //System.Diagnostics.Debug.IndentLevel--; }
private void MoveItemsImplementation(int fromIndex, int toIndex, int count) { CheckReentrancy(); //System.Diagnostics.Debug.IndentLevel++; //System.Diagnostics.Debug.Print("BEGIN MOVE (Multiple Items)"); var itemsToMove = new T[count]; for (var i = 0; i < count; i++) { itemsToMove[i] = _items[fromIndex + i]; } RemoveItemsImplementation(fromIndex, count, true); InsertItemsImplementation(toIndex, itemsToMove, true); NotifyPropertyChanged(propertyName: IndexerString); NotifyCollectionChanged( CollectionChangedEventArgsBuilder.CreateMultipleItemMoveAction(itemsToMove, fromIndex, toIndex)); //System.Diagnostics.Debug.Print("END MOVE (Multiple Items)"); //System.Diagnostics.Debug.IndentLevel--; }
private void ReplaceItemsImplementation(int index, IList <T> items) { CheckReentrancy(); //System.Diagnostics.Debug.IndentLevel++; //System.Diagnostics.Debug.Print("BEGIN REPLACE (Multiple Items)"); var oldItems = new List <T>(); for (var i = 0; i < items.Count; i++) { oldItems.Add(_items[index + i]); _items[index + i] = items[i]; } _version++; NotifyPropertyChanged(propertyName: IndexerString); NotifyCollectionChanged( CollectionChangedEventArgsBuilder.CreateMultipleItemReplaceAtAction(oldItems, items.ToArray(), index)); //System.Diagnostics.Debug.Print("END REPLACE (Multiple Items)"); //System.Diagnostics.Debug.IndentLevel--; }
private void RemoveItemsImplementation(int index, int count, bool isPartOfMove) { var oldItems = new List <T>(); if (!isPartOfMove) { CheckReentrancy(); //System.Diagnostics.Debug.IndentLevel++; //System.Diagnostics.Debug.Print("BEGIN REMOVE (Multiple Items)"); for (var i = 0; i < count; i++) { oldItems.Add(_items[index + i]); } } _count -= count; if (index < _count) { Array.Copy(_items, index + count, _items, index, _count - index); } Array.Clear(_items, _count, count); if (isPartOfMove) { return; } _version++; RecoverFreeSpace(); NotifyPropertyChanged(propertyName: CountString); NotifyPropertyChanged(propertyName: IndexerString); NotifyCollectionChanged(CollectionChangedEventArgsBuilder.CreateMultipleItemRemoveAtAction(oldItems, index)); //System.Diagnostics.Debug.Print("END REMOVE (Multiple Items)"); //System.Diagnostics.Debug.IndentLevel--; }