private void button_OK_Click(object sender, EventArgs e)
 {
     if (element != null)
     {
         for (int i = 0; i < manager.getElementCount(); i++)
         {
             FunctionElement elementExist = (FunctionElement)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.commet = textBox_Commet.Text;
         ArrayList paramsList      = new ArrayList();
         ArrayList paramsValue     = new ArrayList();
         ArrayList paramsValueRest = new ArrayList();
         for (int i = 0; i < (int)numericUpDown_Value.Value; i++)
         {
             paramsList.Add((byte)(((ComboBox)FLP_params.Controls[i]).SelectedIndex));
         }
         for (int i = 0; i < (int)numericUpDown_Value.Value; i++)
         {
             if (FLP_defValue.Controls[i] is NumericUpDown)
             {
                 paramsValue.Add((int)(((NumericUpDown)FLP_defValue.Controls[i]).Value));
             }
             else if (FLP_defValue.Controls[i] is ComboBox)
             {
                 paramsValue.Add((int)(((ComboBox)FLP_defValue.Controls[i]).SelectedIndex));
             }
             else
             {
                 paramsValue.Add(0);
                 MessageBox.Show("格式错误");
             }
         }
         for (int i = 0; i < (int)numericUpDown_Value.Value; i++)
         {
             paramsValueRest.Add((bool)(((CheckBox)FLP_Modify.Controls[i]).Checked));
         }
         if (beUsedTime == 0)
         {
             element.setValue(paramsList);
         }
         else if (beUsedTime > 0)
         {
             if (checkBox_Modify.Checked)
             {
                 element.configValue(paramsList, paramsValue, paramsValueRest);
             }
         }
     }
     this.Close();
 }
Example #2
0
 //生成函数体
 private void genFunctionToHead(FileStream fs, FunctionsManager functionManager)
 {
     for (int i = 0; i < functionManager.getElementCount(); i++)
     {
         FunctionElement fun       = (FunctionElement)functionManager.getElement(i);
         String          strParams = " (";
         ArrayList       paramList = (ArrayList)fun.getValue();
         for (int j = 0; j < paramList.Count; j++)
         {
             strParams += "p" + j;
             if (j < paramList.Count - 1)
             {
                 strParams += ",";
             }
         }
         strParams += ");";
         IOUtil.writeTextLine(fs, "host " + fun.name + strParams);
     }
 }