From 883657e2a948dc950cc01dfb8df70f557a2421e6 Mon Sep 17 00:00:00 2001 From: Rory Naughton <141364481+RoryNaught@users.noreply.github.com> Date: Wed, 27 Nov 2024 13:38:51 -0500 Subject: [PATCH] Mostly documentation Added comments for the functions we added or touched, according to C# convention. Renamed "tsmloadAndAssembleSICSourceFIle_Click" to just" tsmloadSICSourceFIle_Click" according to the refactor. Did some testing. I did change save feature names in tool drop down to specify between save as and save current. Save feature bugs appear fixed in Adams last commit. --- SIC Simulator/Form1.Designer.cs | 2 +- SIC Simulator/Form1.cs | 45 +++++++++++++++++++++++++-------- 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/SIC Simulator/Form1.Designer.cs b/SIC Simulator/Form1.Designer.cs index 2c74692..5323678 100644 --- a/SIC Simulator/Form1.Designer.cs +++ b/SIC Simulator/Form1.Designer.cs @@ -598,7 +598,7 @@ private void InitializeComponent() this.tsmloadSICSourceFIle.Name = "tsmloadSICSourceFIle"; this.tsmloadSICSourceFIle.Size = new System.Drawing.Size(484, 44); this.tsmloadSICSourceFIle.Text = "Load SIC Source FIle"; - this.tsmloadSICSourceFIle.Click += new System.EventHandler(this.tsmloadAndAssembleSICSourceFIle_Click); + this.tsmloadSICSourceFIle.Click += new System.EventHandler(this.tsmloadSICSourceFIle_Click); // // tsmOpen_SIC_Object_File // diff --git a/SIC Simulator/Form1.cs b/SIC Simulator/Form1.cs index 6c35c53..b83daab 100644 --- a/SIC Simulator/Form1.cs +++ b/SIC Simulator/Form1.cs @@ -668,12 +668,14 @@ private void tsmOpen_SIC_Object_File_Click(object sender, EventArgs e) { } - /* - * Loads in SIC assembly code from a file - * Passes the code through an assembler - * Prompts the User for loading preference (absolute or relocating) - */ - private void tsmloadAndAssembleSICSourceFIle_Click(object sender, EventArgs e) { + /// + /// Event handler for loading a SIC source file. + /// Displays the file content in the code editor tab. + /// Stores the file name for further usage. + /// + /// The source of the event. + /// An EventArgs object containing event data. + private void tsmloadSICSourceFIle_Click(object sender, EventArgs e) { if (loadSICSourceFD.ShowDialog() == DialogResult.OK) { //Add file text to code editor. StreamReader fileRead = new StreamReader(loadSICSourceFD.FileName); @@ -681,8 +683,13 @@ private void tsmloadAndAssembleSICSourceFIle_Click(object sender, EventArgs e) { fileRead.Close(); this.LastLoadedFileName = (loadSICSourceFD.FileName); } - }//END tsmloadAndAssembleSICSourceFIle_Click() + }//END tsmloadSICSourceFIle_Click() + /// + /// Assembles the SIC source file and prepares it for loading into the virtual machine. + /// Prompts the user for loading preference (absolute or relocating) + /// + /// The name of the SIC source file to assemble. public void assembleSicFile(string filename) { Assembler assembler = new Assembler(filename); this.SICVirtualMachine.getSICSource(assembler); @@ -720,7 +727,7 @@ public void assembleSicFile(string filename) { } this.RefreshCPUDisplays(); // refresh memory after object code is loaded - } + }//END assembleSICFile() /* * Handles the portion of the T-record that doesn't corresspond to memory @@ -1261,13 +1268,19 @@ private void assembleCurrentFileToolStripMenuItem_Click(object sender, EventArgs } - + /// + /// Event handler. + /// Saves the current SIC source file from the text editor tab. + /// If no file is was loaded in, prompts the user to save as a new file. + /// + /// The source of the event. + /// The event arguments. private void saveSICSourceFileToolStripMenuItem_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.LastLoadedFileName)) { // prompt for "Save As" if no file has been loaded SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "SIC Source Files|*.sic"; - saveFileDialog.Title = "Save SIC Source File"; + saveFileDialog.Title = "Save current SIC Source File"; if (saveFileDialog.ShowDialog() == DialogResult.OK) { this.LastLoadedFileName = saveFileDialog.FileName; try { @@ -1291,13 +1304,23 @@ private void saveSICSourceFileToolStripMenuItem_Click(object sender, EventArgs e } } } - + /// + /// Writes the contents of the code editor to specified file. + /// + /// the file the editor contents will be saved to. private void saveEditorContents(string filename) { StreamWriter fileWrite = new StreamWriter(filename); fileWrite.Write(this.txtCodeEditor.Text); fileWrite.Close(); } + /// + /// Event handler from tool strip menu. + /// Used to save the current editor contents as a NEW SIC source file. + /// The user is prompted to specify the file name and locaton. + /// + /// The source of the event. + /// The event arguments. private void saveNewSICSourceFileToolStripMenuItem_Click(object sender, EventArgs e) { // prompt for "Save As" SaveFileDialog saveFileDialog = new SaveFileDialog();