I know some approachs to add Undo/Redo features for WinForms controls, but I received an email from PostSharp about their Aspect tips showing the very basics to add Undo/Redo features, then I interested in this feature because seems very easy with minimal code source changes (and seems a robust approach because was made by PostSharp team).
Then, i would like to know whether PostSharp is capable to add undo/redo for a WinForm's control, lets say that for example I have a ListBox where I would like to add undo/redo capabilities for item removal using PostSharp, is that possible, how?.
I know much people loves PostSharp but I need to say that their documentation is very confuse and lacks of existential details, the official docs shows a undo/redo example for WPF using XAML, and thats all no information about other technologies, no mention about if it can be implemented in WinForms, so whats happens with people that do not uses WPF?, how I should do it?.
PostSharp's Undo/Redo Documentation:
http://doc.postsharp.net/undoredo?utm_source=crm&utm_medium=email&utm_content=e4&utm_campaign=ln4
Postsharp isn't necessary. Basically, you'd need to create your own "breadcrumbs" and roll back and forth as needed. I've done this in the past by caching a copy of the screen's viewmodel for the past X number of user actions, then rebinding the UI to whatever version they want to roll back/forward to. This is a lot easier if you had built/organized the app with this in mind from the beginning, but I don't see why the same couldn't be done for the state of a listbox or user control. If you introduce a backing data-store this gets much more complicated and I would suggest transactions or changing the form so that nothing gets committed to the data-store until a 'Submit/Commit' type button is clicked, along with your own "breadcrumbs" to support undo/redo just for the editing session prior to submit.