コード例 #1
0
        public IUndoRedoAction Execute()
        {
            var ii = Collection as ISupportInitialize;

            if (ii != null)
            {
                ii.BeginInit();
            }
            IUndoRedoAction result = null;

            if (Args.Action == NotifyCollectionChangedAction.Add)
            {
                Collection.RemoveAt(Collection.Count - 1);
                result = new CollectionChangeUndoRedoAction(Collection, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, Args.NewItems));
            }
            if (Args.Action == NotifyCollectionChangedAction.Remove)
            {
                foreach (var i in Args.OldItems)
                {
                    Collection.Add(i);
                }
                result = new CollectionChangeUndoRedoAction(Collection, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, Args.OldItems));
            }
            if (ii != null)
            {
                ii.EndInit();
            }
            return(result);
        }
コード例 #2
0
 public IUndoRedoAction Execute()
 {
     var ii = Collection as ISupportInitialize;
     if (ii != null) ii.BeginInit();
     IUndoRedoAction result = null;
     if (Args.Action == NotifyCollectionChangedAction.Add)
     {
         Collection.RemoveAt(Collection.Count - 1);
         result = new CollectionChangeUndoRedoAction(Collection, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, Args.NewItems));
     }
     if (Args.Action == NotifyCollectionChangedAction.Remove)
     {
         foreach (var i in Args.OldItems)
             Collection.Add(i);
         result = new CollectionChangeUndoRedoAction(Collection, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, Args.OldItems));
     }
     if (ii != null) ii.EndInit();
     return result;
 }