zoukankan      html  css  js  c++  java
  • WPF DockLayoutManager布局后的布局重置

    初始化布局

                Logging.InfoBiz("初始化布局信息");
                dockLayoutManager = new DockLayoutManager();
                RestoreLayoutOptions.SetRemoveOldPanels(dockLayoutManager, false);
                RestoreLayoutOptions.SetAddNewPanels(dockLayoutManager, true);
                dockLayoutManager.DockingStyle = DockingStyle.VS2010;
                mainLayout.Children.Add(dockLayoutManager);

    保存默认布局

                // 保存默认布局
                dockLayoutManager.SaveLayoutToStream(defaultDockLayoutStream);
                defaultDockLayoutStream.Flush();

    恢复布局

                var layoutPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "layout.xml");
                if (File.Exists(layoutPath))
                {
                    dockLayoutManager.ClosedPanels.Clear();
                    dockLayoutManager.RestoreLayoutFromXml(layoutPath);
                    foreach (var panel in dockLayoutManager.ClosedPanels.ToList())
                    {
                        dockLayoutManager.DockController.Restore(panel);
                    }
                }

    1. 布局重置之前需要关闭活动区域

                var docPanel = (DocPanel)((IMainWindow)this).GetActiveDocPanel();
                if(docPanel!=null)
                {
                    dockLayoutManager.DockController.Close(docPanel);
                }

    2. 然后再恢复初始保存的布局

            protected void RestoreDefaultDockLayout()
            {
                var docPanel = (DocPanel)((IMainWindow)this).GetActiveDocPanel();
                if(docPanel!=null)
                {
                    dockLayoutManager.DockController.Close(docPanel);
                }
                
                defaultDockLayoutStream.Seek(0, SeekOrigin.Begin);
                dockLayoutManager.RestoreLayoutFromStream(defaultDockLayoutStream);
                foreach (var panel in dockLayoutManager.ClosedPanels.ToList())
                {
                    dockLayoutManager.DockController.Restore(panel);
                }
            }

    3. 将布局保存到配置文件

                var layoutPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "layout.xml");
                dockLayoutManager.SaveLayoutToXml(layoutPath);

    4. 切换布局中的活动区域

           private void OnWorkspacePanelCommandExecute(object obj)
            {
                BaseLayoutItem item = null;
                if (obj.Equals("1"))
                {
                    item = this.ermlPanel;
                }
                else if (obj.Equals("2"))
                {
                    item = this.serverPanel;
                }
                else if (obj.Equals("3"))
                {
                    item = this.diagramPanel;
                }
                else if (obj.Equals("4"))
                {
                    item = this.stdzPanel;
                }
                else if (obj.Equals("5"))
                {
                    item = this.outputPanel;
                }
                else if (obj.Equals("6"))
                {
                    item = this.reviewPanel;
                }
                else if (obj.Equals("7"))
                {
                    item = this.explrModelSearchPanel;
                }
                else if (obj.Equals("8"))
                {
                    item = this.naviPanel;
                }
    
                if (item.Visibility == Visibility.Visible)
                {
                    item.Visibility = Visibility.Collapsed;
                }
                else
                {
                    item.Visibility = Visibility.Visible;
                    dockLayoutManager.Activate(item);
                }
            }
  • 相关阅读:
    磁盘分区异常占用满了
    平滑升级nginx
    supervisor进程异常挂掉
    datetime值毫秒四舍五入
    docker+tomcat 启动时非常慢原因之JRE /dev/random阻塞
    Tomcat最大连接数问题
    Docker:设置代理proxy
    easy_install和pip安装python库修改默认的源
    zabbix监控mysql之Warning: Using a password on the command line interface can be insecure.
    Mysql忘记密码解决方法
  • 原文地址:https://www.cnblogs.com/runningRain/p/13879025.html
Copyright © 2011-2022 走看看