By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,191 Members | 2,190 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,191 IT Pros & Developers. It's quick & easy.

How do we normally implement "Undo"/"Redo" function?

P: n/a
any facilities in csharp that can help me implmenting undo/redo in my
application?
thx
Nov 15 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
There isn't any pre-built class in the framework. From an abstraction
standpoint, take a look at the Command design pattern. Here is an
article discussing one implementation (see the command section):

Illustrated GOF Design Patterns in C# Part IV: Behavioral I
http://www.codeproject.com/csharp/csdespat_4.asp

--
Scott
http://www.OdeToCode.com

On Fri, 9 Jan 2004 10:31:23 +0800, "babylon" <am***@hotmail.com>
wrote:
any facilities in csharp that can help me implmenting undo/redo in my
application?
thx


Nov 15 '05 #2

P: n/a
If you break down the problem, it's really easy to implement undo/redo based
on your application's common functionality.

Basically, there are two stacks Undo stack and Redo stack. The Redo stack
gets pushed with items that are popped from the Undo Stack. Whenever an
item is pushed to the Undo stack, the redo stack is cleared.

Depending on the operations, you can define classes that encapsulate the
action and the data associated with the action. For example, if you are
moving a control from one location to another, you'll store the control's
old and new location and the action is "move".

Hope this helps you get started on your own Undo/Redo stack.
-vJ

"babylon" <am***@hotmail.com> wrote in message
news:e9**************@TK2MSFTNGP11.phx.gbl...
any facilities in csharp that can help me implmenting undo/redo in my
application?
thx

Nov 15 '05 #3

P: n/a
thanks everyone
so basically i can create something called "command", e.g. cut, copy, paste
and store the commands that the user has performed

and each command itself knows how to undo

so, e.g. if the user cut a section of text
a CutCommand (inherit from Command) is created and the text is stored in the
CutCommand
and the CutCommand itself is store on a Undo stack

when user choose undo, we retrive the command from the top of the stack and
ask it to redo
in this case, as the CutCommand stored the text that was cut, so i can paste
back the text

thank!
"Vijaye Raji" <no************@hotmail.com> wrote in message
news:Oj**************@TK2MSFTNGP12.phx.gbl...
If you break down the problem, it's really easy to implement undo/redo based on your application's common functionality.

Basically, there are two stacks Undo stack and Redo stack. The Redo stack
gets pushed with items that are popped from the Undo Stack. Whenever an
item is pushed to the Undo stack, the redo stack is cleared.

Depending on the operations, you can define classes that encapsulate the
action and the data associated with the action. For example, if you are
moving a control from one location to another, you'll store the control's
old and new location and the action is "move".

Hope this helps you get started on your own Undo/Redo stack.
-vJ

"babylon" <am***@hotmail.com> wrote in message
news:e9**************@TK2MSFTNGP11.phx.gbl...
any facilities in csharp that can help me implmenting undo/redo in my
application?
thx


Nov 15 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.