I recently created an architecture that did this.
The undo-redo architecture was interface based with the specific
implementations for the various objects conforming to the contract of the
interface but imlementing differently depending upon object type. The
interface included a do, undo and redo method. This separated the do from
the redo and enables you to create a null do with an operative redo.
For objects such as textboxes, a change notification occurred via the
standard events which created and stacked the command object as per normal,
the system called the null do command because the assumption was that
databinding would already have effected the change and subsequent undo /
redo actions were implemented using specialised code that had knowledge of
the bound control type being undone.
I can't post code as it was for a commercial client but the process was
pretty standard Command Pattern.
--
Bob Powell [MVP]
Visual C#, System.Drawing
Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
"Samuel R. Neff" <bl****@newsgroup.nospam> wrote in message
news:8p********************************@4ax.com...
We're working on implementing a Command Pattern design with our
application in order to help facilitate undo/redo. This is fine four
user actions we control which basically means menu actions.
However, it's not quite so clear for bound controls. We don't
directly interact with the change--the user makes a change in a
control, such as a grid, and the dataset stores the update. We
haven't interjected any code which we can funnel through a Command
object.
One work-around we're thinking is to react to the change events and
put a Command object in the stack wich some flag to indicate that the
action has already been accomplished (and thus the Execute method only
should be called for the Redo operation and not for the originating
operation).
How have others addressed this situation? Are there any examples
available of using Command pattern in a bound-control environment?
Thanks,
Sam
B-Line is now hiring one Washington D.C. area VB.NET
developer for WinForms + WebServices position.
Seaking mid to senior level developer. For
information or to apply e-mail resume to
sam_blinex_com.