Class Transaction

GoDiagram®
v10.0.12
by Northwoods Software®

A Transaction holds a list of ChangedEvents collected during a transaction, as the value of the read-only Changes property.

Inheritance
Transaction
Namespace: Northwoods.Go.Models
Assembly: Northwoods.GoDiagram.WinForms.dll
Syntax
public class Transaction
Remarks

Start a transaction by calling StartTransaction(string) (or StartTransaction(string) or StartTransaction(string), which call that method). Be sure to finish a transaction with a matching call to CommitTransaction(string) (or CommitTransaction(string) or CommitTransaction(string)), or a call to RollbackTransaction() (or the same named methods on Model<TNodeData, TNodeKey, TSharedData> or Diagram).

If you are performing multiple or repeated changes to a model or diagram, surround all of the code with calls to start and commit the transaction -- do not perform repeated calls to start-commit-start-commit. Typically each change caused by the user, such as a button click or a change of focus or a mouse drag, should perform one transaction in which all changes are made. All of the predefined commands and tools perform transactions.

Undoing or redoing a transaction is done by calling Undo() or Redo(). Those methods call the Undo() or Redo() methods here.

The UndoManager holds a list of Transactions in its History.

Constructors

Transaction()

Construct an object holding an empty list of ChangedEvents and no Name.

Declaration
public Transaction()

Properties

Changes

This read-only property returns the list of ChangedEvents.

Declaration
public IList<ChangedEvent> Changes { get; }
Property Value
Type Description
IList<ChangedEvent>
Remarks

The changes are stored in order of occurrence.

You should not modify this list.

IsComplete

Gets or sets whether we can add more ChangedEvents to this list of changes.

Declaration
public bool IsComplete { get; set; }
Property Value
Type Description
bool
Remarks

This is initially false. It is set to true by CommitTransaction(string) and RollbackTransaction().

Name

Gets or sets the transaction name for this collection of changes.

Declaration
public string Name { get; set; }
Property Value
Type Description
string
Remarks

This is set by a top-level call to CommitTransaction(string).

Methods

CanRedo()

This predicate returns true if you can call Redo(), namely when IsComplete is true.

Declaration
public bool CanRedo()
Returns
Type Description
bool

true if ready for Redo() to be called.

CanUndo()

This predicate returns true if you can call Undo(), namely when IsComplete is true.

Declaration
public bool CanUndo()
Returns
Type Description
bool

true if ready for Undo() to be called.

Clear()

Clear all of the saved changes.

Declaration
public void Clear()

Optimize()

Remove all but the first and last Property ChangedEvents for each property for each object.

Declaration
public void Optimize()
Remarks

This is called by DraggingTool's StopTransaction() in order to reduce the memory saved by each dragging transaction.

Redo()

Re-perform these changes after an Undo().

Declaration
public void Redo()
Remarks

This is normally called only by the UndoManager. CanRedo() must be true for this method to have any effect.

Undo()

Undo all of the changes, in reverse order.

Declaration
public void Undo()
Remarks

This is normally called only by the UndoManager. CanUndo() must be true for this method to have any effect.