public static VarElement createElement(VarsManager managerT)
        {
            manager = managerT;
            element = new VarElement(manager, Consts.PARAM_STR);
            SmallDialog_NewVar_String dialog = new SmallDialog_NewVar_String("新建字符变量");

            dialog.ShowDialog();
            return(element);
        }
Example #2
0
        public static VarElement createElement(VarsManager managerT)
        {
            manager = managerT;
            element = new VarElement(manager, Consts.PARAM_INT);
            SmallDialog_NewVar_INT dialog = new SmallDialog_NewVar_INT("新建整型变量");

            dialog.ShowDialog();
            return(element);
        }
        //设置地图单元
        public static void configElement(VarElement elementT)
        {
            if (elementT == null)
            {
                Console.WriteLine("error in configElement");
                return;
            }
            manager = (VarsManager)elementT.parent;
            element = elementT;
            SmallDialog_NewVar_String dialog = new SmallDialog_NewVar_String("设置字符变量");

            dialog.textBox_name.Text  = element.name;
            dialog.textBox_Value.Text = (String)element.getValue();
            dialog.ShowDialog();
        }
Example #4
0
        //设置地图单元
        public static void configElement(VarElement elementT)
        {
            if (elementT == null)
            {
                Console.WriteLine("error in configElement");
                return;
            }
            manager = (VarsManager)elementT.parent;
            element = elementT;
            SmallDialog_NewVar_INT dialog = new SmallDialog_NewVar_INT("设置整型变量");

            dialog.textBox_name.Text         = element.name;
            dialog.numericUpDown_Value.Value = (int)element.getValue();
            dialog.ShowDialog();
        }
Example #5
0
 //增加单元
 private void addElement()
 {
     if (tabControl_Lists.SelectedIndex == 0)//增加整型单元
     {
         VarElement element = SmallDialog_NewVar_INT.createElement(form_main.varIntManager);
         if (element != null)
         {
             form_main.varIntManager.addElement(element);
         }
     }
     if (tabControl_Lists.SelectedIndex == 1)//增加字符单元
     {
         VarElement element = SmallDialog_NewVar_String.createElement(form_main.varStringManager);
         if (element != null)
         {
             form_main.varStringManager.addElement(element);
         }
     }
     if (tabControl_Lists.SelectedIndex == 2)//增加触发器函数单元
     {
         FunctionElement element = SmallDialog_FunctionsConfig.createElement(form_main.triggerFunctionManager, "新建触发函数单元");
         if (element != null)
         {
             form_main.triggerFunctionManager.addElement(element);
         }
     }
     if (tabControl_Lists.SelectedIndex == 3)//增加环境函数单元
     {
         FunctionElement element = SmallDialog_FunctionsConfig.createElement(form_main.contextFunctionManager, "新建环境函数单元");
         if (element != null)
         {
             form_main.contextFunctionManager.addElement(element);
         }
     }
     if (tabControl_Lists.SelectedIndex == 4)//增加执行函数单元
     {
         FunctionElement element = SmallDialog_FunctionsConfig.createElement(form_main.executionFunctionManager, "新建执行函数单元");
         if (element != null)
         {
             form_main.executionFunctionManager.addElement(element);
         }
     }
 }
 private void button_OK_Click(object sender, EventArgs e)
 {
     if (element != null)
     {
         for (int i = 0; i < manager.getElementCount(); i++)
         {
             VarElement elementExist = (VarElement)manager.getElement(i);
             if (elementExist.Equals(element))
             {
                 continue;
             }
             if (elementExist.name.Equals(textBox_name.Text))
             {
                 MessageBox.Show("存在相同的单元名称!", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 return;
             }
         }
         element.name = textBox_name.Text;
         element.setValue(textBox_Value.Text.Trim());
     }
     this.Close();
 }
Example #7
0
 //检查变量
 private void checkElement()
 {
     if (tabControl_Lists.SelectedIndex == 0)//检查整型单元
     {
         int currentIndex = listBox_VarInt.SelectedIndex;
         if (currentIndex >= 0)
         {
             VarElement element = (VarElement)form_main.varIntManager.getElement(currentIndex);
             if (element == null)
             {
                 return;
             }
             //String usedInfor = element.getUsedInfor();
             //SmallDialog_ShowString.showString("整型变量检查", usedInfor);
             SmallDialog_ShowList.showList(element.getUsedMeory());
         }
     }
     if (tabControl_Lists.SelectedIndex == 1)//检查字符单元
     {
         int currentIndex = listBox_VarString.SelectedIndex;
         if (currentIndex >= 0)
         {
             VarElement element = (VarElement)form_main.varStringManager.getElement(currentIndex);
             if (element == null)
             {
                 return;
             }
             //String usedInfor = element.getUsedInfor();
             //SmallDialog_ShowString.showString("字符变量检查", usedInfor);
             SmallDialog_ShowList.showList(element.getUsedMeory());
         }
     }
     if (tabControl_Lists.SelectedIndex == 2)//检查触发函数单元
     {
         int currentIndex = listBox_Trigger.SelectedIndex;
         if (currentIndex >= 0)
         {
             FunctionElement element = (FunctionElement)form_main.triggerFunctionManager.getElement(currentIndex);
             if (element == null)
             {
                 return;
             }
             //String usedInfor = element.getUsedInfor();
             //SmallDialog_ShowString.showString("触发器函数检查", usedInfor);
             SmallDialog_ShowList.showList(element.getUsedMeory());
         }
     }
     if (tabControl_Lists.SelectedIndex == 3)//检查环境函数单元
     {
         int currentIndex = listBox_Condition.SelectedIndex;
         if (currentIndex >= 0)
         {
             FunctionElement element = (FunctionElement)form_main.contextFunctionManager.getElement(currentIndex);
             if (element == null)
             {
                 return;
             }
             //String usedInfor = element.getUsedInfor();
             //SmallDialog_ShowString.showString("环境函数检查", usedInfor);
             SmallDialog_ShowList.showList(element.getUsedMeory());
         }
     }
     if (tabControl_Lists.SelectedIndex == 4)//检查执行函数单元
     {
         int currentIndex = listBox_Execution.SelectedIndex;
         if (currentIndex >= 0)
         {
             FunctionElement element = (FunctionElement)form_main.executionFunctionManager.getElement(currentIndex);
             if (element == null)
             {
                 return;
             }
             //String usedInfor = element.getUsedInfor();
             //SmallDialog_ShowString.showString("执行函数检查", usedInfor);
             SmallDialog_ShowList.showList(element.getUsedMeory());
         }
     }
 }
Example #8
0
 //删除变量
 private void deleteElement()
 {
     if (tabControl_Lists.SelectedIndex == 0)//删除整型单元
     {
         int currentIndex = listBox_VarInt.SelectedIndex;
         if (currentIndex >= 0)
         {
             VarElement element = (VarElement)form_main.varIntManager.getElement(currentIndex);
             if (element == null)
             {
                 return;
             }
             int usedTime = element.getUsedTime();
             if (usedTime > 0)
             {
                 MessageBox.Show("变量被引用了" + usedTime + "次,不能删除");
                 return;
             }
             form_main.varIntManager.removeElement(currentIndex);
         }
     }
     if (tabControl_Lists.SelectedIndex == 1)//删除字符单元
     {
         int currentIndex = listBox_VarString.SelectedIndex;
         if (currentIndex >= 0)
         {
             VarElement element = (VarElement)form_main.varStringManager.getElement(currentIndex);
             if (element == null)
             {
                 return;
             }
             int usedTime = element.getUsedTime();
             if (usedTime > 0)
             {
                 MessageBox.Show("变量被引用了" + usedTime + "次,不能删除");
                 return;
             }
             form_main.varStringManager.removeElement(currentIndex);
         }
     }
     if (tabControl_Lists.SelectedIndex == 2)//删除触发器函数单元
     {
         int currentIndex = listBox_Trigger.SelectedIndex;
         if (currentIndex >= 0)
         {
             FunctionElement element = (FunctionElement)form_main.triggerFunctionManager.getElement(currentIndex);
             if (element == null)
             {
                 return;
             }
             int usedTime = element.getUsedTime();
             if (usedTime > 0)
             {
                 MessageBox.Show("函数被引用了" + usedTime + "次,不能删除");
                 return;
             }
             form_main.triggerFunctionManager.removeElement(currentIndex);
         }
     }
     if (tabControl_Lists.SelectedIndex == 3)//删除条件判断函数单元
     {
         int currentIndex = listBox_Condition.SelectedIndex;
         if (currentIndex >= 0)
         {
             FunctionElement element = (FunctionElement)form_main.contextFunctionManager.getElement(currentIndex);
             if (element == null)
             {
                 return;
             }
             int usedTime = element.getUsedTime();
             if (usedTime > 0)
             {
                 MessageBox.Show("函数被引用了" + usedTime + "次,不能删除");
                 return;
             }
             form_main.contextFunctionManager.removeElement(currentIndex);
         }
     }
     if (tabControl_Lists.SelectedIndex == 4)//删除执行函数单元
     {
         int currentIndex = listBox_Execution.SelectedIndex;
         if (currentIndex >= 0)
         {
             FunctionElement element = (FunctionElement)form_main.executionFunctionManager.getElement(currentIndex);
             if (element == null)
             {
                 return;
             }
             int usedTime = element.getUsedTime();
             if (usedTime > 0)
             {
                 MessageBox.Show("函数被引用了" + usedTime + "次,不能删除");
                 return;
             }
             form_main.executionFunctionManager.removeElement(currentIndex);
         }
     }
 }
        //改变参数类型
        public void changeParamType(int index, int type)
        {
            if (index < 0 || index >= FLP_defValue.Controls.Count)
            {
                return;
            }
            ArrayList array = new ArrayList();

            for (int i = 0; i < FLP_defValue.Controls.Count; i++)
            {
                array.Add(FLP_defValue.Controls[i]);
            }
            //添加参数默认值i
            switch (type)
            {
            case Consts.PARAM_INT:
                NumericUpDown numericBoxI = new NumericUpDown();
                numericBoxI.Width   = LINE_WIDTH_VALUE;
                numericBoxI.Height  = LINE_HEIGHT;
                numericBoxI.Margin  = new Padding(2, 1, 2, 2);
                array[index]        = numericBoxI;
                numericBoxI.Maximum = short.MaxValue;
                numericBoxI.Minimum = short.MinValue;
                numericBoxI.Value   = 0;
                if (beUsedTime == 0 || (beUsedTime > 0 && !checkBox_Modify.Checked))
                {
                    numericBoxI.Enabled = false;
                }
                break;

            case Consts.PARAM_STR:
            case Consts.PARAM_INT_ID:
            case Consts.PARAM_INT_VAR:
            case Consts.PARAM_STR_VAR:
                ComboBox comboBoxI = new ComboBox();
                comboBoxI.Width         = LINE_WIDTH_VALUE;
                comboBoxI.Height        = LINE_HEIGHT;
                comboBoxI.Margin        = new Padding(2);
                comboBoxI.DropDownStyle = ComboBoxStyle.DropDownList;
                if (type == Consts.PARAM_INT_VAR)
                {
                    for (int j = 0; j < manager.form_main.varIntManager.getElementCount(); j++)
                    {
                        VarElement var = (VarElement)manager.form_main.varIntManager.getElement(j);
                        comboBoxI.Items.Add(var.name);
                    }
                }
                else if (type == Consts.PARAM_STR_VAR)
                {
                    for (int j = 0; j < manager.form_main.varStringManager.getElementCount(); j++)
                    {
                        VarElement var = (VarElement)manager.form_main.varStringManager.getElement(j);
                        comboBoxI.Items.Add(var.name);
                    }
                }
                array[index] = comboBoxI;
                if (beUsedTime == 0 || (beUsedTime > 0 && !checkBox_Modify.Checked))
                {
                    comboBoxI.Enabled = false;
                }
                break;
            }
            FLP_defValue.Controls.Clear();
            for (int i = 0; i < array.Count; i++)
            {
                FLP_defValue.Controls.Add((Control)array[i]);
            }
        }
        //根据参数生成UI
        private void generateParamUI(ArrayList paramsArray, int i)
        {
            //添加参数i
            ComboBox boxI = new ComboBox();

            boxI.DropDownStyle = ComboBoxStyle.DropDownList;
            for (byte j = Consts.PARAM_INT; j <= Consts.PARAM_INT_ID; j++)
            {
                boxI.Items.Add(Consts.getParamType(j));
            }
            boxI.Width  = LINE_WIDTH;
            boxI.Height = LINE_HEIGHT;
            boxI.Margin = new Padding(2);
            FLP_params.Controls.Add(boxI);
            int type = Consts.PARAM_INT;

            if (i >= 0 && i < paramsArray.Count)
            {
                boxI.SelectedIndex = (byte)paramsArray[i];
                type = ((byte)paramsArray[i]) + Consts.PARAM_INT;
            }
            else
            {
                boxI.SelectedIndex = 0;
            }
            boxI.SelectedIndexChanged += new EventHandler(comboBox_I_selectedIndexChanaged);

            if (beUsedTime > 0 && !checkBox_Modify.Checked)
            {
                boxI.Enabled = false;
            }
            //添加参数默认值i
            switch (type)
            {
            case Consts.PARAM_INT:
                NumericUpDown numericBoxI = new NumericUpDown();
                numericBoxI.Width  = LINE_WIDTH_VALUE;
                numericBoxI.Height = LINE_HEIGHT;
                numericBoxI.Margin = new Padding(2, 1, 2, 2);
                //numericBoxI.
                FLP_defValue.Controls.Add(numericBoxI);
                numericBoxI.Maximum = short.MaxValue;
                numericBoxI.Minimum = short.MinValue;
                numericBoxI.Value   = 0;
                if (beUsedTime == 0 || (beUsedTime > 0 && !checkBox_Modify.Checked))
                {
                    numericBoxI.Enabled = false;
                }
                break;

            case Consts.PARAM_STR:
            case Consts.PARAM_INT_ID:
            case Consts.PARAM_INT_VAR:
            case Consts.PARAM_STR_VAR:
                ComboBox comboBoxI = new ComboBox();
                comboBoxI.Width         = LINE_WIDTH_VALUE;
                comboBoxI.Height        = LINE_HEIGHT;
                comboBoxI.Margin        = new Padding(2);
                comboBoxI.DropDownStyle = ComboBoxStyle.DropDownList;
                if (type == Consts.PARAM_INT_VAR)
                {
                    for (int j = 0; j < manager.form_main.varIntManager.getElementCount(); j++)
                    {
                        VarElement var = (VarElement)manager.form_main.varIntManager.getElement(j);
                        comboBoxI.Items.Add(var.name);
                    }
                }
                else if (type == Consts.PARAM_STR_VAR)
                {
                    for (int j = 0; j < manager.form_main.varStringManager.getElementCount(); j++)
                    {
                        VarElement var = (VarElement)manager.form_main.varStringManager.getElement(j);
                        comboBoxI.Items.Add(var.name);
                    }
                }
                FLP_defValue.Controls.Add(comboBoxI);
                if (beUsedTime == 0 || (beUsedTime > 0 && !checkBox_Modify.Checked))
                {
                    comboBoxI.Enabled = false;
                }
                break;
            }
            //添加自动刷新标志i
            CheckBox checkBoxI = new CheckBox();

            checkBoxI.Text   = "置为默认值";
            checkBoxI.Height = LINE_HEIGHT;
            checkBoxI.Margin = new Padding(2, 1, 2, 2);
            if (beUsedTime == 0 || (beUsedTime > 0 && !checkBox_Modify.Checked))
            {
                checkBoxI.Enabled = false;
            }
            FLP_Modify.Controls.Add(checkBoxI);
        }