private void OnBuild(object sender, EventArgs e) { if (FilePath != null) { this.SaveFile(); this.Compiler = new PL0Compiler(FilePath); Compiler.compile(); if (Compiler.EH.errItem.Count == 0) { if (!codeList.Created) { codeList = new CodeList(); codeList.Show(); } this.pCodeFile(); codeList.setCodeText(Compiler.listCode()); } else { if (!errList.Created) { errList = new ErrorList(); errList.Show(); } errList.setErrText(Compiler.displayErr()); } } else { string msg = "请新建或打开一个PL程序文件!"; MessageBox.Show(msg, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void OnCloseFile(object sender, EventArgs e) { if (FilePath != null) { if (textBoxContent.Text != File.ReadAllText(FilePath)) { string sMsg = "是否保存对文档的更改?"; DialogResult dr = MessageBox.Show(sMsg, this.Text, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { SaveFile(); Compiler = null; if (errList != null) { errList.Close(); } if (codeList != null) { codeList.Close(); } } else if (dr == DialogResult.No) { textBoxContent.Clear(); textBoxContent.ClearUndoAndRedo(); textBoxContent.AcceptsTab = false; textBoxContent.Visible = false; FilePath = null; Compiler = null; if (errList != null) { errList.Close(); } if (codeList != null) { codeList.Close(); } } } else { textBoxContent.Clear(); textBoxContent.ClearUndoAndRedo(); textBoxContent.AcceptsTab = false; textBoxContent.Visible = false; FilePath = null; Compiler = null; if (errList != null) { errList.Close(); } if (codeList != null) { codeList.Close(); } } } }
private void OnExecute(object sender, EventArgs e) { if (FilePath != null) { this.SaveFile(); this.Compiler = new PL0Compiler(FilePath); Compiler.compile(); if (Compiler.EH.errItem.Count == 0) { string CodeFile = pCodeFile(); if (CodeFile != "") { string curPath = Directory.GetCurrentDirectory(); Process pInte = new Process(); pInte.StartInfo.FileName = curPath + "\\PL0CodeInterpreter.exe"; pInte.StartInfo.Arguments = CodeFile; pInte.Start(); } } else { if (!errList.Created) { errList = new ErrorList(); errList.Show(); } errList.setErrText(Compiler.displayErr()); } } else { string msg = "请新建或打开一个PL程序文件!"; MessageBox.Show(msg, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); } }