public void OpenDocument(FileInfo fi) { string title = fi == null ? "New Document" : fi.Name; try { bool valid; XmlDocument doc = XEditNetCtrl.LoadDocument(fi.FullName, true, out valid); if (doc == null) { return; } Form f = GetMdiForm(doc, valid); f.Text = title; f.Closing += new CancelEventHandler(ChildClosing); f.MdiParent = this; f.WindowState = FormWindowState.Maximized; f.Show(); f.Tag = fi; } catch (XmlException e) { // TODO: M: lots of things can cause this error, eg. trying to run xpath anywhere MessageBox.Show(this, "XML error reading document\n" + e.Message, "Open File", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception e) { MessageBox.Show(this, e.Message); } }
private void OpenFile(object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.AddExtension = true; dlg.CheckFileExists = true; dlg.CheckPathExists = true; dlg.DefaultExt = "xml"; dlg.Filter = DEFAULT_FILE_FILTER; if (dlg.ShowDialog(this) == DialogResult.OK) { string fileName = dlg.FileName; FileInfo fi = new FileInfo(fileName); string title = fi == null ? "New Document" : fi.Name; try { bool valid; XmlDocument doc = XEditNetCtrl.LoadDocument(fi.FullName, true, out valid); if (doc == null) { return; } DockContent childForm = GetMdiForm(doc, valid); childForm.Text = title; //f.Closing += new CancelEventHandler(ChildClosing); childForm.MdiParent = this; childForm.DockAreas = DockAreas.Document | DockAreas.Float; childForm.ShowHint = DockState.Document; childForm.Activated += new EventHandler(childForm_Activated); childForm.Show(this.dockPanel1); childForm.Show(); childForm.Tag = fi; } catch (XmlException ex) { // TODO: M: lots of things can cause this error, eg. trying to run xpath anywhere MessageBox.Show(this, "XML error reading document\n" + ex.Message, "Open File", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show(this, ex.Message); } } }