/// <summary> /// This is the method which gives the necessary function to single command line /// </summary> public void RunProgramMethod() { try { String input = textBox1.Text; Validate v = new Validate(); String[] val = v.getValidate(input, p1, p2); // This if statement tests if the input is moveto command and gives necessary function to it if (val[0] == "moveto") { int a = Convert.ToInt32(val[1]); int b = Convert.ToInt32(val[2]); p1 = a; p2 = b; } // This if statement tests if the input is drawto command and gives necessary function to it if (val[0] == "drawto") { ShapeIdentify s1 = new ShapeIdentify(); Interface1 sh = s1.getShape(val[0]); sh.drawShape(val, color, g, p1, p2); } // This else if statement tests if the input is to draw rectangle shape and gives necessary function to it else if (val[0] == "rectangle") { ShapeIdentify s1 = new ShapeIdentify(); Interface1 sh = s1.getShape(val[0]); // This if statement tests if the input is fill off command and gives necessary function to it if (s == "off") { sh.drawShape(val, color, g, p1, p2); } // This if statement tests if the input is fill on command and gives necessary function to it else if (s == "on") { sh.fill(val, color, g, p1, p2); } // This else statement is the default statement if user doesnot give any input for shape else { sh.drawShape(val, color, g, p1, p2); } } // This else if statement tests if the input is circle command and gives necessary function to it else if (val[0] == "circle") { ShapeIdentify s1 = new ShapeIdentify(); Interface1 sh = s1.getShape(val[0]); // same as explained on above line inside rectangle if statement if (s == "off") { sh.drawShape(val, color, g, p1, p2); } else if (s == "on") { sh.fill(val, color, g, p1, p2); } else { sh.drawShape(val, color, g, p1, p2); } } // This else if statement tests if the input is triangle command and gives necessary function to it else if (val[0] == "triangle") { ShapeIdentify s1 = new ShapeIdentify(); Interface1 sh = s1.getShape(val[0]); if (s == "off") { sh.drawShape(val, color, g, p1, p2); } else if (s == "on") { sh.fill(val, color, g, p1, p2); } else { sh.drawShape(val, color, g, p1, p2); } } // This else if statement gives the error message if the user passes invalid command else if (val[0] == "error") { System.Windows.Forms.MessageBox.Show("Error"); } else { } } catch (Exception e) { } }
/// <summary> /// This is the method which gives the necessary function to mulltiple textbox /// </summary> public void MultipleLineMethod() { try { int counter = textBox2.Lines.Length; for (int i = 0; i < counter; i++) { String input = string.Format("text"); input = textBox2.Lines[i]; Validate v = new Validate(); String[] val = v.getValidate(input, p1, p2); if (val[0] == "moveto") { int a = Convert.ToInt32(val[1]); int b = Convert.ToInt32(val[2]); p1 = a; p2 = b; } else if (val[0] == "drawto") { ShapeIdentify s1 = new ShapeIdentify(); Interface1 sh = s1.getShape(val[0]); sh.drawShape(val, color, g, p1, p2); } else if (val[0] == "rectangle") { ShapeIdentify s1 = new ShapeIdentify(); Interface1 sh = s1.getShape(val[0]); if (s == "off") { sh.drawShape(val, color, g, p1, p2); } else if (s == "on") { sh.fill(val, color, g, p1, p2); } else { sh.drawShape(val, color, g, p1, p2); } } else if (val[0] == "circle") { ShapeIdentify s1 = new ShapeIdentify(); Interface1 sh = s1.getShape(val[0]); if (s == "off") { sh.drawShape(val, color, g, p1, p2); } else if (s == "on") { sh.fill(val, color, g, p1, p2); } else { sh.drawShape(val, color, g, p1, p2); } } else if (val[0] == "triangle") { ShapeIdentify s1 = new ShapeIdentify(); Interface1 sh = s1.getShape(val[0]); if (s == "off") { sh.drawShape(val, color, g, p1, p2); } else if (s == "on") { sh.fill(val, color, g, p1, p2); } else { sh.drawShape(val, color, g, p1, p2); } } else if (val[0] == "error") { System.Windows.Forms.MessageBox.Show("Please enter valid value"); } else { } } } catch (Exception e) { } }