Serializing MDI Winforms for persistency
- by Serge
Hello, basically my project is an MDI Winform application where a user can customize the interface by adding various controls and changing the layout. I would like to be able to save the state of the application for each user.
I have done quite a bit of searching and found these:
http://stackoverflow.com/questions/2076259/how-to-auto-save-and-auto-load-all-properties-in-winforms-c
http://stackoverflow.com/questions/1669522/c-save-winform-or-controls-to-file
Basically from what I understand, the best approach is to serialize the data to XML, however winform controls are not serializable, so I would have use surrogate classes:
http://www.codeproject.com/KB/dotnet/Surrogate_Serialization.aspx
Now, do I need to write a surrogate class for each of my controls? I would need to write some sort of a recursive algorithm to save all my controls, what is the best approach to do accomplish that? How would I then restore all the windows, should I use the memento design pattern for that? If I want to implement multiple users later, should I use Nhibernate to store all the object data in a database? I am still trying to wrap my head around the problem and if anyone has any experience or advice I would greatly appreciate it, thanks.