473,804 Members | 3,308 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Undo/Redo Pattern

Hello,

I've tried to find information about how to implement an Undo/Redo pattern.
This article describes such a pattern:
http://www.codeproject.com/csharp/PcObjectUndo.asp , but is a little bit to
narrow, since it only can handle 1 object, and since it only works on
properties.

What if you , in an application, have more than 1 object , and you want to
use undo/redo on them?
What if you'd like it to work on methods as well as properties?

If there is a better pattern than the one in the link, that will let me do
this, please let me know.
Christian H.
Nov 16 '05 #1
2 13270
Christian H wrote:
I've tried to find information about how to implement an
Undo/Redo pattern.
I implement undo/redo using two stacks. I used a "do" and an
"undo" stack.

When a change is made it goes onto the "do" stack. To undo the
change it is just poped of the "do" stack and pushed onto the
"undo" stack.

What gets pushed and poped are primitive operations encapsulated
in an object. These objects hold all the information required to
do or undo themselves.

I would assume this is quite a common apprach.
What if you , in an application, have more than 1 object,
and you want to use undo/redo on them?
I have about 15 types of objects to handle all the different
situations but they all share a common base class so they
can share a common stack.
If there is a better pattern than the one in the link,
that will let me do this, please let me know.


When I first developed my undo/redo method it took quite
some time to get it working correctly. I started by just
trying to implement a few simple case and then slowly
adding new cases. After a few false starts it all fell
into place quite nicely :)

Jussi Jumppanen
Author of: Zeus for Windows (New version 3.93 out now)
"The C/C++, Cobol, Java, HTML, Python, PHP, Perl programmer's editor"
Home Page: http://www.zeusedit.com
Nov 16 '05 #2
Hi,

Take a look at the Command pattern.
http://www.dofactory.com/Patterns/PatternCommand.aspx

in the above link they do a calculator with an undo/redo capability.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Christian H" <n@n.no> wrote in message
news:2G******** **********@news 4.e.nsc.no...
Hello,

I've tried to find information about how to implement an Undo/Redo
pattern.
This article describes such a pattern:
http://www.codeproject.com/csharp/PcObjectUndo.asp , but is a little bit
to narrow, since it only can handle 1 object, and since it only works on
properties.

What if you , in an application, have more than 1 object , and you want to
use undo/redo on them?
What if you'd like it to work on methods as well as properties?

If there is a better pattern than the one in the link, that will let me
do this, please let me know.
Christian H.

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3023
by: Jay | last post by:
I need to implement an undo and redo for an entire row in a listview containing approximately 10 columns. I'm not sure of the best way to implement this. The only thing that I've thought of is a stack implementation. I need to be able to undo a delete, an insert (add), a movement within the list Any ideas? Thank you and any ideas would be appreciated.
0
1405
by: John Benson | last post by:
With respect to: Message: 13 Date: Thu, 1 Jan 2004 18:38:47 -0800 (PST) From: black <quiteblack@yahoo.com> Subject: undo and redo ? To: python-list@python.org Message-ID: <20040102023847.78427.qmail@web21326.mail.yahoo.com> Content-Type: text/plain; charset="us-ascii"
4
4717
by: thanigai | last post by:
How to implement undo/redo technique in C#? The undo/redo are not only for text changes, it also support previous action like creation of an object.
11
15197
by: Mad Joe | last post by:
I'm using a richTextBox for editing a source code (with Syntax Highlighting) of my own programming language... How come that myRichTextBox doesn't respond to Undo/Redo functions by using default shortcut keys, or even programaticaly (by using Button_onClick event)? if(myRichTextBox.CanUndo == true) { myRichTextBox.Undo(); }
3
7833
by: Teis Draiby | last post by:
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
1
1826
by: Alan | last post by:
Hi all, I'm programming one VBScript Editor with syntax hilighting. I use the RichTextBox control. Although the syntaxhilighting function comes true, i found the undo/redo function didn't work. I do nothing about undo list directly. Any help or sample will be very appeciated! Thanks in advance.
3
1513
by: Lars Netzel | last post by:
Hi! Is this hard and where do you start? /Lars
1
3663
by: Jameson | last post by:
Hi, I'm interested in any insights you might have about how to implement undo/redo in a multi-user environment (if it's wise to do it at all). My software is already using the Command and Observer patterns for implementing user actions and as such they are pretty simple to undo/redo in a single user situation. In a multi-user scenario, I can imagine many problems with this however (particularly with respect to database inserts, deletes...
1
4054
by: anupam roy | last post by:
Hi All, I want to perform basic Edit menu functionalities on my custom design surface. While all the Cut/Copy/Paste/Deelete/Select functionalities working fine with code below,Undo/Redo standard commands are not working for me. IMenuCommandService menusrv= HostControl.HostSurface.GetService(typeof(IMenuCommandService)) as IMenuCommandService; if (menusrv != null) { switch (editstring) ...
0
10326
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10317
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10075
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9143
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6851
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5520
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4295
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.