コード例 #1
0
        private void Equals_Click(object sender, RoutedEventArgs e)
        {
            secoundNumberDec = Convert.ToDecimal(secoundNumber);
            var result = 0.0m;

            if (operation.Equals("+"))
            {
                Operation addDel = (x, y) => x + y;
                result             = ProcessData.Process(firstNumberDec, secoundNumberDec, addDel);
                History.Text       = TextBoxResult.Text;
                TextBoxResult.Text = Convert.ToString(result);
                globalVariable     = ProcessData.Process(firstNumberDec, secoundNumberDec, addDel);
                ClearVariable(result);
                return;
            }
            if (operation.Equals("-"))
            {
                Operation addDel = (x, y) => x - y;
                result             = ProcessData.Process(firstNumberDec, secoundNumberDec, addDel);
                History.Text       = TextBoxResult.Text;
                TextBoxResult.Text = Convert.ToString(result);
                globalVariable     = ProcessData.Process(firstNumberDec, secoundNumberDec, addDel);
                ClearVariable(result);
                return;
            }
            if (operation.Equals("*"))
            {
                Operation addDel = (x, y) => x * y;
                result             = ProcessData.Process(firstNumberDec, secoundNumberDec, addDel);
                History.Text       = TextBoxResult.Text;
                TextBoxResult.Text = Convert.ToString(result);
                globalVariable     = ProcessData.Process(firstNumberDec, secoundNumberDec, addDel);
                ClearVariable(result);
                return;
            }
            if (operation.Equals("/"))
            {
                Operation addDel = (x, y) => x / y;
                result             = ProcessData.Process(firstNumberDec, secoundNumberDec, addDel);
                History.Text       = TextBoxResult.Text;
                TextBoxResult.Text = Convert.ToString(result);
                globalVariable     = ProcessData.Process(firstNumberDec, secoundNumberDec, addDel);
                ClearVariable(result);
                return;
            }
        }
コード例 #2
0
 private void Divided_Click(object sender, RoutedEventArgs e)
 {
     if (operation == null)
     {
         firstNumberDec      = Convert.ToDecimal(TextBoxResult.Text);
         operation           = "/";
         TextBoxResult.Text += operation;
     }
     else
     {
         if (IsSpecialChar(TextBoxResult.Text[index: TextBoxResult.Text.Length - 1]))
         {
             TextBoxResult.Text = null;
             ClearVariable(0);
             return;
         }
         if (operation.Equals("+"))
         {
             setedMoreTime       = true;
             TextBoxResult.Text += "/";
             secoundNumberDec    = Convert.ToDecimal(secoundNumber);
             secoundNumber       = "";
             Operation addDel = (x, y) => x + y;
             firstNumberDec = ProcessData.Process(firstNumberDec, secoundNumberDec, addDel);
             operation      = "/";
             return;
         }
         if (operation.Equals("-"))
         {
             setedMoreTime       = true;
             TextBoxResult.Text += "/";
             secoundNumberDec    = Convert.ToDecimal(secoundNumber);
             secoundNumber       = "";
             Operation addDel = (x, y) => x - y;
             firstNumberDec = ProcessData.Process(firstNumberDec, secoundNumberDec, addDel);
             operation      = "/";
             return;
         }
         if (operation.Equals("*"))
         {
             setedMoreTime       = true;
             TextBoxResult.Text += "/";
             secoundNumberDec    = Convert.ToDecimal(secoundNumber);
             secoundNumber       = "";
             Operation addDel = (x, y) => x * y;
             firstNumberDec = ProcessData.Process(firstNumberDec, secoundNumberDec, addDel);
             operation      = "/";
             return;
         }
         if (operation.Equals("/"))
         {
             setedMoreTime       = true;
             TextBoxResult.Text += "/";
             secoundNumberDec    = Convert.ToDecimal(secoundNumber);
             secoundNumber       = "";
             Operation addDel = (x, y) => x / y;
             firstNumberDec = ProcessData.Process(firstNumberDec, secoundNumberDec, addDel);
             operation      = "/";
             return;
         }
     }
 }