/// <summary> /// Checks all the command and draw specific patterns as defined. /// </summary> public void RunProgramMethod() { try { String input = CordinateBox.Text; CommandParser cmd = new CommandParser(); String[] val = cmd.ValidationCheck(input, point1, point2); if (val[0] == "moveto") { int a = Convert.ToInt32(val[1]); int b = Convert.ToInt32(val[2]); point1 = a; point2 = b; } if (val[0] == "drawto") { Color colour = cmd.getColor(); FileChooser s1 = new FileChooser(); Shape sh = s1.getShape(val[0]); sh.drawShape(val, g, point1, point2, colour); } else if (val[0] == "rectangle") { Color colour = cmd.getColor(); FileChooser s1 = new FileChooser(); Shape sh = s1.getShape(val[0]); sh.drawShape(val, g, point1, point2, colour); } else if (val[0] == "circle") { Color colour = cmd.getColor(); FileChooser s1 = new FileChooser(); Shape sh = s1.getShape(val[0]); sh.drawShape(val, g, point1, point2, colour); } else if (val[0] == "triangle") { Color colour = cmd.getColor(); FileChooser s1 = new FileChooser(); Shape sh = s1.getShape(val[0]); sh.drawShape(val, g, point1, point2, colour); } else if (val[0] == "error") { MessageBox.Show("Opppps...! Sorry. Error Occured."); } else if (input.ToUpper() == "RUN") { MultipleLineMethod(); } else { } } catch (Exception e) { } }
/// <summary> /// This method is used to take the input from the user which reads /// the multiple line from the textbox. /// </summary> public void MultipleLineMethod() { try { CommandParser cmd = new CommandParser(); Color colour = cmd.getColor(); int counter = MultipleText.Lines.Length; for (int i = 0; i < counter; i++) { String input = string.Format("text"); input = MultipleText.Lines[i]; CommandParser cp = new CommandParser(); String[] val = cp.ValidationCheck(input, point1, point2); if (val[0] == "moveto") { int a = Convert.ToInt32(val[1]); int b = Convert.ToInt32(val[2]); point1 = a; point2 = b; } else if (val[0] == "drawto") { FileChooser s1 = new FileChooser(); Shape sh = s1.getShape(val[0]); sh.drawShape(val, g, point1, point2, colour); } else if (val[0] == "rectangle") { FileChooser s1 = new FileChooser(); Shape sh = s1.getShape(val[0]); sh.drawShape(val, g, point1, point2, colour); } else if (val[0] == "circle") { FileChooser s1 = new FileChooser(); Shape sh = s1.getShape(val[0]); sh.drawShape(val, g, point1, point2, colour); } else if (val[0] == "triangle") { FileChooser s1 = new FileChooser(); Shape sh = s1.getShape(val[0]); sh.drawShape(val, g, point1, point2, colour); } else if (val[0].ToUpper() == "PEN") { CommandParser.isPen = true; if (val[1].Equals("red")) { CommandParser.colour = Color.Red; } //if parameter is blue then colour is set to blue else if (val[1].Equals("blue")) { CommandParser.colour = Color.Blue; } //if parameter is yellow then colour is set to yellow else if (val[1].Equals("yellow")) { CommandParser.colour = Color.Yellow; } //if parameter is gray then colour is set to gray else if (val[1].Equals("gray")) { CommandParser.colour = Color.Gray; } //if parameter is green then colour is set to green else if (val[1].Equals("green")) { colour = Color.Green; } } else if (val[0].ToUpper() == "FILL") { if (val[1].Equals("on")) { CommandParser.isFillOn = true; } else { CommandParser.isFillOn = false; } } else if (val[0] == "error") { MessageBox.Show("Please enter valid value"); } else { } } } catch (Exception e) { } }