/// HELPER FUNCTION: to loadFileToolStripMenuItem_Click() and resetToolStripMenuItem_Click() events /// /// Tries to load the file into RAM. /// If it can't load, it displays an error dialog. /// If it succesfully load, then /// - reset trace counter to 1 /// - re-create file trace.log /// - set trace ON /// - update gui panels /// - enable/disable toolstrip menu items /// RETURNS: -1 if failed to load file into RAM /// 0 if loaded succesfully private int tryLoadingFileIntoMemory() { try { int succesfullyOpenedFile = computer.loadSegmentsIntoRAM(filePath); if (succesfullyOpenedFile == -1) // display a dialog error if not able to load { displayFailedToOpenFileDialog(this.currentFileName); return(-1); } // get checksum and update labels string memChecksum = computer.getMemChecksum(); this.checksumLabel.Text = "Checksum: " + memChecksum; // update checksum in GUI this.fileOpenedLabel.Text = "File opened: " + this.currentFileName; // update file name in GUI // reset trace computer.resetTraceCounterToOne(); computer.turnOffTraceLog(); computer.turnOnTraceLog(); toggleTraceOnoffToolStripMenuItem.Text = "Turn OFF trace log"; // clear cpu list for dissembly panel computer.clearCPUInstructionAddressDisassembledLists(); // clear disassembled instruction string in CPU computer.clearCPUDisassembledCombinedString(); // clear terminal text and queue terminlaTextBox.Clear(); charsQueue.Clear(); // enable menu item availability updatePanelsAndResetMenuItems(); resetToolStripMenuItem.Enabled = true; toggleTraceOnoffToolStripMenuItem.Enabled = true; return(0); } catch (Exception fileOpenExcept) { fileOpenedLabel.Text = "File opened: None"; displayFailedToOpenFileDialog(this.currentFileName); Debug.WriteLine("loadFileToolStripMenuItem_Click(): " + fileOpenExcept.Message); return(-1); } }