Table of Contents

Class Transaction

Namespace
Northwoods.Go.Models
Assembly
Northwoods.GoDiagram.WinForms.dll

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

public class Transaction
Inheritance
Transaction
Inherited Members

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.

public Transaction()

Properties

Changes

This read-only property returns the list of ChangedEvents.

public IList<ChangedEvent> Changes { get; }

Property Value

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.

public bool IsComplete { get; set; }

Property Value

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.

public string Name { get; set; }

Property Value

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.

public bool CanRedo()

Returns

bool

true if ready for Redo() to be called.

CanUndo()

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

public bool CanUndo()

Returns

bool

true if ready for Undo() to be called.

Clear()

Clear all of the saved changes.

public void Clear()

Optimize()

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

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().

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.

public void Undo()

Remarks

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