//Calling classes public ParseRichCommand(PictureBox pictureBox, ParseCommand parseCommand, ParseVariableCommand parseVariableCommand, Circle drawCircle, Square drawSquare, Triangle drawTriangle) { this.pictureBoxCanvas = pictureBox; this.parseTell = parseCommand; this.pvCommand = parseVariableCommand; this.drawCircle = drawCircle; this.drawSquare = drawSquare; this.drawTriangle = drawTriangle; }
public FormGraphicalProgrammingLanguageApplication() { //Initialization section where other classes are called InitializeComponent(); pictureBoxCanvas = new PictureBox(Graphics.FromImage(outputBitmap)); drawSquare = new Square(Graphics.FromImage(outputBitmap)); drawCircle = new Circle(Graphics.FromImage(outputBitmap)); drawTriangle = new Triangle(Graphics.FromImage(outputBitmap)); varCommand = new ParseCommand(pictureBoxCanvas, drawCircle, drawSquare, drawTriangle); richCommand = new ParseRichCommand(pictureBoxCanvas, varCommand, pvCommand, drawCircle, drawSquare, drawTriangle); pvCommand = new ParseVariableCommand(pictureBoxCanvas, varCommand, drawCircle, drawSquare, drawTriangle); }
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); } } }