简体   繁体   English

DockPanel Suite DockContent全部出现在DockPanel的左上方

[英]DockPanel Suite DockContent all appearing at top left of DockPanel

在此处输入图片说明 Sometimes when my program starts it fails to place the DockPanel DockContent in the correct places assigned in the configuration file. 有时,当我的程序启动时,无法将DockPanel DockContent放置在配置文件中分配的正确位置。

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. 在我的代码中,我具有这三个DockPanel方法,这些方法获取ContentFromPersistString,保存并加载配置文件。

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: 在MainForm初始化程序中,我有这个:

 _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. 这确实是一件令人讨厌的事,将DockContent放置在正确位置的任何帮助将不胜感激。

Concluded as by design, 根据设计结论,

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

Users of DPS are suggested to properly handle exceptions on their own. 建议DPS的用户自行正确处理异常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM