/// <summary> /// Creates a pending undo transaction, which may be committed after the /// undoable work is completed successfully, or rolledback in case of failure. /// The <see cref="IUndoTransaction"/> implements <see cref="IDisposable"/> /// and is intended for use inside a using clause, which rollback the transaction /// automatically, if it is not commited within the scope. /// </summary> /// <param name="description">Description of the action to be performed</param> /// <param name="undoState">An undo state snapshot from the UI thread, in case the transation is begun on another thread</param> /// <returns>Transaction instance</returns> public IUndoTransaction BeginTransaction(string description, IUndoState undoState = null) { if (InUndoRedo) { throw new InvalidOperationException(Resources.UndoManager_BeginTransaction_Undo_transaction_may_not_be_started_in_undo_redo); } // Inner transactions are ignored, since only the initial record is // desired in the undo stack. if (_pendingRecord != null) { return(new NoOpTransaction()); } _pendingRecord = new UndoRecord(description, undoState ?? _client.GetUndoState()); return(new UndoTransaction(this)); }
public UndoRecord(string description, IUndoState undoState) { Description = description; UndoState = undoState; }
/// <summary> /// Creates a pending undo transaction, which may be committed after the /// undoable work is completed successfully, or rolledback in case of failure. /// The <see cref="IUndoTransaction"/> implements <see cref="IDisposable"/> /// and is intended for use inside a using clause, which rollback the transaction /// automatically, if it is not commited within the scope. /// </summary> /// <param name="description">Description of the action to be performed</param> /// <param name="undoState">An undo state snapshot from the UI thread, in case the transation is begun on another thread</param> /// <returns>Transaction instance</returns> public IUndoTransaction BeginTransaction(string description, IUndoState undoState = null) { if (InUndoRedo) throw new InvalidOperationException(Resources.UndoManager_BeginTransaction_Undo_transaction_may_not_be_started_in_undo_redo); // Inner transactions are ignored, since only the initial record is // desired in the undo stack. if (_pendingRecord != null) return new NoOpTransaction(); _pendingRecord = new UndoRecord(description, undoState ?? _client.GetUndoState()); return new UndoTransaction(this); }
public UndoRecord(IUndoState undoState, string description = null) { UndoState = undoState; Description = description; }