Example #1
0
 private static void PrintTransaction(IReadOnlyTransaction transaction, StringBuilder stringBuilder, int increment, int offset = 0)
 {
     foreach (var operation in transaction.Operations)
     {
         PrintOperation(operation, stringBuilder, increment, offset + increment);
     }
 }
Example #2
0
 public string GetName(IReadOnlyTransaction transaction)
 {
     if (transaction == null)
     {
         throw new ArgumentNullException(nameof(transaction));
     }
     return(GetName(transaction.Id) ?? transaction.ToString());
 }
Example #3
0
        /// <summary>
        /// Purges the stack from the given index (included) to the top of the stack.
        /// </summary>
        /// <param name="index">The index from which to purge the stack.</param>
        private void PurgeFromIndex(int index)
        {
            if (index < 0 || index > transactions.Count)
            {
                throw new ArgumentOutOfRangeException(nameof(index));
            }

            if (transactions.Count - index > 0)
            {
                var discardedTransactions = new IReadOnlyTransaction[transactions.Count - index];
                for (var i = index; i < transactions.Count; ++i)
                {
                    transactions[i].Interface.Freeze();
                    discardedTransactions[i - index] = transactions[i];
                }
                transactions.RemoveRange(index, transactions.Count - index);
                TransactionDiscarded?.Invoke(this, new TransactionsDiscardedEventArgs(discardedTransactions, DiscardReason.StackPurged));
            }
        }
Example #4
0
 public string GetName(IReadOnlyTransaction transaction)
 {
     if (transaction == null) throw new ArgumentNullException(nameof(transaction));
     return GetName(transaction.Id) ?? transaction.ToString();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TransactionsDiscardedEventArgs"/> class.
 /// </summary>
 /// <param name="transaction">The transaction that have been discarded.</param>
 /// <param name="reason">The reason why the transaction have been discarded.</param>
 public TransactionsDiscardedEventArgs(IReadOnlyTransaction transaction, DiscardReason reason)
     : this(new[] { transaction }, reason)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TransactionViewModel"/> class.
 /// </summary>
 /// <param name="serviceProvider">The service provider to use for this view model.</param>
 /// <param name="transaction">The transaction represented by this view model.</param>
 public TransactionViewModel(IViewModelServiceProvider serviceProvider, IReadOnlyTransaction transaction)
     : base(serviceProvider)
 {
     this.transaction = transaction;
     Name             = ServiceProvider.Get <IUndoRedoService>().GetName(transaction);
 }
Example #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TransactionEventArgs"/> class.
 /// </summary>
 /// <param name="transaction">The transaction associated to this event.</param>
 public TransactionEventArgs(IReadOnlyTransaction transaction)
 {
     Transaction = transaction;
 }
        /// <summary>
        /// Purges the stack from the given index (included) to the top of the stack.
        /// </summary>
        /// <param name="index">The index from which to purge the stack.</param>
        private void PurgeFromIndex(int index)
        {
            if (index < 0 || index > transactions.Count) throw new ArgumentOutOfRangeException(nameof(index));

            if (transactions.Count - index > 0)
            {
                var discardedTransactions = new IReadOnlyTransaction[transactions.Count - index];
                for (var i = index; i < transactions.Count; ++i)
                {
                    transactions[i].Interface.Freeze();
                    discardedTransactions[i - index] = transactions[i];
                }
                transactions.RemoveRange(index, transactions.Count - index);
                TransactionDiscarded?.Invoke(this, new TransactionsDiscardedEventArgs(discardedTransactions, DiscardReason.StackPurged));
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="TransactionsDiscardedEventArgs"/> class.
 /// </summary>
 /// <param name="transaction">The transaction that have been discarded.</param>
 /// <param name="reason">The reason why the transaction have been discarded.</param>
 public TransactionsDiscardedEventArgs(IReadOnlyTransaction transaction, DiscardReason reason)
     : this(new[] { transaction }, reason)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TransactionsDiscardedEventArgs"/> class.
 /// </summary>
 /// <param name="transactions">The transactions that have been discarded.</param>
 /// <param name="reason">The reason why the transactions have been discarded.</param>
 public TransactionsDiscardedEventArgs(IReadOnlyTransaction[] transactions, DiscardReason reason)
 {
     Transactions = transactions;
     Reason = reason;
 }