public async Task CancelTransaction() { await _transaction.Cancel(); TransactionEnded?.Invoke(this, new MudDragAndDropTransactionFinishedEventArgs <T>(_transaction)); _transaction = null; }
/// <inheritdoc/> public virtual void EndTransaction(string name, AggregateActionItemDelegate aggregateActionItems, bool reverseOrderOnUndo = true) { if (TransactionStack.Count == 0) { throw new InvalidOperationException(Properties.ExceptionMessages.CannotEndNoTransactionInProgress); } var currentTransaction = TransactionStack.Pop(); if (currentTransaction.Count > 0) { var result = aggregateActionItems(currentTransaction); var aggregateActionItem = result as IAggregateActionItem; if (aggregateActionItem != null) { aggregateActionItem.ReverseOrderOnUndo = reverseOrderOnUndo; } Add(result); TransactionEnded?.Invoke(this, new ActionItemsEventArgs <IActionItem>(result)); } else { TransactionDiscarded?.Invoke(this, new ActionItemsEventArgs <IActionItem>(new IActionItem[0])); } }
/// <summary> /// Cancels the drag & drop transaction. /// </summary> /// <returns>A task that represents the asynchronous operation.</returns> public async Task CancelTransaction() { await transaction.Cancel(); TransactionEnded?.Invoke(this, EventArgs.Empty); transaction = null; }
/// <summary> /// Commits the drag & drop transaction. /// </summary> /// <param name="dropZoneName">Dropzone name that is the source of the drag operation.</param> /// <returns>A task that represents the asynchronous operation.</returns> public async Task CommitTransaction(string dropZoneName) { await transaction.Commit(); await ItemDropped.InvokeAsync(new DraggableDroppedEventArgs <TItem>(transaction.Item, dropZoneName)); TransactionEnded?.Invoke(this, EventArgs.Empty); transaction = null; }
public void AbortTransaction() { Debug.Assert(!transactions.Last().IsEnded); Debug.Assert(index == transactions.Count); var trans = transactions[transactions.Count - 1]; transactions.RemoveAt(transactions.Count - 1); index--; TransactionEnded?.Invoke(trans.Scope, trans.Flags); Updated?.Invoke(); project.Validate(); }
public void EndTransaction() { Debug.Assert(!transactions.Last().IsEnded); Debug.Assert(index == transactions.Count); var trans = transactions[transactions.Count - 1]; Debug.Assert(trans.StateAfter == null); trans.End(); TransactionEnded?.Invoke(trans.Scope, trans.Flags); Updated?.Invoke(); project.Validate(); }
public void EndChange() { if (bulkChangesStarted == 0) { throw new InvalidOperationException($"Cannot call {nameof(EndChange)} without a previous call to {nameof(BeginChange)}."); } if (--bulkChangesStarted == 0) { UpdateState(); TransactionEnded?.Invoke(); } }
public async Task CommitTransaction(string dropzoneIdentifier, bool reorderIsAllowed) { await _transaction.Commit(); var index = -1; if (reorderIsAllowed == true) { index = GetTransactionIndex() + 1; if (_transaction.SourceZoneIdentifier == _transaction.CurrentZone && IsItemMovedDownwards() == true) { index -= 1; } } await ItemDropped.InvokeAsync(new MudItemDropInfo <T>(_transaction.Item, dropzoneIdentifier, index)); TransactionEnded?.Invoke(this, new MudDragAndDropTransactionFinishedEventArgs <T>(dropzoneIdentifier, true, _transaction)); _transaction = null; }
/// <inheritdoc/> public virtual void EndTransaction(string name, Func <IReadOnlyCollection <IActionItem>, IActionItem> aggregateActionItems) { if (TransactionStack.Count == 0) { throw new InvalidOperationException(Properties.ExceptionMessages.CannotEndNoTransactionInProgress); } var currentTransaction = TransactionStack.Pop(); if (currentTransaction.Count > 0) { var aggregateActionItem = aggregateActionItems(currentTransaction); Add(aggregateActionItem); TransactionEnded?.Invoke(this, new ActionItemsEventArgs <IActionItem>(aggregateActionItem)); } else { TransactionDiscarded?.Invoke(this, new ActionItemsEventArgs <IActionItem>(new IActionItem[0])); } }