I am creating paint like application using InkCanvas , I am willing to implement Undo and Redo functionality in my application .
Which is the best way to implement Undo / Redo for InkCanvas ??
I've implemented undo / redo for a WPF application and ended up publishing my undo / redo code to http://muf.codeplex.com/. You can also get it via NuGet. Just look for "MUF" or "Monitored Undo Framework". It includes support for Silverlight 4.0, as well as .NET 3.5, 4.0, and WP7.
In my WPF app, we also had an InkCanvas that supported Undo / Redo. In my case, the strokes for the InkCanvas were saved to a database with the rest of the data. I hooked the various events on InkCanvas to detect when the strokes had changed. Then used these events to update the entities.
The entities tracked the changes to the strokes and integrated into the Undo / Redo library. When the user clicked Undo, the library would alter the entities back to their original state. Then I'd push those strokes back into the InkCanvas and trigger a layout update.
Comments and questions are welcome on the codeplex site ( http://muf.codeplex.com/ ). You'll also find complete documentation and sample apps there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With