private void openToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog of = new OpenFileDialog(); of.Filter = "C# cs files (*.cs)|*.cs|All files (*.*)|*.*"; of.Multiselect = true; if (of.ShowDialog() == DialogResult.OK) { foreach (string fileName in of.FileNames) { try { //string program = OOPieIO.Load(of.FileName); string program = OOPieIO.Load(fileName); frmEditor editor = new frmEditor(); //create new editor window editor.MdiParent = this; //set it as a child to Main Form //editor.ProgramName = of.FileName; editor.ProgramName = fileName; editor.ProgramText = program; editor.Show(); //display it editor.FormClosing += new FormClosingEventHandler(editor_FormClosing); //Add event handler to catch events when form is closed editor.Activated += new EventHandler(editor_Activated); editors_.Add(editor); //add it to active editors list activeEditor_ = editor; //set it as active this.Text = String.Format("OO Pie - {0}", activeEditor_.programName_); EditorWindowsUpdate(); } catch (Exception ex) { MessageBox.Show("Failed to read OOPie file!", "OOPie Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
/// <summary> /// Event when create button is clicked on New Program Wizard /// </summary> /// <param name="programName"> /// The name of new program, in future the new program settings, /// which will be a class /// </param> void frmWizard_OnCreate(string programName) { frmEditor editor = new frmEditor(); //create new editor window editor.MdiParent = this; //set it as a child to Main Form editor.ProgramName = programName; editor.Show(); //display it editor.FormClosing += new FormClosingEventHandler(editor_FormClosing); //Add event handler to catch events when form is closed editor.Activated += new EventHandler(editor_Activated); editors_.Add(editor); //add it to active editors list activeEditor_ = editor; //set it as active this.Text = String.Format("OOPie - {0}", activeEditor_.programName_); EditorWindowsUpdate(); }
void editor_Activated(object sender, EventArgs e) { activeEditor_ = (frmEditor)sender; this.Text = String.Format("OO Pie - {0}", activeEditor_.programName_); }