Пример #1
0
        /// <summary>
        /// 按钮:确定
        /// </summary>
        private void button1_Click(object sender, EventArgs e)
        {
            // 检查函数名
            if (this.textBox1.Text == String.Empty ||
                !Halation.IsValidVarname(this.textBox1.Text))
            {
                MessageBox.Show("请使用字母正确填写函数名", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            // 提示并行处理
            if (this.textBox1.Text.Trim().StartsWith("sync_", StringComparison.CurrentCultureIgnoreCase))
            {
                var dr = MessageBox.Show("Halation发现该函数名以 sync_ 开头,这将使引擎以并行处理的方式执行该函数,你确定要这么做吗?", "并行提示",
                                         MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2);
                if (dr == DialogResult.No)
                {
                    return;
                }
            }
            // 处理参数列表
            List <string> argvList = new List <string>();
            int           nrows    = this.argsGridDataView.Rows.Count - 1;

            for (int i = 0; i < nrows; i++)
            {
                var tvarname = this.argsGridDataView.Rows[i].Cells[0].Value;
                if (tvarname == null)
                {
                    continue;
                }
                string varname = tvarname.ToString();
                // 符号合法性
                if (Halation.IsValidVarname(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;
                }
                argvList.Add(varname);
            }
            core.DashAddFunction(this.textBox1.Text.Trim(), argvList);
            this.Close();
        }
Пример #2
0
 /// <summary>
 /// 按钮:确定
 /// </summary>
 private void button1_Click(object sender, EventArgs e)
 {
     if (this.textBox1.Text == String.Empty)
     {
         MessageBox.Show(@"请填写标签");
         return;
     }
     if (!Halation.IsValidVarname(this.textBox1.Text) && this.textBox1.Text != @"~finalizer")
     {
         MessageBox.Show(@"标签名只能是由下划线、数字和字母组成,并且不能以数字开头。");
         return;
     }
     if (this.isEditing)
     {
         Halation.GetInstance().DashEditLabel(this.textBox1.Text);
     }
     else
     {
         Halation.GetInstance().DashLabel(this.textBox1.Text);
     }
     this.Close();
 }
Пример #3
0
        /// <summary>
        /// 按钮:确定
        /// </summary>
        private void button1_Click(object sender, EventArgs e)
        {
            // 处理条件表达
            string op1, op2, opr, expr;

            if (this.checkBox2.Checked)
            {
                if (this.textBox2.Text == String.Empty)
                {
                    MessageBox.Show("请填写表达式");
                    return;
                }
                expr = this.textBox2.Text;
                op1  = op2 = opr = String.Empty;
            }
            else
            {
                // 处理操作数1
                if (this.radioButton1.Checked)
                {
                    if (!Halation.IsValidVarname(this.textBox4.Text))
                    {
                        MessageBox.Show("操作数A变量名不合法");
                        return;
                    }
                    op1 = "1#" + this.textBox4.Text;
                }
                else if (this.radioButton2.Checked)
                {
                    if (!Halation.IsValidVarname(this.textBox1.Text))
                    {
                        MessageBox.Show("操作数A变量名不合法");
                        return;
                    }
                    op1 = "2#" + this.textBox1.Text;
                }
                else if (this.radioButton15.Checked)
                {
                    if (!Halation.IsValidVarname(this.textBox7.Text))
                    {
                        MessageBox.Show("操作数A变量名不合法");
                        return;
                    }
                    op1 = "0#" + this.textBox7.Text;
                }
                else
                {
                    op1 = "3#" + (Convert.ToInt32(this.comboBox3.SelectedItem.ToString().Split(':')[0])).ToString();
                }
                // 处理操作符号
                if (this.radioButton3.Checked)
                {
                    opr = "==";
                }
                else if (this.radioButton4.Checked)
                {
                    opr = "<>";
                }
                else if (this.radioButton5.Checked)
                {
                    opr = ">";
                }
                else if (this.radioButton6.Checked)
                {
                    opr = "<";
                }
                else if (this.radioButton7.Checked)
                {
                    opr = ">=";
                }
                else
                {
                    opr = "<=";
                }
                // 处理操作数2
                if (this.radioButton9.Checked)
                {
                    op2 = "1#" + this.numericUpDown1.Value.ToString();
                }
                else if (this.radioButton14.Checked)
                {
                    op2 = "2#" + this.textBox6.Text.Replace('#', ' ');
                }
                else if (this.radioButton10.Checked)
                {
                    if (!Halation.IsValidVarname(this.textBox5.Text))
                    {
                        MessageBox.Show("操作数A变量名不合法");
                        return;
                    }
                    op2 = "3#" + this.textBox5.Text;
                }
                else if (this.radioButton11.Checked)
                {
                    if (!Halation.IsValidVarname(this.textBox3.Text))
                    {
                        MessageBox.Show("操作数A变量名不合法");
                        return;
                    }
                    op2 = "4#" + this.textBox3.Text;
                }
                else if (this.radioButton16.Checked)
                {
                    if (!Halation.IsValidVarname(this.textBox8.Text))
                    {
                        MessageBox.Show("操作数A变量名不合法");
                        return;
                    }
                    op2 = "0#" + this.textBox8.Text;
                }
                else
                {
                    op2 = "5#" + this.comboBox4.SelectedItem.ToString();
                }
                expr = String.Empty;
            }
            if (this.isEditing)
            {
                Halation.GetInstance().DashEditIf(this.checkBox1.Checked, expr, op1, opr, op2);
            }
            else
            {
                Halation.GetInstance().DashIf(this.checkBox1.Checked, expr, op1, opr, op2);
            }
            this.Close();
        }
Пример #4
0
        /// <summary>
        /// 按钮:确定
        /// </summary>
        private void button1_Click(object sender, EventArgs e)
        {
            // 处理左值
            string leftOp;

            if (this.radioButton1.Checked)
            {
                if (!Halation.IsValidVarname(this.textBox1.Text))
                {
                    MessageBox.Show(@"变量名不合法");
                    return;
                }
                leftOp = "&" + this.textBox1.Text;
            }
            else if (this.radioButton14.Checked)
            {
                if (!Halation.IsValidVarname(this.textBox7.Text))
                {
                    MessageBox.Show(@"变量名不合法");
                    return;
                }
                leftOp = "%" + this.textBox7.Text;
            }
            else
            {
                if (!Halation.IsValidVarname(this.textBox2.Text))
                {
                    MessageBox.Show(@"变量名不合法");
                    return;
                }
                leftOp = "$" + this.textBox2.Text;
            }
            // 处理操作符
            string opr;

            if (this.radioButton3.Checked)
            {
                opr = "=";
            }
            else if (this.radioButton4.Checked)
            {
                opr = "+=";
            }
            else if (this.radioButton5.Checked)
            {
                opr = "-=";
            }
            else if (this.radioButton6.Checked)
            {
                opr = "*=";
            }
            else
            {
                opr = "/=";
            }
            // 处理右值
            string rightOp;

            if (this.radioButton9.Checked)
            {
                rightOp = String.Format("1#{0}", this.numericUpDown1.Value);
            }
            else if (this.radioButton8.Checked)
            {
                rightOp = String.Format("2#{0}", this.textBox5.Text.Replace('#', ' '));
            }
            else if (this.radioButton10.Checked)
            {
                if (!Halation.IsValidVarname(this.textBox3.Text))
                {
                    MessageBox.Show(@"变量名不合法");
                    return;
                }
                rightOp = String.Format("3#{0}", this.textBox3.Text);
            }
            else if (this.radioButton11.Checked)
            {
                if (!Halation.IsValidVarname(this.textBox4.Text))
                {
                    MessageBox.Show(@"变量名不合法");
                    return;
                }
                rightOp = String.Format("4#{0}", this.textBox4.Text);
            }
            else if (this.radioButton12.Checked)
            {
                rightOp = String.Format("5#{0}:{1}", this.numericUpDown2.Value, this.numericUpDown3.Value);
            }
            else if (this.radioButton15.Checked)
            {
                rightOp = String.Format("0#{0}", this.textBox8.Text);
            }
            else
            {
                rightOp = String.Format("6#{0}", this.textBox6.Text);
            }
            // 除0检查
            if (opr == "/=" && rightOp == "1#0")
            {
                MessageBox.Show(@"0不可以作为除数");
                return;
            }
            // 提交到后台
            if (this.isEditing)
            {
                Halation.GetInstance().DashEditVar(leftOp, opr, rightOp);
            }
            else
            {
                Halation.GetInstance().DashVar(leftOp, opr, rightOp);
            }
            this.Close();
        }