예제 #1
0
        private void handleSourceCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            HandledEventSender = sender;
            HandledEventArgs   = e;

            if (!Utils.handledAfterActivationInCountOrIndexerPropertyChangedHandlers(e.Action, _countPropertyChangedEventRaised, _indexerPropertyChangedEventRaised))
            {
                _indexerPropertyChangedEventRaised = false;
                switch (e.Action)
                {
                case NotifyCollectionChangedAction.Add:
                    //if (e.NewItems.Count > 1) throw new ObservableComputationsException("Adding of multiple items is not supported");
                    int newStartingIndex = e.NewStartingIndex;
                    InsertItem(newStartingIndex, _sourceAsList[newStartingIndex]);
                    break;

                case NotifyCollectionChangedAction.Remove:
                    // (e.OldItems.Count > 1) throw new ObservableComputationsException("Removing of multiple items is not supported");
                    RemoveItem(e.OldStartingIndex);
                    break;

                case NotifyCollectionChangedAction.Replace:
                    //if (e.NewItems.Count > 1) throw new ObservableComputationsException("Replacing of multiple items is not supported");
                    int newStartingIndex2 = e.NewStartingIndex;
                    SetItem(newStartingIndex2, _sourceAsList[newStartingIndex2]);
                    break;

                case NotifyCollectionChangedAction.Move:
                    int oldStartingIndex1 = e.OldStartingIndex;
                    int newStartingIndex1 = e.NewStartingIndex;
                    if (oldStartingIndex1 == newStartingIndex1)
                    {
                        return;
                    }

                    MoveItem(oldStartingIndex1, newStartingIndex1);
                    break;

                case NotifyCollectionChangedAction.Reset:
                    reset();
                    break;
                }
            }
        }