473,411 Members | 2,230 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

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 11609
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**************@TK2MSFTNGP11.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**************@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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
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: ...
0
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...
5
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...
0
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...
0
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
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...
17
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...
5
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...
0
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...
0
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...

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.