private void openMI_Click(object sender, EventArgs e) { if (openFile.ShowDialog() == DialogResult.OK) { SaveAndClose(); try { memView.Close(); memView.Dispose(); } catch { } MPU.CommitMemory(); if (OneXFile.ExtractOneXFile(openFile.FileName, "currentfile")) { saveFileName = openFile.FileName; string dir = Application.UserAppDataPath + "\\currentfile"; codeFileName = dir + "\\code"; codeBox.OpenFile(codeFileName, Encoding.UTF8); MPU.InitMemory(dir + "\\memory"); memView = new MemoryViewer(); codeBox.IsChanged = false; modifiedinfo.Text = Path.GetFileName(saveFileName) + " - *No Changes*"; codeBox.Visible = true; } else { MessageBox.Show("The selected *.onex file is in invalid format!", "Invalid format!", MessageBoxButtons.OK, MessageBoxIcon.Error); CloseFile(); } } }
private async void nextStepBtn_Click(object sender, EventArgs e) { if (MPU.PC < MainForm.startAddress) { MPU.PC = MainForm.startAddress; } await Task.Run(() => MPU.NextStep()); }
private void CloseFile() { codeBox.Clear(); string dir = Application.UserAppDataPath + "\\currentfile"; codeFileName = dir + "\\code"; codeBox.IsChanged = false; modifiedinfo.Text = ""; try { memView.Close(); memView.Dispose(); } catch { } try { MPU.CommitMemory(); Directory.Delete(dir, true); } catch (IOException) { } catch (NullReferenceException) { } codeBox.Visible = false; }
private void New() { SaveAndClose(); codeBox.Clear(); string dir = Application.UserAppDataPath + "\\currentfile"; codeFileName = dir + "\\code"; modifiedinfo.Text = "Untitled - *No Changes*"; try { memView.Close(); memView.Dispose(); } catch { } try { MPU.CommitMemory(); } catch (NullReferenceException) { } try { Directory.Delete(dir, true); } catch (IOException) { } Directory.CreateDirectory(dir); MPU.InitMemory(dir + "\\memory"); memView = new MemoryViewer(); codeBox.IsChanged = false; codeBox.Visible = true; }
private void SaveFile(string name) { if (string.IsNullOrWhiteSpace(name)) { saveasMI.PerformClick(); return; } saveFileName = name; string dir = Application.UserAppDataPath + "\\currentfile"; codeFileName = dir + "\\code"; codeBox.SaveToFile(codeFileName, Encoding.UTF8); try { memView.Close(); memView.Dispose(); } catch { } MPU.CommitMemory(); OneXFile.RepackOneXFile(name, "currentfile"); MPU.InitMemory(dir + "\\memory"); memView = new MemoryViewer(); // commit changes (reset all dirty flags) codeBox.IsChanged = false; modifiedinfo.Text = Path.GetFileName(saveFileName) + " - *Changes Saved*"; }
private void stopBtn_Click(object sender, EventArgs e) { MPU.Stop(); }
private async void execButton_Click(object sender, EventArgs e) => await Task.Run(() => MPU.ExecuteAllSteps());
private async void nextStepBtn_Click(object sender, EventArgs e) => await Task.Run(() => MPU.NextStep());
private void resetBtn_Click(object sender, EventArgs e) { MPU.Stop(); MPU.PC = MainForm.startAddress; }