473,385 Members | 2,069 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,385 software developers and data experts.

Undo/Redo

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.
Nov 15 '05 #1
4 4691
Hi,

There is no support for such thing.
You'll have to do it by yourself.

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

"thanigai" <th**********@enventureonline.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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.

Nov 15 '05 #2
There's no "built-in" support, but take a look at the command pattern:

http://c2.com/cgi/wiki?CommandPattern
"thanigai" <th**********@enventureonline.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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.

Nov 15 '05 #3

"Philip Rieck" <st***@mckraken.com> wrote in message
news:eg**************@TK2MSFTNGP09.phx.gbl...
There's no "built-in" support, but take a look at the command pattern:

http://c2.com/cgi/wiki?CommandPattern
"thanigai" <th**********@enventureonline.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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.



You can also read about the Command Pattern in the "GOF" book (i.e. "Design
Patterns by Gamma, Helm, Johnson, Vlissides")

--
Sam Gentile [C#/.NET MVP]
..NET Blog http://samgentile.com/blog/
Nov 15 '05 #4
I would agree. The "command pattern," as it's called, is probably what you
will have to use. However, the wiki mentions that you may have an explosion
of Command classes as a problem. Depending on your performance constraints,
you might be better off writing just a few "generic" command classes that
use reflection. So you might try something like:

#region Assumed
public interface ICommand {
void Do();
void Undo();
}
#endregion

#region Example
[Serializable]
public class PropertySetCommand : ICommand {
private object _Instance;
private System.Reflection.PropertyInfo _TargetProperty;
private object _OldValue;
private object _NewValue;
private object[] _Indeces;

public PropertySetCommand(object instance,
System.Reflection.PropertyInfo targetProperty, object oldValue, object
newValue, object[] indeces) {
_Instance = instance;
_TargetProperty = targetProperty;
_OldValue = oldValue;
_NewValue = newValue;
_Indeces = new object[indeces.Length];
Array.Copy(indeces, _Indeces, indeces.Length);
}

#region ICommand Members
public void Do() {
_TargetProperty.SetValue(_Instance, _NewValue, _Indeces);
}

public void Undo() {
_TargetProperty.SetValue(_Instance, _OldValue, _Indeces);
}
#endregion
}
#endregion

I'm not suggesting this as a perfect, or even good, solution. I'm just
saying that if you suddenly found yourself drowning in an endless sea of
slightly different command classes, using reflection might be an option. It
will, almost certainly, come at the expense of either performance or your
budget, though.

--
Max Guernsey, III
http://www.harbingersoftware.com

"Philip Rieck" <st***@mckraken.com> wrote in message
news:eg**************@TK2MSFTNGP09.phx.gbl...
There's no "built-in" support, but take a look at the command pattern:

http://c2.com/cgi/wiki?CommandPattern
"thanigai" <th**********@enventureonline.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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.


Nov 15 '05 #5

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

Similar topics

1
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...
0
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:...
11
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...
3
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...
1
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...
2
by: Christian H | last post by:
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...
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: Sakharam Phapale | last post by:
Hi All, I am developing my own text editor using RichTextBox control. I don't want to use RichTextBox Undo and Redo functions. Instead of that I want to develop my own algorithm for Undo & Redo,...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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
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,...
0
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...

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.