Exemplo n.º 1
0
 public void NewUVDocument()
 {
     if (AppConfig.frmUV == null || AppConfig.frmUV.IsDisposed == true)
     {
         AppConfig.frmUV = FrmUV.GetInstance();
         //AppConfig.frmUV.TabText = "UV Detector";
         AppConfig.frmUV.Show(this.Dock_Main, (AppConfig.ms_FrmUV = DockState.Document));
     }
     else
     {
         AppConfig.frmUV.Close();
     }
 }
Exemplo n.º 2
0
        private void InitDockPanel(string path)
        {
            try
            {
                //if (this.Dock_Main.ActiveContent == null)
                //{
                //    this.Dock_Main = new WeifenLuo.WinFormsUI.Docking.DockPanel();
                //    this.Dock_Main.ActiveAutoHideContent = null;
                //    this.Dock_Main.BackColor = System.Drawing.SystemColors.Control;
                //    this.Dock_Main.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
                //    this.Dock_Main.Dock = System.Windows.Forms.DockStyle.Fill;
                //    this.Dock_Main.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World);
                //    this.Dock_Main.Location = new System.Drawing.Point(0, 25);
                //    this.Dock_Main.Name = "Dock_Main";
                //    this.Dock_Main.Size = new System.Drawing.Size(1264, 857);
                //    this.Dock_Main.TabIndex = 1;
                //    this.Dock_Main.DocumentStyle = DocumentStyle.DockingMdi;
                //    this.Controls.Add(this.Dock_Main);
                //}
                //根据配置文件动态加载浮动窗体
                this.Dock_Main.LoadFromXml(path, delegate(string persistString)
                {
                    //功能窗体
                    if (persistString == typeof(FrmUV).ToString())
                    {
                        AppConfig.frmUV = FrmUV.GetInstance();
                        //AppConfig.frmUV.TabText = "UV Detector";
                        return(AppConfig.frmUV);
                    }
                    else if (persistString == typeof(FrmPump).ToString())
                    {
                        AppConfig.frmPump = FrmPump.GetInstance();
                        //AppConfig.frmPump.TabText = "Pump";
                        return(AppConfig.frmPump);
                    }
                    else if (persistString == typeof(FrmCollector).ToString())
                    {
                        AppConfig.frmCollector = FrmCollector.GetInstance();
                        //AppConfig.frmCollector.TabText = "Collector";
                        return(AppConfig.frmCollector);
                    }
                    else if (persistString == typeof(FrmPH).ToString())
                    {
                        AppConfig.frmPH = FrmPH.GetInstance();
                        //AppConfig.frmPH.TabText = "PH";
                        return(AppConfig.frmPH);
                    }
                    else if (persistString == typeof(FrmLeft).ToString())
                    {
                        AppConfig.frmLeft = FrmLeft.GetInstance();
                        AppConfig.frmLeft.Focus();
                        return(AppConfig.frmLeft);
                    }
                    else if (persistString == typeof(FrmRight).ToString())
                    {
                        AppConfig.frmRight = FrmRight.GetInstance();
                        return(AppConfig.frmRight);
                    }
                    else if (persistString == typeof(FrmBottom).ToString())
                    {
                        AppConfig.frmBottom = FrmBottom.GetInstance();
                        return(AppConfig.frmBottom);
                    }
                    //主框架之外的窗体不显示
                    return(null);
                });
            }
            catch (Exception Err)
            {
                // 配置文件不存在或配置文件有问题时按系统默认规则加载子窗体
                //FrmFunction.GetInstance().Show(this.dockPanel1);
                AppConfig.frmLeft = FrmLeft.GetInstance();
                AppConfig.frmLeft.Show(this.Dock_Main, AppConfig.ms_FrmLeft);

                AppConfig.frmRight = FrmRight.GetInstance();
                AppConfig.frmRight.Show(this.Dock_Main, AppConfig.ms_FrmRight);

                AppConfig.frmBottom = FrmBottom.GetInstance();
                AppConfig.frmBottom.Show(this.Dock_Main, AppConfig.ms_FrmBottom);
                MessageBox.Show(Err.Message);
            }
        }