Saving and Restoring the Layout

3/30/2010 8:42 PM
You can subscribe to this wiki article using an RSS feed reader.

Earlier versions of SoapBox Core automatically saved the layout when the application exited, and restored the layout when it restarted.  A real application has more complicated needs.  You probably want to save the state of the layout along with some user saved file, and restore it when they open that project, solution, or whatever.  Now you can do this.  First, make sure you have a reference to your LayoutManager service:

    [Import(SoapBox.Core.Services.Layout.LayoutManager, typeof(ILayoutManager))]
    private Lazy<ILayoutManager> layoutManager { get; set; }

Saving the Layout

Saving the layout is simple:

    string layoutBlob = layoutManager.Value.SaveLayout();

The layoutBlob string you get back is actually three Base64 encoded strings separated by dots (.) so the blob is easy to store inside of XML or other save files.

Restoring the Layout

Restoring is just as easy:


The layout manager will show all the pads you originally had open, and it will also show all the documents.  Note that this means it's going to show the document and pass in the memento string that the document was exposing as the Memento property when you called SaveLayout.  Typically this is a file name, so it should work fine, but it's up to your logic to interpret what the Memento means in your overloaded CreateDocument routine, so that it opens the right file, view, or whatever.

Home: SoapBox Core What's new: Recently changed articles