473,748 Members | 2,328 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

any facilities in csharp that can help me implmenting undo/redo in my
application?
thx
Nov 15 '05 #1
3 11634
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
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******** ******@TK2MSFTN GP11.phx.gbl...
any facilities in csharp that can help me implmenting undo/redo in my
application?
thx

Nov 15 '05 #3
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******** ******@TK2MSFTN GP12.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******** ******@TK2MSFTN GP11.phx.gbl...
any facilities in csharp that can help me implmenting undo/redo in my
application?
thx


Nov 15 '05 #4

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

Similar topics

2
10653
by: Robert Creager | last post by:
I'm receiving the following error during startup: Aug 10 14:11:27 thunder postgres: LOG: failed to create socket: Address family not supported by protocol Aug 10 14:11:27 thunder postgres: LOG: database system was shut down at 2003-08-10 14:11:11 MDT Aug 10 14:11:27 thunder postgres: LOG: checkpoint record is at 4/E28389B4
0
1475
by: Alex L | last post by:
Hi To All! I just started to develop my applications in .Net. And I have a problem with undo option in the Visual Studio .Net: I can't to undo any text (code) (Ctrl+Z doesn't work!) And if I try to do it , I receive the next message box "unknown undo/redo error". What I should do? Any Ideas will be appreciated! Thank u in advance
5
1528
by: Robin Tucker | last post by:
Ok now my intellisense has gone t's-up again - I also cannot use undo/redo in the editor. I deleted the NCB file in case that was corrupt but no poonanas, its still fubar (how many explitives can I use without actually swearing!?). My next "solution" is to reinstall Visual Studio 2003 ;) I'm not asking for a solution here, just sharing my frustration with the group (unless you have one that is....).
0
1436
by: Durai | last post by:
Hello All, I built postgresql on HPUX IPF(11.22) platform. It works fine. But I have warning message "could not resolve "localhost": host nor service provided, or not known" when I start the postmaster. I have given entries in pg_hba.conf file to access also. $ ./postmaster -D /var/opt/iexpress/postgresql & 2410 $ LOG: could not resolve "localhost": host nor service provided, or not known LOG: database system was shut down...
0
1257
by: monkey3333sg | last post by:
I am programming some flow chart program using VB6... which is similar to Visual Logic software... I would like to add in "Undo" and "Redo" part...anyone can help? Thank you.
0
5428
by: s.amann | last post by:
Hello, I get the following error when I try to insert data into a table. "SQL1477N Table "<table-name>" cannot be accessed. " The table was created with NOT LOGGED INITIALLY The import is done by a program written in C and using embedded SQL. It starts with ALTER TABLE myTable ACTIVATE NOT LOGGED INITIALLY WITH EMPTY TABLE. Then I prepare the statement and the inserts are done within a loop
17
5833
by: malathib | last post by:
Hi, I have used a rich text editor in my application. I got it from one of the site.all are JS files. My problem is, i want to call a javascript function from the iframe. Can anybody help me in this regard
5
13378
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL http://mghospedagem.com/images/controlpanel.jpg instead of http://mghospedagem.comhttp://mghospedagem.com/images/controlpanel.jpg As u see, there's the website URL before the image URL.
0
8983
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9528
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9359
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...
0
8235
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...
1
6792
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6072
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
4592
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
4863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3298
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

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.