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); } } } }
private void saveToolStripMenuItem_Click(object sender, EventArgs e) { if (editors_.Count == 0) { MessageBox.Show("No files open!", "OOPie Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (activeEditor_ == null) { MessageBox.Show("No active editor found!", "OOPie Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string Text = activeEditor_.ProgramText; SaveFileDialog sf = new SaveFileDialog(); sf.Filter = "C# cs files (*.cs)|*.cs|All files (*.*)|*.*"; sf.AddExtension = true; sf.FileName = activeEditor_.ProgramName; if (sf.ShowDialog() == DialogResult.OK) { OOPieIO.Save(sf.FileName, Text); MessageBox.Show("File saved", "OOPies", MessageBoxButtons.OK, MessageBoxIcon.Information); } }