Created
May 4, 2012 14:09
-
-
Save jsadeli/2595009 to your computer and use it in GitHub Desktop.
Actipro-MMVM-Docking: Layout Load
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private readonly DockSiteLayoutSerializer _dockSiteLayoutSerializer; | |
private string _pendingDockSiteLayout; | |
public void Initialize() | |
{ | |
_dockSiteLayoutSerializer = new DockSiteLayoutSerializer() { SerializationBehavior = DockSiteSerializationBehavior.All }; | |
this.mainDockSite.Loaded += OnDockSiteLoaded; | |
// | |
// initialize dockable windows (documents and tools) | |
// | |
Debug.Assert(this.DocumentItems != null); | |
_mainDocumentWindowsImport = mainDocumentWindowsImport; | |
mainDocumentWindowsImport.ForEach(document => this.DocumentItems.Add(document.Value)); | |
Debug.Assert(this.ToolItems != null); | |
_mainToolWindowsImport = mainToolWindowsImport; | |
mainToolWindowsImport.ForEach(tool => this.ToolItems.Add(tool.Value)); | |
RestoreDockableWindowsLayout(); | |
} | |
public void RestoreDockableWindowsLayout() | |
{ | |
if (this.mainDockSite.IsLoaded) | |
{ | |
try | |
{ | |
_dockSiteLayoutSerializer.LoadFromString(layout, this.mainDockSite); | |
} | |
catch (Exception exc) | |
{ | |
Debug.WriteLine(exc.ToString()); | |
} | |
} | |
else | |
{ | |
_pendingDockSiteLayout = layout; | |
} | |
} | |
private void OnDockSiteLoaded(object sender, RoutedEventArgs e) | |
{ | |
DockSite dockSite = (DockSite) sender; | |
if (string.IsNullOrEmpty(_pendingDockSiteLayout)) | |
return; | |
SetDockSiteLayout(_pendingDockSiteLayout); | |
_pendingDockSiteLayout = null; | |
} |
Author
jsadeli
commented
May 4, 2012
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment