Пример #1
0
        private void FFunction_Click(object sender, EventArgs e)
        {
            string tail  = HandleEquation.GetLastUnit(equation);
            string tail2 = HandleEquation.GetLastUnit(richTxtEquation.Text);

            switch (((ToolStripMenuItem)sender).Name)
            {
            case "toolStripMenuItemAbs":
                if (tail2[0] == '|')
                {
                    break;                          //已经添加过绝对值符,不再添加
                }
                equation             = HandleEquation.RemoveLastUnit(equation) + "abs(" + tail + ")";
                richTxtEquation.Text = HandleEquation.RemoveLastUnit(richTxtEquation.Text) + "|" + tail2 + "|";
                break;

            case "toolStripMenuItemFloor":
                equation             = HandleEquation.RemoveLastUnit(equation) + "floor(" + tail + ")";
                richTxtEquation.Text = HandleEquation.RemoveLastUnit(richTxtEquation.Text) + "⌊" + tail2 + "⌋";
                break;

            case "toolStripMenuItemCeil":
                equation             = HandleEquation.RemoveLastUnit(equation) + "ceil(" + tail + ")";
                richTxtEquation.Text = HandleEquation.RemoveLastUnit(richTxtEquation.Text) + "⌈" + tail2 + "⌉";
                break;

            default:
                break;
            }
        }
Пример #2
0
        private void btnFac_Click(object sender, EventArgs e)
        {
            string tail = HandleEquation.GetLastUnit(equation);

            equation = HandleEquation.RemoveLastUnit(equation) + "(" + tail + ")!";
            string tail2 = HandleEquation.GetLastUnit(richTxtEquation.Text);

            richTxtEquation.Text = HandleEquation.RemoveLastUnit(richTxtEquation.Text) + "(" + tail2 + ")!";
        }
Пример #3
0
        private void Function_Click(object sender, EventArgs e)
        {
            string tail = HandleEquation.GetLastUnit(equation);

            equation = HandleEquation.RemoveLastUnit(equation) + ((ToolStripMenuItem)sender).Text + "(" + tail + ")";
            string tail2 = HandleEquation.GetLastUnit(richTxtEquation.Text);

            richTxtEquation.Text = HandleEquation.RemoveLastUnit(richTxtEquation.Text) + ((ToolStripMenuItem)sender).Text + "(" + tail2 + ")";
        }
Пример #4
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (equation.Length == 1)
            {
                equation             = "0";
                richTxtEquation.Text = "0";
            }
            else if (equation.Last() >= 48 && equation.Last() <= 57)
            {
                equation             = equation.Substring(0, equation.Length - 1);
                richTxtEquation.Text = richTxtEquation.Text.Substring(0, richTxtEquation.Text.Length - 1);
            }
            else if (equation.Last() == '.')
            {
                equation             = equation.Substring(0, equation.Length - 1);
                richTxtEquation.Text = richTxtEquation.Text.Substring(0, richTxtEquation.Text.Length - 1);
                isClickPoint         = false;
            }
            else if (HandleEquation.IsGeneralOp(equation.Last()))
            {
                equation             = equation.Substring(0, equation.Length - 1);
                richTxtEquation.Text = richTxtEquation.Text.Substring(0, richTxtEquation.Text.Length - 1);
                string tail = HandleEquation.GetLastUnit(equation);
                if (tail.Contains("."))
                {
                    isClickPoint = true;
                }
                else
                {
                    isClickPoint = false;
                }
            }
            else
            {
                equation             = HandleEquation.RemoveLastUnit(equation);
                richTxtEquation.Text = HandleEquation.RemoveLastUnit(richTxtEquation.Text);
                isClickPoint         = false;
            }

            if (equation == "" || richTxtEquation.Text == "")
            {
                equation             = "0";
                richTxtEquation.Text = "0";
            }
        }
Пример #5
0
        private void btnNega_Click(object sender, EventArgs e)
        {
            string tail         = HandleEquation.GetLastUnit(equation);
            string tail2        = HandleEquation.GetLastUnit(richTxtEquation.Text);
            string removedTail  = HandleEquation.RemoveLastUnit(equation);
            string removedTail2 = HandleEquation.RemoveLastUnit(richTxtEquation.Text);

            if (removedTail.Length == 0)   //输入是一个正数
            {
                equation             = "-" + tail;
                richTxtEquation.Text = "-" + tail2;
            }
            else if (removedTail.Last() == '-' && removedTail.Length == 1)
            {                              //输入是一个负数
                equation             = tail;
                richTxtEquation.Text = tail2;
            }
            else
            {
                equation             = removedTail + HandleEquation.ChangeToNega(tail);
                richTxtEquation.Text = removedTail2 + HandleEquation.ChangeToNega(tail2);
            }
        }
Пример #6
0
        private void ShiftManaged_Click(object sender, EventArgs e)
        {
            switch (((Button)sender).Text)
            {
            case "x³":
                equation             += "^3";
                richTxtEquation.Text += "^3";
                break;

            case "x²":
                equation             += "^2";
                richTxtEquation.Text += "^2";
                break;

            case "^":
                equation             += "^";
                richTxtEquation.Text += "^";
                break;

            case "lg":
                string tail = HandleEquation.GetLastUnit(equation);
                equation = HandleEquation.RemoveLastUnit(equation) + "log10(" + tail + ")";
                string tail0 = HandleEquation.GetLastUnit(richTxtEquation.Text);
                richTxtEquation.Text = HandleEquation.RemoveLastUnit(richTxtEquation.Text) + ((Button)sender).Text + "(" + tail0 + ")";
                break;

            case "ln":
                string tail1 = HandleEquation.GetLastUnit(equation);
                equation = HandleEquation.RemoveLastUnit(equation) + ((Button)sender).Text + "(" + tail1 + ")";
                string tail2 = HandleEquation.GetLastUnit(richTxtEquation.Text);
                richTxtEquation.Text = HandleEquation.RemoveLastUnit(richTxtEquation.Text) + ((Button)sender).Text + "(" + tail2 + ")";
                break;

            case "²√x":
                equation += "^(1/2)";
                string tail3 = HandleEquation.GetLastUnit(richTxtEquation.Text);
                richTxtEquation.Text = HandleEquation.RemoveLastUnit(richTxtEquation.Text) + "²√(" + tail3 + ")";
                break;

            case "³√x":
                equation += "^(1/3)";
                string tail4 = HandleEquation.GetLastUnit(richTxtEquation.Text);
                richTxtEquation.Text = HandleEquation.RemoveLastUnit(richTxtEquation.Text) + "³√(" + tail4 + ")";
                break;

            case "1/x":
                string tail5 = HandleEquation.GetLastUnit(equation);
                equation = HandleEquation.RemoveLastUnit(equation) + "1/(" + tail5 + ")";
                string tail6 = HandleEquation.GetLastUnit(richTxtEquation.Text);
                richTxtEquation.Text = HandleEquation.RemoveLastUnit(richTxtEquation.Text) + "1/(" + tail6 + ")";
                break;

            case "e^x":
                string tail7 = HandleEquation.GetLastUnit(equation);
                equation = HandleEquation.RemoveLastUnit(equation) + "e^(" + tail7 + ")";
                string tail8 = HandleEquation.GetLastUnit(richTxtEquation.Text);
                richTxtEquation.Text = HandleEquation.RemoveLastUnit(richTxtEquation.Text) + "e^(" + tail8 + ")";
                break;

            case "log y(x)":
                MessageBox.Show("请先右键此按钮设置底数。");
                break;

            default:
                string tail9 = HandleEquation.GetLastUnit(equation);
                equation = HandleEquation.RemoveLastUnit(equation) + "log" + someLog.LogBase + "(" + tail9 + ")";
                string tail10 = HandleEquation.GetLastUnit(richTxtEquation.Text);
                richTxtEquation.Text = HandleEquation.RemoveLastUnit(richTxtEquation.Text) + "log " + someLog.LogBase + "(" + tail10 + ")";
                break;
            }
        }