Пример #1
0
        private void OpenAdd(Statement name)
        {
            StatementBase StatementName = null;

            if (name.GetType() == typeof(XmlVariable))
            {
                StatementName = new VariableDefine();
            }
            else if (name.GetType() == typeof(XmlImputC))
            {
                StatementName = new InputConsole();
            }
            else if (name.GetType() == typeof(XmlCondition))
            {
                StatementName = new Conditions();
            }
            else if (name.GetType() == typeof(XmlLoop))
            {
                StatementName = new Loop();
            }
            else if (name.GetType() == typeof(XmlArray))
            {
                StatementName = new ArrayDefine();
            }
            else if (name.GetType() == typeof(XmlCase))
            {
                StatementName = new CaseControl();
            }
            else if (name.GetType() == typeof(XmlOutputC))
            {
                StatementName = new OutputConsole();
            }
            else if (name.GetType() == typeof(XmlBreak))
            {
                StatementName = new BreakControl();
            }
            else if (name.GetType() == typeof(XmlCalculation))
            {
                StatementName = new Calculation();
            }
            else if (name.GetType() == typeof(XmlMold))
            {
                StatementName = new ReturnMold();
            }
            else if (name.GetType() == typeof(XmlAssignment))
            {
                StatementName = new Assignment();
            }
            InsertContlols(StatementName);
            ControlOrder[IndexNumber].ControlSetup(name);
            number++;
            if (this.Parent.Parent.Parent.GetType() == typeof(Form1))
            {
                Form1 Mparent = (Form1)Parent.Parent.Parent;
                Mparent.AddBar(1);
            }
        }
Пример #2
0
        /// <summary>
        /// 変数の型を調べます
        /// </summary>
        /// <param name="MyControl"></param>
        /// <returns></returns>
        public static Dictionary <string, string> GetVariableType(Control MyControl)
        {
            Dictionary <string, string> VariableType = new Dictionary <string, string>();
            Control              MyParent            = MyControl.Parent;
            StatementBlock       MystatementBlock    = (StatementBlock)MyParent;
            List <StatementBase> OrderControls       = new List <StatementBase>();

            OrderControls = MystatementBlock.GetOrderControls();
            for (int i = 0; OrderControls[i] != MyControl; i++)
            {
                if (OrderControls[i].GetType().Equals(typeof(VariableDefine)))
                {
                    VariableDefine variableDefineName = (VariableDefine)OrderControls[i];
                    if (string.IsNullOrWhiteSpace(variableDefineName.textBox1.Text) == false || string.IsNullOrEmpty(variableDefineName.comboBox1.Text) == false)
                    {
                        VariableType.Add(variableDefineName.textBox1.Text, variableDefineName.itemType);
                    }
                }
                else if (OrderControls[i].GetType().Equals(typeof(ArrayDefine)))
                {
                    ArrayDefine arrayDefineName = (ArrayDefine)OrderControls[i];
                    if (string.IsNullOrWhiteSpace(arrayDefineName.textBox1.Text) == false && string.IsNullOrEmpty(arrayDefineName.arrayType.Text) == false && string.IsNullOrWhiteSpace(arrayDefineName.textBox2.Text) == false)
                    {
                        for (int j = 0; j < int.Parse(arrayDefineName.textBox2.Text); j++)
                        {
                            VariableType.Add(arrayDefineName.textBox1.Text + "[" + j + "]", arrayDefineName.itemType);
                        }
                    }
                }
            }

            if (MyParent.Parent is StatementBase)
            {
                foreach (KeyValuePair <String, String> keyVal in GetVariableType(MyParent.Parent))
                {
                    VariableType.Add(keyVal.Key, keyVal.Value);
                }
            }
            return(VariableType);
        }
Пример #3
0
        public static List <String> GetVariableList(Control MyControl, int Type)
        {
            List <string>        vList            = new List <string>();
            Control              MyParent         = MyControl.Parent;
            StatementBlock       MystatementBlock = (StatementBlock)MyParent;
            List <StatementBase> OrderControls    = new List <StatementBase>();

            OrderControls = MystatementBlock.GetOrderControls();
            if (Type == 0)
            {
                for (int i = 0; OrderControls[i] != MyControl; i++)
                {
                    if (OrderControls[i].GetType().Equals(typeof(VariableDefine)))
                    {
                        VariableDefine variableDefineName = (VariableDefine)OrderControls[i];
                        if (string.IsNullOrWhiteSpace(variableDefineName.textBox1.Text) == false || string.IsNullOrEmpty(variableDefineName.comboBox1.Text) == false)
                        {
                            vList.Add(variableDefineName.textBox1.Text);
                        }
                    }
                    else if (OrderControls[i].GetType().Equals(typeof(ArrayDefine)))
                    {
                        ArrayDefine arrayDefineName = (ArrayDefine)OrderControls[i];
                        if (string.IsNullOrWhiteSpace(arrayDefineName.textBox1.Text) == false && string.IsNullOrEmpty(arrayDefineName.arrayType.Text) == false && string.IsNullOrWhiteSpace(arrayDefineName.textBox2.Text) == false)
                        {
                            for (int j = 0; j < int.Parse(arrayDefineName.textBox2.Text); j++)
                            {
                                vList.Add(arrayDefineName.textBox1.Text + "[" + j + "]");
                            }
                        }
                    }
                }
            }
            if (Type == 1)
            {
                for (int i = 0; OrderControls[i] != MyControl; i++)
                {
                    if (OrderControls[i].GetType().Equals(typeof(VariableDefine)))
                    {
                        VariableDefine variableDefineName = (VariableDefine)OrderControls[i];
                        if (variableDefineName.comboBox1.SelectedIndex == 0 || variableDefineName.comboBox1.SelectedIndex == 3 || variableDefineName.comboBox1.SelectedIndex == 4)
                        {
                            if (string.IsNullOrWhiteSpace(variableDefineName.textBox1.Text) == false || string.IsNullOrEmpty(variableDefineName.comboBox1.Text) == false)
                            {
                                vList.Add(variableDefineName.textBox1.Text);
                            }
                        }
                    }
                    else if (OrderControls[i].GetType().Equals(typeof(ArrayDefine)))
                    {
                        ArrayDefine arrayDefineName = (ArrayDefine)OrderControls[i];
                        if (arrayDefineName.arrayType.SelectedIndex == 0 || arrayDefineName.arrayType.SelectedIndex == 3 || arrayDefineName.arrayType.SelectedIndex == 4)
                        {
                            if (string.IsNullOrWhiteSpace(arrayDefineName.textBox1.Text) == false && string.IsNullOrEmpty(arrayDefineName.arrayType.Text) == false && string.IsNullOrWhiteSpace(arrayDefineName.textBox2.Text) == false)
                            {
                                for (int j = 0; j < int.Parse(arrayDefineName.textBox2.Text); j++)
                                {
                                    vList.Add(arrayDefineName.textBox1.Text + "[" + j + "]");
                                }
                            }
                        }
                    }
                }
            }
            if (Type == 2)
            {
                for (int i = 0; OrderControls[i] != MyControl; i++)
                {
                    if (OrderControls[i].GetType().Equals(typeof(VariableDefine)))
                    {
                        VariableDefine variableDefineName = (VariableDefine)OrderControls[i];
                        if (variableDefineName.comboBox1.SelectedIndex == 1)
                        {
                            if (string.IsNullOrWhiteSpace(variableDefineName.textBox1.Text) == false || string.IsNullOrEmpty(variableDefineName.comboBox1.Text) == false)
                            {
                                vList.Add(variableDefineName.textBox1.Text);
                            }
                        }
                    }
                    else if (OrderControls[i].GetType().Equals(typeof(ArrayDefine)))
                    {
                        ArrayDefine arrayDefineName = (ArrayDefine)OrderControls[i];
                        if (arrayDefineName.arrayType.SelectedIndex == 1)
                        {
                            if (string.IsNullOrWhiteSpace(arrayDefineName.textBox1.Text) == false && string.IsNullOrEmpty(arrayDefineName.arrayType.Text) == false && string.IsNullOrWhiteSpace(arrayDefineName.textBox2.Text) == false)
                            {
                                for (int j = 0; j < int.Parse(arrayDefineName.textBox2.Text); j++)
                                {
                                    vList.Add(arrayDefineName.textBox1.Text + "[" + j + "]");
                                }
                            }
                        }
                    }
                }
            }
            if (Type == 3)
            {
                for (int i = 0; OrderControls[i] != MyControl; i++)
                {
                    if (OrderControls[i].GetType().Equals(typeof(VariableDefine)))
                    {
                        VariableDefine variableDefineName = (VariableDefine)OrderControls[i];
                        if (variableDefineName.comboBox1.SelectedIndex == 0 || variableDefineName.comboBox1.SelectedIndex == 1 || variableDefineName.comboBox1.SelectedIndex == 3 || variableDefineName.comboBox1.SelectedIndex == 4)
                        {
                            if (string.IsNullOrWhiteSpace(variableDefineName.textBox1.Text) == false || string.IsNullOrEmpty(variableDefineName.comboBox1.Text) == false)
                            {
                                vList.Add(variableDefineName.textBox1.Text);
                            }
                        }
                    }
                    else if (OrderControls[i].GetType().Equals(typeof(ArrayDefine)))
                    {
                        ArrayDefine arrayDefineName = (ArrayDefine)OrderControls[i];
                        if (arrayDefineName.arrayType.SelectedIndex == 0 || arrayDefineName.arrayType.SelectedIndex == 1 || arrayDefineName.arrayType.SelectedIndex == 3 || arrayDefineName.arrayType.SelectedIndex == 4)
                        {
                            if (string.IsNullOrWhiteSpace(arrayDefineName.textBox1.Text) == false && string.IsNullOrEmpty(arrayDefineName.arrayType.Text) == false && string.IsNullOrWhiteSpace(arrayDefineName.textBox2.Text) == false)
                            {
                                for (int j = 0; j < int.Parse(arrayDefineName.textBox2.Text); j++)
                                {
                                    vList.Add(arrayDefineName.textBox1.Text + "[" + j + "]");
                                }
                            }
                        }
                    }
                }
            }
            if (Type == 4)
            {
                for (int i = 0; OrderControls[i] != MyControl; i++)
                {
                    if (OrderControls[i].GetType().Equals(typeof(VariableDefine)))
                    {
                        VariableDefine variableDefineName = (VariableDefine)OrderControls[i];
                        if (variableDefineName.comboBox1.SelectedIndex == 5)
                        {
                            if (string.IsNullOrWhiteSpace(variableDefineName.textBox1.Text) == false || string.IsNullOrEmpty(variableDefineName.comboBox1.Text) == false)
                            {
                                vList.Add(variableDefineName.textBox1.Text);
                            }
                        }
                    }
                    else if (OrderControls[i].GetType().Equals(typeof(ArrayDefine)))
                    {
                        ArrayDefine arrayDefineName = (ArrayDefine)OrderControls[i];
                        if (arrayDefineName.arrayType.SelectedIndex == 5)
                        {
                            if (string.IsNullOrWhiteSpace(arrayDefineName.textBox1.Text) == false && string.IsNullOrEmpty(arrayDefineName.arrayType.Text) == false && string.IsNullOrWhiteSpace(arrayDefineName.textBox2.Text) == false)
                            {
                                for (int j = 0; j < int.Parse(arrayDefineName.textBox2.Text); j++)
                                {
                                    vList.Add(arrayDefineName.textBox1.Text + "[" + j + "]");
                                }
                            }
                        }
                    }
                }
            }
            if (Type == 5)
            {
                for (int i = 0; OrderControls[i] != MyControl; i++)
                {
                    if (OrderControls[i].GetType().Equals(typeof(VariableDefine)))
                    {
                        VariableDefine variableDefineName = (VariableDefine)OrderControls[i];
                        if (variableDefineName.comboBox1.SelectedIndex == 0)
                        {
                            if (string.IsNullOrWhiteSpace(variableDefineName.textBox1.Text) == false || string.IsNullOrEmpty(variableDefineName.comboBox1.Text) == false)
                            {
                                vList.Add(variableDefineName.textBox1.Text);
                            }
                        }
                    }
                    else if (OrderControls[i].GetType().Equals(typeof(ArrayDefine)))
                    {
                        ArrayDefine arrayDefineName = (ArrayDefine)OrderControls[i];
                        if (arrayDefineName.arrayType.SelectedIndex == 0)
                        {
                            if (string.IsNullOrWhiteSpace(arrayDefineName.textBox1.Text) == false && string.IsNullOrEmpty(arrayDefineName.arrayType.Text) == false && string.IsNullOrWhiteSpace(arrayDefineName.textBox2.Text) == false)
                            {
                                for (int j = 0; j < int.Parse(arrayDefineName.textBox2.Text); j++)
                                {
                                    vList.Add(arrayDefineName.textBox1.Text + "[" + j + "]");
                                }
                            }
                        }
                    }
                }
            }
            if (Type == 10)
            {
                for (int i = 0; OrderControls[i] != MyControl; i++)
                {
                    if (OrderControls[i].GetType().Equals(typeof(VariableDefine)))
                    {
                        VariableDefine variableDefineName = (VariableDefine)OrderControls[i];
                        if (variableDefineName.comboBox1.SelectedIndex == 0)
                        {
                            if (string.IsNullOrWhiteSpace(variableDefineName.textBox1.Text) == false || string.IsNullOrEmpty(variableDefineName.comboBox1.Text) == false)
                            {
                                vList.Add(variableDefineName.textBox1.Text);
                            }
                        }
                    }
                    else if (OrderControls[i].GetType().Equals(typeof(ArrayDefine)))
                    {
                        ArrayDefine arrayDefineName = (ArrayDefine)OrderControls[i];
                        if (arrayDefineName.arrayType.SelectedIndex == 0)
                        {
                            if (string.IsNullOrWhiteSpace(arrayDefineName.textBox1.Text) == false && string.IsNullOrEmpty(arrayDefineName.arrayType.Text) == false && string.IsNullOrWhiteSpace(arrayDefineName.textBox2.Text) == false)
                            {
                                for (int j = 0; j < int.Parse(arrayDefineName.textBox2.Text); j++)
                                {
                                    vList.Add(arrayDefineName.textBox1.Text + "[" + j + "]");
                                }
                            }
                        }
                    }
                }
            }
            if (Type == 11)
            {
                for (int i = 0; OrderControls[i] != MyControl; i++)
                {
                    if (OrderControls[i].GetType().Equals(typeof(VariableDefine)))
                    {
                        VariableDefine variableDefineName = (VariableDefine)OrderControls[i];
                        if (variableDefineName.comboBox1.SelectedIndex == 1)
                        {
                            if (string.IsNullOrWhiteSpace(variableDefineName.textBox1.Text) == false || string.IsNullOrEmpty(variableDefineName.comboBox1.Text) == false)
                            {
                                vList.Add(variableDefineName.textBox1.Text);
                            }
                        }
                    }
                    else if (OrderControls[i].GetType().Equals(typeof(ArrayDefine)))
                    {
                        ArrayDefine arrayDefineName = (ArrayDefine)OrderControls[i];
                        if (arrayDefineName.arrayType.SelectedIndex == 1)
                        {
                            if (string.IsNullOrWhiteSpace(arrayDefineName.textBox1.Text) == false && string.IsNullOrEmpty(arrayDefineName.arrayType.Text) == false && string.IsNullOrWhiteSpace(arrayDefineName.textBox2.Text) == false)
                            {
                                for (int j = 0; j < int.Parse(arrayDefineName.textBox2.Text); j++)
                                {
                                    vList.Add(arrayDefineName.textBox1.Text + "[" + j + "]");
                                }
                            }
                        }
                    }
                }
            }
            if (Type == 12)
            {
                for (int i = 0; OrderControls[i] != MyControl; i++)
                {
                    if (OrderControls[i].GetType().Equals(typeof(VariableDefine)))
                    {
                        VariableDefine variableDefineName = (VariableDefine)OrderControls[i];
                        if (variableDefineName.comboBox1.SelectedIndex == 2)
                        {
                            if (string.IsNullOrWhiteSpace(variableDefineName.textBox1.Text) == false || string.IsNullOrEmpty(variableDefineName.comboBox1.Text) == false)
                            {
                                vList.Add(variableDefineName.textBox1.Text);
                            }
                        }
                    }
                    else if (OrderControls[i].GetType().Equals(typeof(ArrayDefine)))
                    {
                        ArrayDefine arrayDefineName = (ArrayDefine)OrderControls[i];
                        if (arrayDefineName.arrayType.SelectedIndex == 2)
                        {
                            if (string.IsNullOrWhiteSpace(arrayDefineName.textBox1.Text) == false && string.IsNullOrEmpty(arrayDefineName.arrayType.Text) == false && string.IsNullOrWhiteSpace(arrayDefineName.textBox2.Text) == false)
                            {
                                for (int j = 0; j < int.Parse(arrayDefineName.textBox2.Text); j++)
                                {
                                    vList.Add(arrayDefineName.textBox1.Text + "[" + j + "]");
                                }
                            }
                        }
                    }
                }
            }
            if (Type == 13)
            {
                for (int i = 0; OrderControls[i] != MyControl; i++)
                {
                    if (OrderControls[i].GetType().Equals(typeof(VariableDefine)))
                    {
                        VariableDefine variableDefineName = (VariableDefine)OrderControls[i];
                        if (variableDefineName.comboBox1.SelectedIndex == 3)
                        {
                            if (string.IsNullOrWhiteSpace(variableDefineName.textBox1.Text) == false || string.IsNullOrEmpty(variableDefineName.comboBox1.Text) == false)
                            {
                                vList.Add(variableDefineName.textBox1.Text);
                            }
                        }
                    }
                    else if (OrderControls[i].GetType().Equals(typeof(ArrayDefine)))
                    {
                        ArrayDefine arrayDefineName = (ArrayDefine)OrderControls[i];
                        if (arrayDefineName.arrayType.SelectedIndex == 3)
                        {
                            if (string.IsNullOrWhiteSpace(arrayDefineName.textBox1.Text) == false && string.IsNullOrEmpty(arrayDefineName.arrayType.Text) == false && string.IsNullOrWhiteSpace(arrayDefineName.textBox2.Text) == false)
                            {
                                for (int j = 0; j < int.Parse(arrayDefineName.textBox2.Text); j++)
                                {
                                    vList.Add(arrayDefineName.textBox1.Text + "[" + j + "]");
                                }
                            }
                        }
                    }
                }
            }
            if (Type == 14)
            {
                for (int i = 0; OrderControls[i] != MyControl; i++)
                {
                    if (OrderControls[i].GetType().Equals(typeof(VariableDefine)))
                    {
                        VariableDefine variableDefineName = (VariableDefine)OrderControls[i];
                        if (variableDefineName.comboBox1.SelectedIndex == 4)
                        {
                            if (string.IsNullOrWhiteSpace(variableDefineName.textBox1.Text) == false || string.IsNullOrEmpty(variableDefineName.comboBox1.Text) == false)
                            {
                                vList.Add(variableDefineName.textBox1.Text);
                            }
                        }
                    }
                    else if (OrderControls[i].GetType().Equals(typeof(ArrayDefine)))
                    {
                        ArrayDefine arrayDefineName = (ArrayDefine)OrderControls[i];
                        if (arrayDefineName.arrayType.SelectedIndex == 4)
                        {
                            if (string.IsNullOrWhiteSpace(arrayDefineName.textBox1.Text) == false && string.IsNullOrEmpty(arrayDefineName.arrayType.Text) == false && string.IsNullOrWhiteSpace(arrayDefineName.textBox2.Text) == false)
                            {
                                for (int j = 0; j < int.Parse(arrayDefineName.textBox2.Text); j++)
                                {
                                    vList.Add(arrayDefineName.textBox1.Text + "[" + j + "]");
                                }
                            }
                        }
                    }
                }
                if (Type == 15)
                {
                    for (int i = 0; OrderControls[i] != MyControl; i++)
                    {
                        if (OrderControls[i].GetType().Equals(typeof(VariableDefine)))
                        {
                            VariableDefine variableDefineName = (VariableDefine)OrderControls[i];
                            if (variableDefineName.comboBox1.SelectedIndex == 5)
                            {
                                if (string.IsNullOrWhiteSpace(variableDefineName.textBox1.Text) == false || string.IsNullOrEmpty(variableDefineName.comboBox1.Text) == false)
                                {
                                    vList.Add(variableDefineName.textBox1.Text);
                                }
                            }
                        }
                        else if (OrderControls[i].GetType().Equals(typeof(ArrayDefine)))
                        {
                            ArrayDefine arrayDefineName = (ArrayDefine)OrderControls[i];
                            if (arrayDefineName.arrayType.SelectedIndex == 5)
                            {
                                if (string.IsNullOrWhiteSpace(arrayDefineName.textBox1.Text) == false && string.IsNullOrEmpty(arrayDefineName.arrayType.Text) == false && string.IsNullOrWhiteSpace(arrayDefineName.textBox2.Text) == false)
                                {
                                    for (int j = 0; j < int.Parse(arrayDefineName.textBox2.Text); j++)
                                    {
                                        vList.Add(arrayDefineName.textBox1.Text + "[" + j + "]");
                                    }
                                }
                            }
                        }
                    }
                }
            }

            if (MyParent.Parent is StatementBase)
            {
                vList.AddRange(GetVariableList(MyParent.Parent, Type));
            }

            return(vList);
        }