DockPanel Suite DockContent all appearing at top left of DockPanel

878 Views Asked by At

enter image description hereSometimes when my program starts it fails to place the DockPanel DockContent in the correct places assigned in the configuration file.

The config file looks like this:

<?xml version="1.0" encoding="utf-16"?>
<!--DockPanel configuration file. Author: Weifen Luo, all rights reserved.-->
<!--!!! AUTOMATICALLY GENERATED FILE. DO NOT MODIFY !!!-->
<DockPanel FormatVersion="1.0" DockLeftPortion="0.25" DockRightPortion="0.25" DockTopPortion="0.25" DockBottomPortion="0.25" ActiveDocumentPane="-1" ActivePane="-1">
  <Contents Count="5">
    <Content ID="0" PersistString="Imogen3.Forms.Dockable.FrmLogging" AutoHidePortion="0.25" IsHidden="False" IsFloat="False" />
    <Content ID="1" PersistString="Imogen3.Forms.Dockable.FrmTimers" AutoHidePortion="0.25" IsHidden="False" IsFloat="False" />
    <Content ID="2" PersistString="Imogen3.Forms.Dockable.FrmImageAssessmentControl" AutoHidePortion="0.25" IsHidden="False" IsFloat="False" />
    <Content ID="3" PersistString="Imogen3.Forms.Dockable.FrmRestrictedBrowser" AutoHidePortion="0.25" IsHidden="False" IsFloat="False" />
    <Content ID="4" PersistString="Imogen3.Forms.Dockable.FrmGroupCandidates" AutoHidePortion="0.25" IsHidden="False" IsFloat="False" />
  </Contents>
  <Panes Count="3">
    <Pane ID="0" DockState="DockBottom" ActiveContent="0">
      <Contents Count="1">
        <Content ID="0" RefID="0" />
      </Contents>
    </Pane>
    <Pane ID="1" DockState="DockBottom" ActiveContent="1">
      <Contents Count="1">
        <Content ID="0" RefID="1" />
      </Contents>
    </Pane>
    <Pane ID="2" DockState="Document" ActiveContent="2">
      <Contents Count="3">
        <Content ID="0" RefID="2" />
        <Content ID="1" RefID="3" />
        <Content ID="2" RefID="4" />
      </Contents>
    </Pane>
  </Panes>
  <DockWindows>
    <DockWindow ID="0" DockState="Document" ZOrderIndex="1">
      <NestedPanes Count="1">
        <Pane ID="0" RefID="2" PrevPane="-1" Alignment="Right" Proportion="0.5" />
      </NestedPanes>
    </DockWindow>
    <DockWindow ID="1" DockState="DockLeft" ZOrderIndex="2">
      <NestedPanes Count="0" />
    </DockWindow>
    <DockWindow ID="2" DockState="DockRight" ZOrderIndex="3">
      <NestedPanes Count="0" />
    </DockWindow>
    <DockWindow ID="3" DockState="DockTop" ZOrderIndex="4">
      <NestedPanes Count="0" />
    </DockWindow>
    <DockWindow ID="4" DockState="DockBottom" ZOrderIndex="0">
      <NestedPanes Count="2">
        <Pane ID="0" RefID="0" PrevPane="-1" Alignment="Right" Proportion="0.5" />
        <Pane ID="1" RefID="1" PrevPane="0" Alignment="Right" Proportion="0.215625" />
      </NestedPanes>
    </DockWindow>
  </DockWindows>
  <FloatWindows Count="0" />
</DockPanel>

within my code I have these three DockPanel methods which Gets the ContentFromPersistString, Saves and Loads the Configuration file.

private readonly DeserializeDockContent _deserializeDockContent; 

private IDockContent GetContentFromPersistString(string persistString)
        {
            MainLog("GetContentFromPersistString " + persistString);
            if (persistString == typeof(FrmLogging).ToString())
            {
                logToolStripMenuItem.Checked = true;
                _frmLogging.Dock = DockStyle.Fill;
                return _frmLogging;
            }
            else if (persistString == typeof(FrmTimers).ToString())
            {
                timersToolStripMenuItem.Checked = true;
                _frmTimers.Dock = DockStyle.Fill;
                return _frmTimers;
            }
            else if (persistString == typeof(FrmImageAssessmentControl).ToString())
            {
                imageAssessmentToolStripMenuItem.Checked = true;
                _frmIac.Dock = DockStyle.Fill;
                return _frmIac;
            }
            else if (persistString == typeof(FrmRestrictedBrowser).ToString())
            {
                restrictedBrowserToolStripMenuItem.Checked = true;
                _frmRb.Dock = DockStyle.Fill;
                return _frmRb;
            }
            else if (persistString == typeof(FrmGroupCandidates).ToString())
            {
                groupCandidatesToolStripMenuItem.Checked = true;
                _frmGc.Dock = DockStyle.Fill;
                return _frmGc;
            }
            else
            {
                MainLog("Received Window PersistString: " + persistString);
                return null;
            }
        }

        private void LoadDockingWindowsConfiguration()
        {
            MainLog("LoadDockingWindowsConfiguration()");
            // ReSharper disable once AssignNullToNotNullAttribute
            string configFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "DockPanel.config");

            try
            {
                if (File.Exists(configFile))
                    dockPanel1.LoadFromXml(configFile, _deserializeDockContent);
            }
            catch (Exception ex)
            {
                MainLog("Error: LoadDockingWindowsConfiguration " + ex.Message);
            }

        }

        private void SaveDockingWindowConfiguration()
        {
            MainLog("SaveDockingWindowConfiguration()");
            // ReSharper disable once AssignNullToNotNullAttribute
            string configFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "DockPanel.config");
            if (_saveLayout)
                dockPanel1.SaveAsXml(configFile);
            else if (File.Exists(configFile))
                File.Delete(configFile);
        }

in the MainForm initializer I have this:

 _deserializeDockContent = GetContentFromPersistString;  

We Load the Docking configuration in the Form Load Event like this:

 LoadDockingWindowsConfiguration();  

This is a real nuisance, any help in getting the DockContent placed in the correct locations would be appreciated.

1

There are 1 best solutions below

0
On

Concluded as by design,

https://github.com/dockpanelsuite/dockpanelsuite/issues/338

Users of DPS are suggested to properly handle exceptions on their own.