private void ShowNewForm(object sender, EventArgs e) { SetEditor childForm = new SetEditor(ref _AppSettings); childForm.MdiParent = this; childForm.Text = "Untitled"; childForm.Tag = null; childForm.Show(); AdjustMenu(); }
public void OpenFile(string filename) { string corePath = Path.GetDirectoryName(filename); bool InUse = false; foreach (SetEditor childForm in MdiChildren) { if (filename == (string)childForm.ConfigurationFilePath) { childForm.Activate(); InUse = true; break; } } if (!InUse) { bool FileIsOk = true; SetEditor childForm = new SetEditor(ref _AppSettings); childForm.ConfigurationFilePath = filename; try { childForm.LoadFromFile(); AddMRU(filename); } catch (Exception e) { FileIsOk = false; childForm.Dispose(); MessageBox.Show(string.Format("Error loading configuration file: {0}\r\n{1}\r\nThe file may be corrupt.", filename, e.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); } if (FileIsOk) { childForm.StorageFolder = corePath; childForm.MdiParent = this; childForm.Show(); } AdjustMenu(); } if (corePath != _StorageFolder) { _AppSettings.LoadSettings(); _AppSettings.SetSetting("LastFolderLocation", corePath); _AppSettings.SaveSettings(); } _StorageFolder = corePath; }