Example #1
0
        private void Equal_Button(object sender, RoutedEventArgs e)
        {
            string num = this.Input.Text;

            if (num != "")
            {
                arrayList.Add(num);
            }
            Logical logical = new Logical();
            string  result  = logical.Analysis(arrayList); //引用dll文件计算方法

            if (result == "")                              //计算出错
            {
                if (logical.code == 1)                     //除零错误
                {
                    this.Input.Text     = "Divisor cannot be zero";
                    this.Input.FontSize = 30;
                }
                else if (logical.code == 2)   //无效输入,如tan(90)
                {
                    this.Input.Text     = "Invalid input";
                    this.Input.FontSize = 30;
                }
                else
                {
                    this.Input.Text = "Error";
                }
                this.Result.Text = "";
                isError          = true;
                arrayList.Clear();
                return;
            }
            this.Result.Text = this.Result.Text + num + "=" + result;
            this.Input.Text  = result;
            arrayList.Clear();
        }