Multiple undo/redo implementation in C#?

T

Teis Draiby

I'm looking for some information (books, articles, tutorials) on how to
implement a multiple undo/redo framework. I'm a beginner in this so I prefer
information specifically targeting C# with code samples. Is seems that the
'Command Pattern' is the way to achieve it (?).
If you know any good resources I would be very happy to know!

Thank you very much!,
Teis
 
M

Miha Markic [MVP C#]

Hi Teis,

It depends on your program as there is no universal solution.
Here are some hints:
The idea is, that you store all actions you want to undo (in some sort of
collection).
When user wants to undo, you go through stored actions in reverse order and
undo actions one by one.
Of course, you'll have to provide undo/redo functionality.

I don't know of any resources, sorry.
 
P

Paul E Collins

Teis Draiby said:
I'm looking for some information (books, articles,
tutorials) on how to implement a multiple undo/redo
framework. [...]

I use two classes, an UndoFrame (representing an action that was performed)
and an UndoStack. The UndoStack has two regular C# Stack objects: an undo
stack and a redo stack.

When the user carries out an action, push its new UndoFrame onto the undo
stack and clear the redo stack. When the user undoes an action, pop the undo
stack and push the action being undone onto the redo stack.

If this isn't enough information, mail me and I'll send you some code.

P.
 
T

Teis Draiby

Hi Paul
If this isn't enough information, mail me and I'll send you some code.
Oh, yes please! I've found some articles out there but not much sample
code - so I'd like to
see some examples.
You can mail me at: teisATdraibyDOTcom

regards, Teis

----- Original Message -----
From: "Paul E Collins" <[email protected]>
Newsgroups: microsoft.public.dotnet.languages.csharp
Sent: Saturday, April 24, 2004 5:14 PM
Subject: Re: Multiple undo/redo implementation in C#?

Teis Draiby said:
I'm looking for some information (books, articles,
tutorials) on how to implement a multiple undo/redo
framework. [...]

I use two classes, an UndoFrame (representing an action that was performed)
and an UndoStack. The UndoStack has two regular C# Stack objects: an undo
stack and a redo stack.

When the user carries out an action, push its new UndoFrame onto the undo
stack and clear the redo stack. When the user undoes an action, pop the undo
stack and push the action being undone onto the redo stack.

If this isn't enough information, mail me and I'll send you some code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top