Hi,

I have a small graphics app and am trying to improve on the undo/redo
mecahism for the users. Currently jusy kee a track of the last 5 items added
or deleted and allow thos to be removed/re-added.

Any ideas on an undo/redo mechism or part of a class-design that will help
this process and make it more funcitional against all user actions?

Thanks,

Lini

Re: Undo/Redo mechanism by Stefan

Stefan
Fri Mar 11 08:57:18 CST 2005

Hi Lini,

I solved Undo/Redo with the Command pattern. Every user operation results in
the creation of a command object. Each command is implemented by its own
class and inherits a base class called Command (or implements an interface
ICommand). On command creation the necessary information for Do and Undo are
saved in the newly created command object.

After creation the command object is added to a command stack where it is
execute. Execution is done by calling the parameterless Do method. Undo is
done by going down the stack and calling Undo. Redo is done by going up the
stack and calling Do again.


Sincerely,
Stefan Lieser


"Lini" <Lini@discussions.microsoft.com> schrieb im Newsbeitrag
news:05813E98-A63B-469B-A7A3-D4FF48FB9C2C@microsoft.com...
> Hi,
>
> I have a small graphics app and am trying to improve on the undo/redo
> mecahism for the users. Currently jusy kee a track of the last 5 items
> added
> or deleted and allow thos to be removed/re-added.
>
> Any ideas on an undo/redo mechism or part of a class-design that will help
> this process and make it more funcitional against all user actions?
>
> Thanks,
>
> Lini



Re: Undo/Redo mechanism by Lini

Lini
Fri Mar 11 09:35:06 CST 2005

Stefan, GREAT idea!!

I will look into that right now!!

To the rest, any other great ideas for undo/redo?


Thanks!



"Stefan Lieser" wrote:

> Hi Lini,
>
> I solved Undo/Redo with the Command pattern. Every user operation results in
> the creation of a command object. Each command is implemented by its own
> class and inherits a base class called Command (or implements an interface
> ICommand). On command creation the necessary information for Do and Undo are
> saved in the newly created command object.
>
> After creation the command object is added to a command stack where it is
> execute. Execution is done by calling the parameterless Do method. Undo is
> done by going down the stack and calling Undo. Redo is done by going up the
> stack and calling Do again.
>
>
> Sincerely,
> Stefan Lieser
>
>
> "Lini" <Lini@discussions.microsoft.com> schrieb im Newsbeitrag
> news:05813E98-A63B-469B-A7A3-D4FF48FB9C2C@microsoft.com...
> > Hi,
> >
> > I have a small graphics app and am trying to improve on the undo/redo
> > mecahism for the users. Currently jusy kee a track of the last 5 items
> > added
> > or deleted and allow thos to be removed/re-added.
> >
> > Any ideas on an undo/redo mechism or part of a class-design that will help
> > this process and make it more funcitional against all user actions?
> >
> > Thanks,
> >
> > Lini
>
>
>

Re: Undo/Redo mechanism by Lini

Lini
Fri Mar 11 10:21:03 CST 2005

Stefan,

I use vb.Net

What do I import/reference or declare to ge tto the Command pattern or
Command object?
Sorry, I'm not sure I can get to this in VB.

Any more advice?

Thanks



"Stefan Lieser" wrote:

> Hi Lini,
>
> I solved Undo/Redo with the Command pattern. Every user operation results in
> the creation of a command object. Each command is implemented by its own
> class and inherits a base class called Command (or implements an interface
> ICommand). On command creation the necessary information for Do and Undo are
> saved in the newly created command object.
>
> After creation the command object is added to a command stack where it is
> execute. Execution is done by calling the parameterless Do method. Undo is
> done by going down the stack and calling Undo. Redo is done by going up the
> stack and calling Do again.
>
>
> Sincerely,
> Stefan Lieser
>
>
> "Lini" <Lini@discussions.microsoft.com> schrieb im Newsbeitrag
> news:05813E98-A63B-469B-A7A3-D4FF48FB9C2C@microsoft.com...
> > Hi,
> >
> > I have a small graphics app and am trying to improve on the undo/redo
> > mecahism for the users. Currently jusy kee a track of the last 5 items
> > added
> > or deleted and allow thos to be removed/re-added.
> >
> > Any ideas on an undo/redo mechism or part of a class-design that will help
> > this process and make it more funcitional against all user actions?
> >
> > Thanks,
> >
> > Lini
>
>
>

Re: Undo/Redo mechanism by Stefan

Stefan
Sat Mar 12 04:09:25 CST 2005

Hi Lini,

> What do I import/reference or declare to ge tto the Command pattern or
> Command object?

well.... you should google for Command pattern. It's not as easy as
importing some assemblies, you have to program the necessary classes. There
are lots of examples on the web, so you have not to reinvent the wheel of
course ;-)


Sincerely,
Stefan Lieser



Re: Undo/Redo mechanism by Tim

Tim
Sat Mar 12 07:44:55 CST 2005

This might be a good place to start.
http://www.dofactory.com/Patterns/PatternCommand.aspx

--
Tim Wilson
.Net Compact Framework MVP

"Stefan Lieser" <slieser@t-online.de> wrote in message
news:d0uf57$d4i$02$1@news.t-online.com...
> Hi Lini,
>
> > What do I import/reference or declare to ge tto the Command pattern or
> > Command object?
>
> well.... you should google for Command pattern. It's not as easy as
> importing some assemblies, you have to program the necessary classes.
There
> are lots of examples on the web, so you have not to reinvent the wheel of
> course ;-)
>
>
> Sincerely,
> Stefan Lieser
>
>



Re: Undo/Redo mechanism by Lini

Lini
Sun Mar 13 08:53:02 CST 2005

Hi Stefan,

Thanks again for pointing me in the right direction!
I use a derivative of the Factory pattern but didn't look any further...

Time to learn a WHOLE LOT more!

If you know of any VB samples, that'd be great.

Thanks again,

Lini

"Stefan Lieser" wrote:

> Hi Lini,
>
> > What do I import/reference or declare to ge tto the Command pattern or
> > Command object?
>
> well.... you should google for Command pattern. It's not as easy as
> importing some assemblies, you have to program the necessary classes. There
> are lots of examples on the web, so you have not to reinvent the wheel of
> course ;-)
>
>
> Sincerely,
> Stefan Lieser
>
>
>

Re: Undo/Redo mechanism by Lini

Lini
Sun Mar 13 08:55:01 CST 2005

Heh Tim,

Great link and this has opened my eyes a lot!
Have used a derivative of the Factory Pattern but that as far as I went...

Any samples in VB you know of?

Thanks again,

Lini

"Tim Wilson" wrote:

> This might be a good place to start.
> http://www.dofactory.com/Patterns/PatternCommand.aspx
>
> --
> Tim Wilson
> ..Net Compact Framework MVP
>
> "Stefan Lieser" <slieser@t-online.de> wrote in message
> news:d0uf57$d4i$02$1@news.t-online.com...
> > Hi Lini,
> >
> > > What do I import/reference or declare to ge tto the Command pattern or
> > > Command object?
> >
> > well.... you should google for Command pattern. It's not as easy as
> > importing some assemblies, you have to program the necessary classes.
> There
> > are lots of examples on the web, so you have not to reinvent the wheel of
> > course ;-)
> >
> >
> > Sincerely,
> > Stefan Lieser
> >
> >
>
>
>

Re: Undo/Redo mechanism by Tim

Tim
Sun Mar 13 10:18:32 CST 2005

No, sorry. The only samples that I'm currently aware of are in C#. However,
there are C# to VB.Net converters out on the Internet. Here is one
(http://csharpconverter.claritycon.com/Default.aspx). I don't know of any
converters that are perfect so I would advise you to pass a block of C# code
in at a time and then look it over to see the conversion that was made so
that maybe in the future you could translate without the help of a
converter. I find it particularly useful to have a good working knowledge of
other languages, even if I don't code in them, just so that I could
translate a sample if I needed to.

--
Tim Wilson
.Net Compact Framework MVP

"Lini" <Lini@discussions.microsoft.com> wrote in message
news:61F4C3FD-DB9A-47B5-BCEE-F1FE2A53BA40@microsoft.com...
> Heh Tim,
>
> Great link and this has opened my eyes a lot!
> Have used a derivative of the Factory Pattern but that as far as I went...
>
> Any samples in VB you know of?
>
> Thanks again,
>
> Lini
>
> "Tim Wilson" wrote:
>
> > This might be a good place to start.
> > http://www.dofactory.com/Patterns/PatternCommand.aspx
> >
> > --
> > Tim Wilson
> > ..Net Compact Framework MVP
> >
> > "Stefan Lieser" <slieser@t-online.de> wrote in message
> > news:d0uf57$d4i$02$1@news.t-online.com...
> > > Hi Lini,
> > >
> > > > What do I import/reference or declare to ge tto the Command pattern
or
> > > > Command object?
> > >
> > > well.... you should google for Command pattern. It's not as easy as
> > > importing some assemblies, you have to program the necessary classes.
> > There
> > > are lots of examples on the web, so you have not to reinvent the wheel
of
> > > course ;-)
> > >
> > >
> > > Sincerely,
> > > Stefan Lieser
> > >
> > >
> >
> >
> >



Re: Undo/Redo mechanism by Lini

Lini
Sun Mar 13 10:57:02 CST 2005

Hi Tim,

You're a big help! I can read the C# code in that link you sent...Not sure
if it is deep enough but that's not my technical critique showing, just
expected implementations of interfaces like ICommand etc which I can't seem
to get to from VB. Not sure what imports to use other than System.

Also my drawing class has so many commands, I cannot see how to store these
operations for the inevitable undo actions by the user. Phew, where to start
skinning this cat??

Gonna buy the book on Design Patterns for VB.Net or something like that...
anything that may help a bit more!

Thanks again,

Lini


"Tim Wilson" wrote:

> No, sorry. The only samples that I'm currently aware of are in C#. However,
> there are C# to VB.Net converters out on the Internet. Here is one
> (http://csharpconverter.claritycon.com/Default.aspx). I don't know of any
> converters that are perfect so I would advise you to pass a block of C# code
> in at a time and then look it over to see the conversion that was made so
> that maybe in the future you could translate without the help of a
> converter. I find it particularly useful to have a good working knowledge of
> other languages, even if I don't code in them, just so that I could
> translate a sample if I needed to.
>
> --
> Tim Wilson
> ..Net Compact Framework MVP
>
> "Lini" <Lini@discussions.microsoft.com> wrote in message
> news:61F4C3FD-DB9A-47B5-BCEE-F1FE2A53BA40@microsoft.com...
> > Heh Tim,
> >
> > Great link and this has opened my eyes a lot!
> > Have used a derivative of the Factory Pattern but that as far as I went...
> >
> > Any samples in VB you know of?
> >
> > Thanks again,
> >
> > Lini
> >
> > "Tim Wilson" wrote:
> >
> > > This might be a good place to start.
> > > http://www.dofactory.com/Patterns/PatternCommand.aspx
> > >
> > > --
> > > Tim Wilson
> > > ..Net Compact Framework MVP
> > >
> > > "Stefan Lieser" <slieser@t-online.de> wrote in message
> > > news:d0uf57$d4i$02$1@news.t-online.com...
> > > > Hi Lini,
> > > >
> > > > > What do I import/reference or declare to ge tto the Command pattern
> or
> > > > > Command object?
> > > >
> > > > well.... you should google for Command pattern. It's not as easy as
> > > > importing some assemblies, you have to program the necessary classes.
> > > There
> > > > are lots of examples on the web, so you have not to reinvent the wheel
> of
> > > > course ;-)
> > > >
> > > >
> > > > Sincerely,
> > > > Stefan Lieser
> > > >
> > > >
> > >
> > >
> > >
>
>
>

Re: Undo/Redo mechanism by Tim

Tim
Sun Mar 13 12:02:09 CST 2005

I've never actually gone through the process of creating an undo/redo action
command set in code. Sounds interesting. I just came across the Command
pattern in the past and noticed that the "real-world code demonstrates" of
the Command pattern, at the bottom of the page, has a basic undo/redo
strategy. Anything more complicated might be too complicated for the given
task. The undo/redo example is pretty much entirely written from the ground
up, meaning that there is not much framework "help" in it aside from some
stuff out of the Collections namespace.

--
Tim Wilson
.Net Compact Framework MVP

"Lini" <Lini@discussions.microsoft.com> wrote in message
news:488346BF-5F6B-43D5-80CE-ECE1D7FD7686@microsoft.com...
> Hi Tim,
>
> You're a big help! I can read the C# code in that link you sent...Not sure
> if it is deep enough but that's not my technical critique showing, just
> expected implementations of interfaces like ICommand etc which I can't
seem
> to get to from VB. Not sure what imports to use other than System.
>
> Also my drawing class has so many commands, I cannot see how to store
these
> operations for the inevitable undo actions by the user. Phew, where to
start
> skinning this cat??
>
> Gonna buy the book on Design Patterns for VB.Net or something like that...
> anything that may help a bit more!
>
> Thanks again,
>
> Lini
>
>
> "Tim Wilson" wrote:
>
> > No, sorry. The only samples that I'm currently aware of are in C#.
However,
> > there are C# to VB.Net converters out on the Internet. Here is one
> > (http://csharpconverter.claritycon.com/Default.aspx). I don't know of
any
> > converters that are perfect so I would advise you to pass a block of C#
code
> > in at a time and then look it over to see the conversion that was made
so
> > that maybe in the future you could translate without the help of a
> > converter. I find it particularly useful to have a good working
knowledge of
> > other languages, even if I don't code in them, just so that I could
> > translate a sample if I needed to.
> >
> > --
> > Tim Wilson
> > ..Net Compact Framework MVP
> >
> > "Lini" <Lini@discussions.microsoft.com> wrote in message
> > news:61F4C3FD-DB9A-47B5-BCEE-F1FE2A53BA40@microsoft.com...
> > > Heh Tim,
> > >
> > > Great link and this has opened my eyes a lot!
> > > Have used a derivative of the Factory Pattern but that as far as I
went...
> > >
> > > Any samples in VB you know of?
> > >
> > > Thanks again,
> > >
> > > Lini
> > >
> > > "Tim Wilson" wrote:
> > >
> > > > This might be a good place to start.
> > > > http://www.dofactory.com/Patterns/PatternCommand.aspx
> > > >
> > > > --
> > > > Tim Wilson
> > > > ..Net Compact Framework MVP
> > > >
> > > > "Stefan Lieser" <slieser@t-online.de> wrote in message
> > > > news:d0uf57$d4i$02$1@news.t-online.com...
> > > > > Hi Lini,
> > > > >
> > > > > > What do I import/reference or declare to ge tto the Command
pattern
> > or
> > > > > > Command object?
> > > > >
> > > > > well.... you should google for Command pattern. It's not as easy
as
> > > > > importing some assemblies, you have to program the necessary
classes.
> > > > There
> > > > > are lots of examples on the web, so you have not to reinvent the
wheel
> > of
> > > > > course ;-)
> > > > >
> > > > >
> > > > > Sincerely,
> > > > > Stefan Lieser
> > > > >
> > > > >
> > > >
> > > >
> > > >
> >
> >
> >