private void btnDelete_Click(object sender, System.EventArgs e) { string nameOrPath; Pgm pgm; if (isProjectBased) { pgm = new ProjectBasedPgm(currentProject, currentProject.FilePath); nameOrPath = cmbPrograms.Text; } else { pgm = new FileBasedPgm(currentProject, currentProject.FilePath); nameOrPath = txtProject.Text; } if (nameOrPath == string.Empty) { MsgBox.ShowError(SharedStrings.SELECT_PROGRAM); } else { DialogResult result = MessageBox.Show(SharedStrings.DELETE_PROGRAM, SharedStrings.CONFIRM_PROGRAM_DELETE, MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { this.pgmDialogMode = PgmDialogMode.OpenProgram; pgm.PgmDelete(nameOrPath); Clear(); txtProject.Text = currentProject.FilePath; programs = currentProject.GetPgms(); if (programs.Rows.Count > 0) { LoadPgms(); } else { this.programRow = null; } ToggleControls(); } } DialogResult = DialogResult.OK; }
/// <summary> /// Constructor /// theContent will be empty for Attach /// </summary> public PgmDialog(Epi.Windows.Analysis.Forms.AnalysisMainForm theParentForm, string name, string theContent, PgmDialogMode mode) : base(theParentForm) { // // Required for Windows Form Designer support // InitializeComponent(); this.content = theContent; this.pgmDialogMode = mode; this.EpiInterpreter = theParentForm.EpiInterpreter; Project project = this.EpiInterpreter.Context.CurrentProject; if (project != null) { this.currentProject = project; } if (mode == PgmDialogMode.SaveProgram) { cmbPrograms.DropDownStyle = ComboBoxStyle.DropDown; this.Text = "Save Program"; // form title } else if (mode == PgmDialogMode.SaveProgramAs) { cmbPrograms.DropDownStyle = ComboBoxStyle.DropDown; this.Text = "Save Program As"; // form title } else { cmbPrograms.DropDownStyle = ComboBoxStyle.DropDownList; this.Text = "Open Program"; // form title } programName = name; this.isProjectBased = true; }