Exemple #1
0
        /// <summary>
        /// 在表达式末尾添加函数
        /// </summary>
        /// <param name="sender">事件发送者</param>
        /// <param name="e">事件参数</param>
        private void AddFunctionAtEnd(object sender, EventArgs e)
        {
            FunctionEditForm eForm = new FunctionEditForm(conn);

            if (eForm.ShowDialog() == DialogResult.OK)
            {
                int    index          = richTextBox1.SelectionStart;
                string content        = richTextBox1.Text;
                string functionString = eForm.Value;

                content = content.Insert(index + 1, functionString);
                if (CheckExpressionValid(content))
                {
                    richTextBox1.ForeColor = Color.Black;
                }
                else
                {
                    richTextBox1.ForeColor = Color.Red;
                }

                richTextBox1.Text            = content;
                lastSelectionStart           = index + 1;
                lastSelectionLength          = functionString.Length;
                richTextBox1.SelectionStart  = index + 1;
                richTextBox1.SelectionLength = functionString.Length;
            }
        }
Exemple #2
0
        /// <summary>
        /// 编辑方法
        /// </summary>
        /// <param name="sender">事件发送者</param>
        /// <param name="e">事件参数</param>
        private void EditFunction(object sender, EventArgs e)
        {
            FunctionEditForm eForm = new FunctionEditForm(conn);

            if (eForm.ShowDialog() == DialogResult.OK)
            {
                int    index          = richTextBox1.SelectionStart;
                string content        = richTextBox1.Text;
                string functionString = eForm.Value;

                if (richTextBox1.SelectedText == "") // 添加函数
                {
                    content = content.Insert(index, functionString);
                }
                else // 编辑函数
                {
                    content = content.Remove(index, richTextBox1.SelectedText.Length);
                    content = content.Insert(index, functionString);
                }

                if (CheckExpressionValid(content))
                {
                    richTextBox1.ForeColor = Color.Black;
                }
                else
                {
                    richTextBox1.ForeColor = Color.Red;
                }

                richTextBox1.Text            = content;
                lastSelectionStart           = index;
                lastSelectionLength          = functionString.Length;
                richTextBox1.SelectionStart  = index;
                richTextBox1.SelectionLength = functionString.Length;
            }
        }
Exemple #3
0
        /// <summary>
        /// 在表达式末尾添加函数
        /// </summary>
        /// <param name="sender">事件发送者</param>
        /// <param name="e">事件参数</param>
        private void AddFunctionAtEnd(object sender, EventArgs e)
        {
            FunctionEditForm eForm = new FunctionEditForm(conn);
            if (eForm.ShowDialog() == DialogResult.OK)
            {
                int index = richTextBox1.SelectionStart;
                string content = richTextBox1.Text;
                string functionString = eForm.Value;

                content = content.Insert(index + 1, functionString);
                if (CheckExpressionValid(content))
                {
                    richTextBox1.ForeColor = Color.Black;
                }
                else
                {
                    richTextBox1.ForeColor = Color.Red;
                }

                richTextBox1.Text = content;
                lastSelectionStart = index + 1;
                lastSelectionLength = functionString.Length;
                richTextBox1.SelectionStart = index + 1;
                richTextBox1.SelectionLength = functionString.Length;                
            }
        }
Exemple #4
0
        /// <summary>
        /// 编辑方法
        /// </summary>
        /// <param name="sender">事件发送者</param>
        /// <param name="e">事件参数</param>
        private void EditFunction(object sender, EventArgs e)
        {
            FunctionEditForm eForm = new FunctionEditForm(conn);
            if(eForm.ShowDialog() == DialogResult.OK)
            {
                int index = richTextBox1.SelectionStart;
                string content = richTextBox1.Text;
                string functionString = eForm.Value;

                if(richTextBox1.SelectedText == "") // 添加函数
                {
                    content = content.Insert(index, functionString);                    
                }
                else // 编辑函数
                {
                    content = content.Remove(index, richTextBox1.SelectedText.Length);
                    content = content.Insert(index, functionString);                    
                }

                if (CheckExpressionValid(content))
                {
                    richTextBox1.ForeColor = Color.Black;
                }
                else
                {
                    richTextBox1.ForeColor = Color.Red;
                }

                richTextBox1.Text = content;
                lastSelectionStart = index;
                lastSelectionLength = functionString.Length;
                richTextBox1.SelectionStart = index;
                richTextBox1.SelectionLength = functionString.Length;
            }
        }