private void createFileToolStripMenuItem_Click(object sender, EventArgs e) { TextForm textForm = new TextForm(); textForm.MdiParent = this; textForm.Show(); }
private void toolStripMenuItem2_Click(object sender, EventArgs e) { using (OpenFileDialog openFileDialog = new OpenFileDialog()) { openFileDialog.Filter = "Text files|*.txt"; if (openFileDialog.ShowDialog() == DialogResult.OK) { TextForm textForm = this.MdiChildren.OfType <TextForm>().FirstOrDefault(f => f.Path == openFileDialog.FileName); if (textForm == null) { textForm = new TextForm(); textForm.MdiParent = this; textForm.Content = File.ReadAllText(openFileDialog.FileName); textForm.Text = Path.GetFileName(openFileDialog.FileName); textForm.Path = openFileDialog.FileName; textForm.Show(); } else { textForm.Content = File.ReadAllText(openFileDialog.FileName); textForm.Activate(); } } } }