private void btnAnswer_Click(object sender, EventArgs e) { try { if (HandleEquation.IsGeneralOp(equation.Last())) { MessageBox.Show("请在算式最后输入参与计算的数字!"); } else { Function.Function func = new Function.Function(equation); equation = richTxtEquation.Text = func.GetValue().ToString(); } } catch { MessageBox.Show("不支持计算此算式,请重新输入!"); } }
private void RightBkt_Click(object sender, EventArgs e) { if (bktAmount <= 0) { return; } else if (HandleEquation.IsGeneralOp(equation.Last())) { richTxtEquation.Text = richTxtEquation.Text.Substring(0, richTxtEquation.Text.Length - 1) + ((Button)sender).Text; equation = equation.Substring(0, equation.Length - 1) + ((Button)sender).Text; bktAmount--; } else { richTxtEquation.Text += ((Button)sender).Text; equation += ((Button)sender).Text; bktAmount--; } }
public void GeneralOp_Click(object sender, EventArgs e) { if (HandleEquation.IsGeneralOp(equation.Last())) { return; } richTxtEquation.Text += ((Button)sender).Text; isClickPoint = false; if (((Button)sender).Text == "×") { equation += "*"; } else if (((Button)sender).Text == "÷") { equation += "/"; } else { equation += ((Button)sender).Text; } }