WindowStateManager Class

WindowStateManager is a simple .NET Windows Forms class written in C# that handles persisting window size, location, and state between sessions of an application. It's meant for use with Windows Forms applications. It was inspired by the post "The fractal nature of UI design problems" at flow | state (this class gets to point 7, as far as I know), and was implemented based on Joel Matthias' PersistWindowState class on CodeProject.net.

To use WindowStateManager, simply create an instance of WindowStateManager and set its Parent property to the form you want to save. Then you have a choice: you can either load and save the WindowStateManager to an XML file by calling its Load and Save methods, or you can include it in another class that's already being serialized back and forth from XML, like the settings file for your app (that's what I do). WindowStateManager does the rest! It saves the position of the form, the size of the form, and the state it was in (Minimized, Maximized, or Normal). Furthermore, it stores a separate set of sizes and positions for each resolution, so that the window doesn't get screwed up when the user changes resolutions (for example, when docking and undocking a laptop).

Like PopupNotify, WindowStateManager was created for XBList, and therefore it's probably not as general or polished as it could be. It also hasn't had much testing with multi-monitor setups, as I don't have one. Please feel free to improve on the code and send it back to me, so that it can benefit everybody (and you get your name in the credits for the file!)

CC-GNU LGPL
This software is licensed under the CC-GNU LGPL.