//Command line waiting to be called (textbox) private void commandLine_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { String direct = commandLine.Text.Trim().ToLower(); String charge = richCommandLine.Text.Trim().ToLower(); //Run command if (direct.Equals("run") == true) { richCommand.parseRich(charge); } else { varCommand.Parse(direct); } commandLine.Text = ""; Refresh(); } }
public void parseRich(string charge) { List <string> commandList = new List <string>( charge.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries)); foreach (string direct in commandList) { if (direct.Contains("loop") == true) { string loadLoop = direct.Trim().ToLower(); List <string> loadValue = new List <string>( loadLoop.Split(new string[] { ",", " " }, StringSplitOptions.RemoveEmptyEntries)); int processLoop = Int32.Parse(loadValue[2]); foreach (string loopLoad in commandList) { if (loopLoad.Contains("end") == true) { for (int i = 0; i < processLoop; i++) { foreach (string j in loopIndex) { string loopContent = j; parseRich(loopContent); } System.Diagnostics.Debug.WriteLine("Amount of loops: " + i); } } else { if (loopLoad.Contains("loop") == true) { System.Diagnostics.Debug.WriteLine("Ignore loopIndex"); } else { loopIndex.Add(loopLoad); } } } } //Checks if ParseVariableCommand is null, if it is, it parses the data else if (direct.Contains("=") == true) { if (pvCommand == null) { pvCommand = new ParseVariableCommand(pictureBoxCanvas, parseTell, drawCircle, drawSquare, drawTriangle); pvCommand.Parse(direct); } else { pvCommand.Parse(direct); } } else { parseTell.Parse(direct); } } }