示例#1
0
        //
        private void myCircle(string[] result)
        {
            d = 1;
            string[] a;
            string[] line;
            line = MultipleCommand.Lines;
            CodeVallidation val     = new CodeVallidation();
            var             textArr = textOrder.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
            int             length  = textArr.Length;
            int             counter = 0;

            for (int t = 1; t <= length - 1; t++)
            {
                string[] arrayOrders = Regex.Split(line[counter], "\r\n");//splits the data at next line and stores themin array                                                                 //MessageBox.Show(arrayOrder[0]);
                String[] res         = val.valid(arrayOrders[0]);
                if (res[0] == "mycircle")
                {
                    string[] arra = Regex.Split(line[counter + 1], "\r\n");//splits the data at next line and stores themin array
                    a = val.valid(arra[0]);
                    if (a[1] == "mycircle")
                    {
                        string[] re = { "circle", res[1] };
                        definmethod(re);
                    }
                    else
                    {
                        MessageBox.Show("Method doesnot match");;
                    }
                }
                counter = counter + 1;
            }
        }
示例#2
0
        private void button7_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(MultipleCommand.Text))
            {
                textOrder = MultipleCommand.Text.Trim();

                string[] arrayOrder = Regex.Split(textOrder, "\n");

                for (int i = 0; i < arrayOrder.Length; i++)
                {
                    CodeVallidation v = new CodeVallidation();

                    String[] result = v.valid(arrayOrder[i]);
                    getShape(result);
                }
            }
        }
示例#3
0
        private void definmethod(string[] result)
        {
            d = 1;
            int b = Ending();

            if (b == 6)
            {
                string[] line;
                line = MultipleCommand.Lines;
                CodeVallidation val     = new CodeVallidation();
                var             textArr = textOrder.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                int             length  = textArr.Length;
                int             counter = 0;
                int             temp    = linenumber();
                MessageBox.Show(temp + "");
                for (int t = 1; t < length - 1; t++)
                {
                    string[] arrayOrder = Regex.Split(line[temp], "\r\n");//splits the data at next line and stores themin array
                    String[] results    = val.valid(arrayOrder[0]);
                    if (results[0] == "circle" || results[0] == "rectangle")
                    {
                        string[] arrayOrders = Regex.Split(line[temp], "\r\n");//splits the data at next line and stores themin array
                        results = val.valid(arrayOrder[0]);
                        if (results[0] == "rectangle" && result[0] == "rectangle")
                        {
                            string[] arra = { "rectangle", result[1], result[2] };
                            rectangle(arra);
                        }
                        else if (results[0] == "circle" && result[0] == "circle")
                        {
                            string[] arra = { "circle", result[1] };
                            circle(arra);
                            MessageBox.Show("circle build");
                        }
                    }
                    counter = counter + 1;
                }
            }
            else
            {
                d = 1;
                MessageBox.Show("endmethod missing");
            }
        }
示例#4
0
        private int Ending()
        {
            try
            {
                string[] line;
                line = MultipleCommand.Lines;
                CodeVallidation val     = new CodeVallidation();
                var             textArr = textOrder.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                int             length  = textArr.Length;
                int             counter = 0;
                for (int t = 1; t <= length; t++)
                {
                    string[] arrayOrder = Regex.Split(line[counter], "\r\n");//splits the data at next line and stores themin array
                    string[] result1    = val.valid(arrayOrder[0]);
                    if (result1[0] == "end")
                    {
                        return(5);

                        break;
                    }
                    if (result1[0] == "endmethod")
                    {
                        return(6);

                        break;
                    }
                    if (result1[0] == "endif")
                    {
                        return(7);

                        break;
                    }

                    counter = counter + 1;
                }
            }
            catch (NullReferenceException e)
            {
                MessageBox.Show(e.Message);
            }

            return(0);
        }
示例#5
0
        //end if

        //


        private int linenumber()
        {
            string[] line;
            line = MultipleCommand.Lines;
            CodeVallidation val     = new CodeVallidation();
            var             textArr = textOrder.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
            int             length1 = textArr.Length;
            int             counter = 0;
            int             yell    = 1;

            for (int t = 0; t <= length1; t++)
            {
                string[] arrayOrder = Regex.Split(line[counter], "\r\n");//splits the data at next line and stores themin array

                string[] result1 = val.valid(arrayOrder[0]);
                if (result1[0] == "loop")
                {
                    MessageBox.Show(counter + "l");
                    return(counter);

                    break;
                }
                else if (result1[0] == "if")
                {
                    MessageBox.Show(counter + "if");
                    return(counter);

                    break;
                }
                else if (result1[0] == "circle" || result1[0] == "rectangle")
                {
                    MessageBox.Show(counter + "circle or rectangle");
                    return(counter);

                    break;
                }

                counter = counter + 1;
                yell    = yell + 1;
            }
            return(0);
        }
示例#6
0
        private void button1_Click(object sender, EventArgs e)
        {
            String          cmd = SingleCommand.Text;
            CodeVallidation v   = new CodeVallidation();

            String[] result = v.valid(cmd);
            try
            {
                if (result[0] == "moveTo")
                {
                    MessageBox.Show("asdda");
                    int store1 = Convert.ToInt32(result[1]);
                    int store2 = Convert.ToInt32(result[2]);
                    x_axis = store1;
                    y_axis = store2;
                }
                if (result[0] == "rectangle")
                {
                    ShapeFactory s1 = new ShapeFactory();
                    FinalShape   sh = s1.getShape(result[0]);
                    sh.DrawShape(result, graph, x_axis, y_axis, radius, width, height);
                }
                if (result[0] == "triangle")
                {
                    ShapeFactory t1 = new ShapeFactory();
                    FinalShape   sh = t1.getShape(result[0]);
                    sh.DrawShape(result, graph, x_axis, y_axis, radius, width, height);
                }
                if (result[0] == "circle")
                {
                    ShapeFactory c1 = new ShapeFactory();
                    FinalShape   sh = c1.getShape(result[0]);
                    sh.DrawShape(result, graph, x_axis, y_axis, radius, width, height);
                }
            }
            catch (IndexOutOfRangeException)
            {
                MessageBox.Show("Please type a valid Command");
            }
        }
示例#7
0
        private void ifcase(string[] result)
        {
            d = 1;
            int b = Ending();

            if (b == 7)
            {
                string[] line;
                line = MultipleCommand.Lines;
                CodeVallidation val     = new CodeVallidation();
                var             textArr = textOrder.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                int             length  = textArr.Length;


                int counter = 0;
                for (int s = 1; s < length - 1; s++)
                {
                    string[] arrayOrder = Regex.Split(line[counter], "\r\n");//splits the data at next line and stores themin array
                    String[] results    = val.valid(arrayOrder[0]);
                    if (results[0] == "endif")
                    {
                        MessageBox.Show("dolll");
                    }
                    else
                    {
                        if (results[1] == "radius")
                        {
                            symbolcheck(results, line, counter);
                        }
                        counter = counter + 1;
                    }
                }
            }
            else
            {
                d = 1;
                MessageBox.Show("endif missing");
            }
        }
示例#8
0
        private void symbolcheck(string[] results, string[] line, int counter)
        {
            CodeVallidation val = new CodeVallidation();

            MessageBox.Show(results[2]);
            if (results[2] == "=")
            {
                MessageBox.Show("===");
                MessageBox.Show(radius + "");
                if (results[1] == "radius")
                {
                    if (Convert.ToInt32(results[3]) == radius)
                    {
                        MessageBox.Show("Radius equal");
                        string[] arrayOrders = Regex.Split(line[counter + 1], "\r\n");//splits the data at next line and stores themin array
                        MessageBox.Show(arrayOrders[0]);
                        String[] result = val.valid(arrayOrders[0]);
                        if (result[0] == "circle")
                        {
                            MessageBox.Show("asd");
                            string[] value = { "circle", result[1] };
                            MessageBox.Show("ssssdd");
                            circle(value);
                        }
                    }
                    else
                    {
                        MessageBox.Show("not equal");
                        d = 1;
                    }
                }
            }
            else if (results[2] == ">")
            {
                MessageBox.Show("greater");
                if (results[1] == "radius")
                {
                    if (radius > Convert.ToInt32(results[3]))
                    {
                        MessageBox.Show("assd");
                        string[] arrayOrders = Regex.Split(line[counter + 1], "\r\n");//splits the data at next line and stores themin array
                        String[] result      = val.valid(arrayOrders[0]);
                        MessageBox.Show(result[1] + "asssss");
                        MessageBox.Show(result[0]);
                        if (result[0] == "circle")
                        {
                            MessageBox.Show("asd");
                            string[] value = { "circle", result[1] };
                            circle(value);
                        }
                    }
                    else
                    {
                        MessageBox.Show("radius is lesser");
                        d = 1;
                    }
                }
            }

            else if (results[2] == "<")
            {
                if (results[1] == "radius")
                {
                    if (radius < Convert.ToInt32(results[3]))
                    {
                        string[] arrayOrders = Regex.Split(line[counter + 1], "\r\n");//splits the data at next line and stores themin array
                        MessageBox.Show(arrayOrders[0]);
                        String[] r = val.valid(arrayOrders[0]);
                        r = val.valid(arrayOrders[0]);
                        MessageBox.Show(r[1]);
                        if (r[0] == "circle")
                        {
                            string[] value = { "circle", r[1] };
                            circle(value);
                        }
                    }
                    else
                    {
                        MessageBox.Show("radius greater");
                        d = 1;
                    }
                }
            }
        }
示例#9
0
        private void loop(string[] result, int radius, int width, int height)
        {
            MessageBox.Show("yaha pugi");
            try
            {
                b = Ending();
                d = 1;
                if (b == 5)
                {
                    string[] line;
                    int      a = Convert.ToInt32(result[1]);
                    line = MultipleCommand.Lines;
                    CodeVallidation val     = new CodeVallidation();
                    var             textArr = textOrder.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                    int             length  = textArr.Length;
                    for (int s = 1; s <= a; s++)
                    {
                        int temp    = linenumber();
                        int number  = linenumber();
                        int counter = 0;
                        for (int t = 1; t < length - 1; t++)
                        {
                            string[] arrayOrder = Regex.Split(line[temp], "\r\n"); //splits the data at next line and stores themin array
                                                                                   //MessageBox.Show(arrayOrder[0]);
                            String[] results = val.valid(arrayOrder[0]);
                            MessageBox.Show(arrayOrder[0]);

                            if (results[0] == "rectangle")
                            {
                                rectangle(result);
                            }
                            else if (results[0] == "triangle")
                            {
                                triangle(results);
                            }
                            else if (results[0] == "circle")
                            {
                                circle(results);
                            }
                            else if (result[0] == "square")
                            {
                                Square(results);
                            }
                            else if (results[0] == "transform")
                            {
                                transform(results);
                            }
                            else if (results[0] == "drawTo")
                            {
                                drawto(results);
                            }
                            else if (results[0] == "moveto")
                            {
                                moveto(results);
                            }
                            else if (results[0] == "radius" && results[1] == "=")
                            {
                                string[] r = { "circle", results[1], results[2] };
                                radiusvariable(r);
                            }
                            else if (results[0] == "width" && results[1] == "=")
                            {
                                width = Convert.ToInt32(result[2]);
                            }
                            else if (results[0] == "height" && results[1] == "=")
                            {
                                height = Convert.ToInt32(results[2]);
                            }
                            else if (results[0] == "radius" && results[1] == "+")
                            {
                                string[] r = { "circle", results[1], results[2] };
                                radiusadd(r);
                            }
                            else if (results[0] == "width" && results[1] == "+")
                            {
                                width = Convert.ToInt32(results[2]);
                            }
                            else if (results[0] == "height" && results[1] == "+")
                            {
                                height = Convert.ToInt32(results[2]);
                            }

                            counter = counter + 1;
                            temp    = temp + 1;
                        }
                    }
                }
                else
                {
                    MessageBox.Show("end command missing");
                    d = 1;
                }
            }
            catch (NullReferenceException e)
            {
                MessageBox.Show(e.Message);
            }
        }