private void ShowNewForm(object sender, EventArgs e) { dlgNieuw dlg = new dlgNieuw(); if (dlg.ShowDialog() == DialogResult.OK) { string p = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "DrawIt"); int i = 1; switch (dlg.Resultaat) { case dlgNieuw.enNieuwDocType.Pictogram: string[] t = MdiChildren.Where(T => T.GetType() == typeof(frmIcon)).Select(T => T.Text).ToArray(); while (File.Exists(Path.Combine(p, "Pictogram " + i)) | t.Contains("Pictogram " + i)) { i++; } frmIcon icon_form = new frmIcon(); icon_form.MdiParent = this; //MDI; icon_form.Text = "Icoon " + i; icon_form.Show(); break; case dlgNieuw.enNieuwDocType.Cursor: break; case dlgNieuw.enNieuwDocType.Afbeelding: string[] u = MdiChildren.Where(T => T.GetType() == typeof(frmImageEditor)).Select(T => T.Text).ToArray(); while (File.Exists(Path.Combine(p, "Afbeelding " + i)) | u.Contains("Afbeelding " + i)) { i++; } frmImageEditor img_form = new frmImageEditor(); img_form.MdiParent = this; //MDI; img_form.Text = "Afbeelding " + i; img_form.Show(); break; default: string[] v = MdiChildren.Where(T => T.GetType() == typeof(frmTekenen)).Select(T => T.Text).ToArray(); while (File.Exists(Path.Combine(p, "Tekening " + i + ".tek")) | v.Contains("Tekening " + i)) { i++; } frmTekenen tek_form = new frmTekenen(); tek_form.MdiParent = this; tek_form.Text = "Tekening " + i; tek_form.Show(); tek_form.EndMove += Tek_form_EndMove; tek_form.EndPan += Tek_form_EndPan; break; } } }
public void OpenFile(string bestand) { if (bestand.Replace(" ", "") == "") { return; } if (!File.Exists(bestand)) { return; } IDocument[] vensters = MdiChildren.Select(T => (IDocument)T).Where(T => T.CurrentFileName == bestand).ToArray(); if (vensters.Length == 0) { switch (Path.GetExtension(bestand)) { case ".tek": frmTekenen childForm = new frmTekenen(); childForm.MdiParent = this; childForm.Show(); childForm.EndMove += Tek_form_EndMove; childForm.EndPan += Tek_form_EndPan; childForm.OpenFile(bestand); break; case ".ico": frmIcon childForm2 = new frmIcon(); childForm2.MdiParent = this; childForm2.Show(); childForm2.Open(bestand); break; } } else { vensters[0].Activate(); } }