示例#1
0
        /// <summary>
        /// Its a run button to run single line command and draw shape from single line command
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnRun_Click(object sender, EventArgs e)
        {
            string   UserInput = this.UserInput.Text;
            Validate validate  = new Validate();

            string[] getInput = validate.getValidate(UserInput);
            this.UserInput.ResetText();
            if (getInput.Length > 1)
            {
                if (getInput[0] == "moveto")
                {
                    int x = Convert.ToInt32(getInput[1]);
                    int y = Convert.ToInt32(getInput[2]);
                    pos1 = x;
                    pos2 = y;
                }

                else if (getInput[0] == "line")
                {
                    Shape          shape          = new Shape();
                    ShapeInterface shapeinterface = shape.getShape(getInput[0]);
                    shapeinterface.drawshape(g, pos1, pos2, getInput);
                }

                else if (getInput[0] == "rectangle")
                {
                    Shape          shape          = new Shape();
                    ShapeInterface shapeinterface = shape.getShape(getInput[0]);
                    shapeinterface.drawshape(g, pos1, pos2, getInput);
                }

                else if (getInput[0] == "circle")
                {
                    Shape          shape          = new Shape();
                    ShapeInterface shapeinterface = shape.getShape(getInput[0]);
                    shapeinterface.drawshape(g, pos1, pos2, getInput);
                }

                else if (getInput[0] == "triangle")
                {
                    Shape          shape          = new Shape();
                    ShapeInterface shapeinterface = shape.getShape(getInput[0]);
                    shapeinterface.drawshape(g, pos1, pos2, getInput);
                }
                else if (getInput[0] == "polygon")
                {
                    Shape          shape          = new Shape();
                    ShapeInterface shapeinterface = shape.getShape(getInput[0]);
                    shapeinterface.drawshape(g, pos1, pos2, getInput);
                }

                else
                {
                    throw new Exception("Parameter Not Foundasdfasdf !!!");
                }
            }
        }
示例#2
0
        private void btnMultilineExecute_Click(object sender, EventArgs e)
        {
            string userInput = txtMultiLine.Text;

            string[] lineSeparate = userInput.Split('\n');

            foreach (string eachline in lineSeparate)
            {
                if (lineSeparate.Equals(" ") || lineSeparate.Equals(null))
                {
                }
                else
                {
                    string   UserInput = eachline;
                    Validate validate  = new Validate();
                    string[] getInput  = validate.getValidate(UserInput);
                    if (getInput.Length > 1)
                    {
                        if (getInput[0].Equals("moveto"))
                        {
                            int x = Convert.ToInt32(getInput[1]);
                            int y = Convert.ToInt32(getInput[2]);
                            pos1 = x;
                            pos2 = y;
                        }

                        else if (getInput[0].Equals("line"))
                        {
                            Shape          shape          = new Shape();
                            ShapeInterface shapeinterface = shape.getShape(getInput[0]);
                            shapeinterface.drawshape(g, pos1, pos2, getInput);
                        }

                        else if (getInput[0].Equals("rectangle"))
                        {
                            Shape          shape          = new Shape();
                            ShapeInterface shapeinterface = shape.getShape(getInput[0]);
                            shapeinterface.drawshape(g, pos1, pos2, getInput);
                        }

                        else if (getInput[0].Equals("circle"))
                        {
                            Shape          shape          = new Shape();
                            ShapeInterface shapeinterface = shape.getShape(getInput[0]);
                            shapeinterface.drawshape(g, pos1, pos2, getInput);
                        }

                        else if (getInput[0].Equals("triangle"))
                        {
                            Shape          shape          = new Shape();
                            ShapeInterface shapeinterface = shape.getShape(getInput[0]);
                            shapeinterface.drawshape(g, pos1, pos2, getInput);
                        }

                        else if (getInput[0].Equals("polygon"))
                        {
                            Shape          shape          = new Shape();
                            ShapeInterface shapeinterface = shape.getShape(getInput[0]);
                            shapeinterface.drawshape(g, pos1, pos2, getInput);
                        }

                        else
                        {
                            throw new Exception("Parameter Not Found !!!");
                        }
                    }
                }
            }
        }