示例#1
0
        private void LoadWorkSpace(string fileName, bool closeCurrentForms = false)
        {
            var configJson = FileUtils.GetFileContent(fileName);

            if (!string.IsNullOrWhiteSpace(configJson))
            {
                try
                {
                    var configDtos = JsonConvert.DeserializeObject <List <FormDto> >(configJson);
                    if (configDtos == null)
                    {
                        return;
                    }
                    if (closeCurrentForms)
                    {
                        this.CloseAllToolStripMenuItem_Click(null, null);
                    }

                    foreach (var config in configDtos)
                    {
                        var form = new FormTestRest();
                        form.ApplyFormData(config);
                        form.MdiParent = this;
                        form.Show();
                    }
                    LayoutMdi(MdiLayout.TileVertical);
                }
                catch (Exception exception)
                {
                    MessageBox.Show(string.Format("加载配置文件出错:{0}", exception.Message));
                }
            }
        }
示例#2
0
        private void ShowNewForm(object sender, EventArgs e)
        {
            var childForm = new FormTestRest
            {
                MdiParent = this,
                Text      = "窗口 " + childFormNumber++
            };

            childForm.Show();
        }
示例#3
0
 private void MainMDI_Load(object sender, EventArgs e)
 {
     LoadWorkSpace(configFile);
     if (this.MdiChildren.Length == 0)
     {
         var childForm = new FormTestRest
         {
             MdiParent = this,
             Text      = "窗口 " + childFormNumber++
         };
         childForm.Show();
     }
 }