Exemple #1
0
        private void DoUpdate(ISortedChangeSet <TObject, TKey> updates, IObservableCollection <TObject> list)
        {
            foreach (var update in updates)
            {
                switch (update.Reason)
                {
                case ChangeReason.Add:
                    list.Insert(update.CurrentIndex, update.Current);
                    break;

                case ChangeReason.Remove:
                    list.RemoveAt(update.CurrentIndex);
                    break;

                case ChangeReason.Moved:
                    list.Move(update.PreviousIndex, update.CurrentIndex);
                    break;

                case ChangeReason.Update:
                    if (update.PreviousIndex != update.CurrentIndex)
                    {
                        list.RemoveAt(update.PreviousIndex);
                        list.Insert(update.CurrentIndex, update.Current);
                    }
                    else
                    {
                        list.Replace(update.Previous.Value, update.Current);
                    }

                    break;
                }
            }
        }
Exemple #2
0
        private void DoUpdate(ISortedChangeSet <TObject, TKey> updates, IObservableCollection <TObject> list)
        {
            updates.ForEach(update =>
            {
                switch (update.Reason)
                {
                case ChangeReason.Add:
                    list.Insert(update.CurrentIndex, update.Current);
                    break;

                case ChangeReason.Remove:
                    list.RemoveAt(update.CurrentIndex);
                    break;

                case ChangeReason.Moved:
                    list.Move(update.PreviousIndex, update.CurrentIndex);
                    break;

                case ChangeReason.Update:
                    {
                        list.RemoveAt(update.PreviousIndex);
                        list.Insert(update.CurrentIndex, update.Current);
                    }
                    break;
                }
            });
        }
        public bool ReceiveWeakEvent(Type managerType, object sender, EventArgs e)
        {
            if (managerType == typeof(CollectionChangedEventManager))
            {
                NotifyCollectionChangedEventArgs arg = e as NotifyCollectionChangedEventArgs;
                if (arg != null)
                {
                    switch (arg.Action)
                    {
                    case NotifyCollectionChangedAction.Add:
                        if (arg.NewItems != null)
                        {
                            for (int itemIndex = 0; itemIndex < arg.NewItems.Count; itemIndex++)
                            {
                                _syncCollection.Insert(arg.NewStartingIndex +
                                                       itemIndex, _create(arg.NewItems[itemIndex] as T));
                            }
                            break;
                        }
                        break;

                    case NotifyCollectionChangedAction.Move:
                        _syncCollection.RemoveAt(arg.OldStartingIndex);
                        _syncCollection.Insert(arg.NewStartingIndex, _create(arg.NewItems[0] as T));
                        break;

                    case NotifyCollectionChangedAction.Remove:
                        if (arg.OldItems != null && _syncCollection.Count > 0)
                        {
                            for (int itemIndex = 0; itemIndex < arg.OldItems.Count; itemIndex++)
                            {
                                _syncCollection.RemoveAt(arg.OldStartingIndex);
                            }
                        }
                        break;

                    case NotifyCollectionChangedAction.Replace:
                        if (arg.NewItems == null)
                        {
                            for (int itemIndex = 0; itemIndex < arg.NewItems.Count; itemIndex++)
                            {
                                _syncCollection[arg.NewStartingIndex + itemIndex] = _create(arg.NewItems[itemIndex] as T);
                            }
                        }
                        break;

                    case NotifyCollectionChangedAction.Reset:
                        _syncCollection.Clear();
                        break;

                    default:
                        break;
                    }
                }
                return(true);
            }
            return(false);
        }
        private IUndoableAction Pop(IObservableCollection <IUndoableAction> stack)
        {
            if (stack.Count == 0)
            {
                return(null);
            }

            var r = stack[stack.Count - 1];

            stack.RemoveAt(stack.Count - 1);
            return(r);
        }
Exemple #5
0
        public bool Remove(object a)
        {
            if (a is FloodRule rule)
            {
                return(rules.Remove(rule));
            }
            else if (a is string || a is ConcatenatedString)
            {
                int idx = rules.FindIndex((s) => s.Name == a.ToString());
                if (idx > -1)
                {
                    rules.RemoveAt(idx);
                    return(true);
                }
            }

            return(false);
        }
Exemple #6
0
 public void Redo() => target.RemoveAt(index);
 /// <summary>
 /// Remove o item na posição informada.
 /// </summary>
 /// <param name="index"></param>
 public void RemoveAt(int index)
 {
     _source.RemoveAt(_indexes[index]);
 }