现在的位置: 首页 > 综合 > 正文

DockPanel2 保存各个窗口的状态

2013年10月04日 ⁄ 综合 ⁄ 共 1263字 ⁄ 字号 评论关闭

这个功能太强大了,需要好好研究原代码

load中    

           Frm1 f1= new Frm1();
            Frm2 f2= new Frm2();
            Frm3 f3= new Frm3();
            Frm4 f4= new Frm4();

            m_deserializeDockContent = new DeserializeDockContent(GetContentFromPersistString);
            string configFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "DockPanel.config");

            if (File.Exists(configFile))
                dockPanel1.LoadFromXml(configFile, m_deserializeDockContent);

 

            f1.Show(dockPanel1, DockState.DockLeft);
            f2.Show(f1.Pane, DockAlignment.Bottom, 0.3);
            f3.Show(dockPanel1, DockState.Document);
            f4.Show(f3.Pane,DockAlignment.Bottom,0.3); 

 

closing中

            string configFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "DockPanel.config");
                dockPanel1.SaveAsXml(configFile);

 

        private IDockContent GetContentFromPersistString(string persistString)
        {
            if (persistString == typeof(Frm1).ToString())
                return f1;
            else if (persistString == typeof(Frm2).ToString())
                return f2;
            else if (persistString == typeof(Frm3).ToString())
                return f3;
            else if (persistString == typeof(Frm4).ToString())
                return f4;
            return null;
        }

抱歉!评论已关闭.