コード例 #1
0
        // 全局变量保存
        private void button1_Click(object sender, EventArgs e)
        {
            // 处理参数列表
            List <string> argvList = new List <string>();
            int           nrows    = this.globalvarDataGridView.Rows.Count - 1;

            for (int i = 0; i < nrows; i++)
            {
                string varname = this.globalvarDataGridView.Rows[i].Cells[0].Value.ToString();
                // 类型不能为空
                if (this.globalvarDataGridView.Rows[i].Cells[1].Value == null)
                {
                    MessageBox.Show(String.Format("变量 {0} 类型不合法", varname), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                string vartype = this.globalvarDataGridView.Rows[i].Cells[1].Value.ToString();
                // 符号合法性
                if (Consta.IsStdCSymbol(varname) == false)
                {
                    MessageBox.Show(String.Format("变量 {0} 命名不合法", varname), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                // 符号唯一性
                if (argvList.Find((x) => x.Split('@')[0] == varname) != null)
                {
                    MessageBox.Show(String.Format("变量名 {0} 重复", varname), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                // 类型合法性
                if (Consta.basicType.Find((x) => x == vartype) == null)
                {
                    MessageBox.Show(String.Format("变量 {0} 类型不合法", varname), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                argvList.Add(String.Format("{0}@{1}", varname, vartype));
            }
            // 把更改提交给后台
            core.setNewGlobalVar(argvList);
            // 刷新主窗体
            ((MainForm)this.Owner).globalvarListBox.Items.Clear();
            foreach (string s in core.getGlobalVar())
            {
                ((MainForm)this.Owner).globalvarListBox.Items.Add((string)s.Replace("@", " @ "));
            }
        }
コード例 #2
0
ファイル: BasicInputForm.cs プロジェクト: trigrass2/KagaIDE
 // 确定
 private void button1_Click(object sender, EventArgs e)
 {
     if ((comboBox1.Visible == true && comboBox1.SelectedIndex == -1) ||
         textBox1.Text == null || textBox1.Text == "")
     {
         MessageBox.Show("请完整填写", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     // 变量名合法性检查
     if (this.Text.Contains("变量") == true && Consta.IsStdCSymbol(this.textBox1.Text) == false)
     {
         MessageBox.Show(
             String.Format("变量 {0} 命名不合法", this.textBox1.Text), "错误",
             MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     ((IBasicInputForm)this.Owner).passByBasicSubForm(
         String.Format("{0}@{1}", this.textBox1.Text, this.comboBox1.SelectedItem.ToString()));
     this.Dispose();
 }
コード例 #3
0
ファイル: ConditionForm.cs プロジェクト: trigrass2/KagaIDE
        // 确定按钮
        private void button1_Click(object sender, EventArgs e)
        {
            // 正确性检查
            if (this.checkBox2.Checked == false)
            {
                if (this.radioButton2.Checked && (this.textBox1.Text == null || this.textBox1.Text == ""))
                {
                    MessageBox.Show("请完整填写");
                    return;
                }
                if (this.radioButton11.Checked && (this.textBox3.Text == null || this.textBox3.Text == ""))
                {
                    MessageBox.Show("请完整填写");
                    return;
                }
                // 符号合法性
                if (this.radioButton2.Checked && Consta.IsStdCSymbol(this.textBox1.Text) == false)
                {
                    MessageBox.Show(String.Format("变量 {0} 命名不合法", this.textBox1.Text), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (this.radioButton11.Checked && Consta.IsStdCSymbol(this.textBox3.Text) == false)
                {
                    MessageBox.Show(String.Format("变量 {0} 命名不合法", this.textBox3.Text), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            if (this.checkBox2.Checked && (this.textBox2.Text == "" || this.textBox2.Text == null))
            {
                MessageBox.Show("请完整填写");
                return;
            }
            // 处理要传递给后台的参数列表
            string condEx = this.checkBox2.Checked ? this.textBox2.Text : "";
            string lop, rop;

            switch (Lot)
            {
            case OperandType.VO_GlobalVar:
                lop = (string)this.comboBox1.Items[this.comboBox1.SelectedIndex];
                break;

            case OperandType.VO_DefVar:
                lop = this.textBox1.Text;
                break;

            case OperandType.VO_Switch:
                lop = ((string)this.comboBox3.Items[this.comboBox3.SelectedIndex]).Split(':')[0];
                break;

            default:
                lop = null;
                break;
            }
            switch (Rot)
            {
            case OperandType.VO_Constant:
                rop = Convert.ToString(this.numericUpDown1.Value);
                break;

            case OperandType.VO_GlobalVar:
                rop = (string)this.comboBox2.Items[this.comboBox2.SelectedIndex];
                break;

            case OperandType.VO_DefVar:
                rop = this.textBox3.Text;
                break;

            case OperandType.VO_Switch:
                rop = (string)this.comboBox4.Items[this.comboBox4.SelectedIndex];
                break;

            default:
                rop = null;
                break;
            }
            int laid = 0;

            for (int i = 0; i < this.groupBox2.Controls.Count;)
            {
                if (this.groupBox2.Controls[i] is RadioButton)
                {
                    if (((RadioButton)this.groupBox2.Controls[i]).Checked == true)
                    {
                        string[] sname = ((RadioButton)this.groupBox2.Controls[i]).Name.Split('n');
                        laid = Convert.ToInt32(sname[1]) - 3;
                        break;
                    }
                    i++;
                }
            }
            // 把修改提交到后台
            core.dash_condition(this.checkBox2.Checked, condEx, this.checkBox1.Checked,
                                this.Lot, lop, (CondOperatorType)laid, this.Rot, rop);
            this.Close();
        }
コード例 #4
0
ファイル: VariableForm.cs プロジェクト: trigrass2/KagaIDE
        // 确定按钮
        private void button1_Click(object sender, EventArgs e)
        {
            // 正确性检查
            if (this.radioButton2.Checked && (this.textBox1.Text == null || this.textBox1.Text == ""))
            {
                MessageBox.Show("请完整填写");
                return;
            }
            if (this.radioButton11.Checked && (this.textBox3.Text == null || this.textBox3.Text == ""))
            {
                MessageBox.Show("请完整填写");
                return;
            }
            // 符号合法性
            if (this.radioButton2.Checked && Consta.IsStdCSymbol(this.textBox1.Text) == false)
            {
                MessageBox.Show(String.Format("变量 {0} 命名不合法", this.textBox1.Text), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (this.radioButton11.Checked && Consta.IsStdCSymbol(this.textBox3.Text) == false)
            {
                MessageBox.Show(String.Format("变量 {0} 命名不合法", this.textBox3.Text), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            // 把修改提交到后台
            int laid = 0;

            for (int i = 0; i < this.groupBox2.Controls.Count;)
            {
                if (this.groupBox2.Controls[i] is RadioButton)
                {
                    if (((RadioButton)this.groupBox2.Controls[i]).Checked == true)
                    {
                        string[] sname = ((RadioButton)this.groupBox2.Controls[i]).Name.Split('n');
                        laid = Convert.ToInt32(sname[1]) - 3;
                        break;
                    }
                    i++;
                }
            }
            OperandType raid = OperandType.VO_Constant;
            string      rop1 = null, rop2 = null;

            if (this.radioButton9.Checked)
            {
                raid = OperandType.VO_Constant;
                rop1 = Convert.ToString(this.numericUpDown1.Value);
            }
            else if (this.radioButton10.Checked)
            {
                raid = OperandType.VO_GlobalVar;
                rop1 = ((string)(this.comboBox1.Items[this.comboBox1.SelectedIndex])).Split('@')[0];
            }
            else if (this.radioButton11.Checked)
            {
                raid = OperandType.VO_DefVar;
                rop1 = (string)this.textBox3.Text;
            }
            else if (this.radioButton12.Checked)
            {
                raid = OperandType.VO_Random;
                rop1 = Convert.ToString(this.numericUpDown2.Value);
                rop2 = Convert.ToString(this.numericUpDown3.Value);
            }
            core.dash_varOperator(
                (OperandType)(this.radioButton1.Checked ? OperandType.VO_GlobalVar : OperandType.VO_DefVar),
                this.radioButton1.Checked ? (string)this.comboBox1.Text.Split('@')[0] : this.textBox1.Text,
                (VarOperateType)(laid), raid, rop1, rop2);
            this.Close();
        }
コード例 #5
0
        // 确定或应用
        private void button1_Click(object sender, EventArgs e)
        {
            // 处理参数列表
            List <string> argvList = new List <string>();
            int           nrows    = this.argsGridDataView.Rows.Count - 1;

            for (int i = 0; i < nrows; i++)
            {
                string varname = this.argsGridDataView.Rows[i].Cells[0].Value.ToString();
                // 类型不能为空
                if (this.argsGridDataView.Rows[i].Cells[1].Value == null)
                {
                    MessageBox.Show(String.Format("变量 {0} 类型不合法", varname), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                string vartype = this.argsGridDataView.Rows[i].Cells[1].Value.ToString();
                // 符号合法性
                if (Consta.IsStdCSymbol(varname) == false)
                {
                    MessageBox.Show(String.Format("变量 {0} 命名不合法", varname), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                // 符号唯一性
                if (argvList.Find((x) => x.Split('@')[0] == varname) != null)
                {
                    MessageBox.Show(String.Format("变量名 {0} 重复", varname), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                // 类型合法性
                if (Consta.basicType.Find((x) => x == vartype) == null)
                {
                    MessageBox.Show(String.Format("变量 {0} 类型不合法", varname), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                argvList.Add(String.Format("{0}@{1}", varname, vartype));
            }
            // 处理函数头部
            string callname = this.textBox1.Text;

            if (Consta.IsStdCSymbol(callname) == false)
            {
                MessageBox.Show(String.Format("函数命名不合法"), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            // 处理返回类型
            string rettype = (string)this.comboBox1.SelectedItem;

            // 如果是新建函数
            if (this.Text == "新建函数")
            {
                // 通过控制器传递给后台
                bool flag = core.addFunction(callname, argvList, rettype);
                // 重名错误时
                if (flag == false)
                {
                    MessageBox.Show("函数名已经存在,\n请修改函数名!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                // 刷新前台
                MainForm father = (MainForm)this.Owner;
                father.functionListBox.Items.Add(callname);
                father.addTabCard(callname);
                this.Close();
            }
            else if (this.Text == "从管理器新建函数")
            {
                // 通过控制器传递给后台
                bool flag = core.addFunction(callname, argvList, rettype);
                // 重名错误时
                if (flag == false)
                {
                    MessageBox.Show("函数名已经存在,\n请修改函数名!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                // 刷新前台
                SymbolForm parentForm = (SymbolForm)this.Owner;
                parentForm.funListBox.Items.Add(callname);
                parentForm.funListBox.SelectedItem = callname;
                MainForm father = (MainForm)(parentForm.Owner);
                father.functionListBox.Items.Add(callname);
                father.addTabCard(callname);
                this.Close();
            }
            // 如果是编辑函数
            else
            {
                // 通过控制器传递给后台
                bool flag = core.editFunction(this.oldfcname, callname, argvList, rettype);
                // 重名错误时
                if (flag == false)
                {
                    MessageBox.Show("函数名已经存在,\n请修改函数名!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                // 刷新前台
                if (this.Text == "编辑函数")
                {
                    MainForm father = (MainForm)(this.Owner);
                    father.closeTabCard(this.oldfcname);
                    father.functionListBox.Items.Remove(this.oldfcname);
                    father.functionListBox.Items.Add(callname);
                    father.addTabCard(callname);
                    this.Close();
                }
                else if (this.Text == "管理函数")
                {
                    if (this.mainFormRef != null)
                    {
                        this.mainFormRef.tabControl1.TabPages[this.oldfcname].Text = callname;
                        this.mainFormRef.tabControl1.TabPages[this.oldfcname].Name = callname;
                        int flid = this.mainFormRef.functionListBox.Items.IndexOf(this.oldfcname);
                        this.mainFormRef.functionListBox.Items[flid] = callname;
                        SymbolForm ownSf = (SymbolForm)this.symbolFormRef;
                        ownSf.funListBox.Items.Clear();
                        List <string> funList = core.getAllFunction();
                        foreach (string s in funList)
                        {
                            ownSf.funListBox.Items.Add(s);
                        }
                        flid = ownSf.funListBox.Items.IndexOf(callname);
                        ownSf.funListBox.SelectedIndex = flid;
                        this.refreshContext(callname);
                    }
                }
            }
        }