Beispiel #1
0
        private void CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (stack.RollInProgress)
            {
                return;
            }

            // We create a transaction at the first change, and complete it at the next dispatcher frame with InvokeAsync
            if (currentTransaction == null)
            {
                currentTransaction = stack.CreateTransaction();
                dispatcher.InvokeAsync(CompleteTransaction);
            }

            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                PropertySelectionSuppressed = true;
                try
                {
                    // When we add a new item to selection, we clear the selection in all other collections
                    foreach (var scope in scopes.Where(x => !x.Collections.Contains(sender)))
                    {
                        foreach (var collection in scope.Collections)
                        {
                            var descriptor = TypeDescriptorFactory.Default.Find(collection.GetType()) as CollectionDescriptor;
                            descriptor?.Clear(collection);
                        }
                    }
                }
                finally
                {
                    PropertySelectionSuppressed = false;
                }
            }
        }
Beispiel #2
0
        public ITransaction CreateTransaction()
        {
            var transaction = UndoRedoInProgress ? new DummyTransaction() : stack.CreateTransaction();

            transaction.BeforeComplete += TryMergeOperations;
            return(transaction);
        }
Beispiel #3
0
        public ITransaction CreateTransaction(TransactionFlags flags = TransactionFlags.None)
        {
            if (UndoRedoInProgress)
            {
                return(new DummyTransaction());
            }

            transactionCompletion = new TaskCompletionSource <int>();
            return(stack.CreateTransaction(flags));
        }
Beispiel #4
0
 public ITransaction CreateTransaction()
 {
     if (UndoRedoInProgress)
     {
         return(new DummyTransaction());
     }
     else
     {
         transactionCompletion = new TaskCompletionSource <int>();
         return(stack.CreateTransaction());
     }
 }
Beispiel #5
0
 public ITransaction CreateTransaction()
 {
     return(UndoRedoInProgress ? new DummyTransaction() : stack.CreateTransaction());
 }