/// <summary> /// User clicked new project button. /// </summary> private void NewProjectButton_Click(object sender, EventArgs e) { // Browse for new project file SaveFileDialog dlg = new SaveFileDialog(); dlg.DefaultExt = ProjectDocument.Extension; dlg.Filter = ProjectDocument.Filter; dlg.OverwritePrompt = false; dlg.Title = "Create Project File"; if (dlg.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } // Cannot overwrite an existing project file. // This is to protect user from accidentally killing all their work // by creating instead of opening. if (File.Exists(dlg.FileName)) { // Show error MessageBox.Show("Cannot overwrite existing project file.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { // Create new project file projectDocument.CreateProjectFile(dlg.FileName); } }