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)); } } }
private void ShowNewForm(object sender, EventArgs e) { var childForm = new FormTestRest { MdiParent = this, Text = "窗口 " + childFormNumber++ }; childForm.Show(); }
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(); } }