private void openToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog of = new OpenFileDialog(); of.Filter = "SIL files (*.SIL)|*.SIL|All files (*.*)|*.*"; if (of.ShowDialog() == DialogResult.OK) { try { SIL_Program prog = SIL_IO.Load(of.FileName); frmEditor editor = new frmEditor(); //create new editor window editor.MdiParent = this; //set it as a child to Main Form editor.ProgramName = prog.Name; editor.ProgramText = prog.Text; 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("SIL - {0}", activeEditor_.programName_); EditorWindowsUpdate(); } catch (Exception ex) { MessageBox.Show("Failed to read SIL file!", "SIL Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public bool start(string[] arrayOfStringsFromCommandLine) { //Console.WriteLine(arrayOfStringsFromCommandLine[1]); if (arrayOfStringsFromCommandLine.GetLength(0) == 0) { return(false); } try { if (!File.Exists(arrayOfStringsFromCommandLine[0])) { Console.WriteLine("File not found"); return(true); } SIL_Program program = SIL_IO.Load(arrayOfStringsFromCommandLine[0]); Console.WriteLine("Loaded Program: " + arrayOfStringsFromCommandLine[0]); // program.Name += "\n\r" + program.Text; // program.Text = program.Name; // SymbolTable.Initialize(); program.Parse(); program.Execute(); } catch (FileNotFoundException ex) { // Write error. Console.WriteLine("File not Found"); return(true); } catch (Exception e) { string[] err = e.Message.Split('%'); for (int i = 0; i < err.Length - 1; ++i) { Console.WriteLine(err[i]); } Console.WriteLine("LineNumber:" + err[err.Length - 1]); } return(true); }