Exemplo n.º 1
0
        private void buttonPlus_Click(object sender, EventArgs e)
        {
            try
            {
                if (_operationChoosed)
                {
                    _digit2 = Convert.ToDouble(CalcTextBox.Text);
                    Calculate();
                    _digit1 = _result;
                }
                else
                {
                    _digit1 = Convert.ToDouble(CalcTextBox.Text);
                }

                _currentState.Append(CalcTextBox.Text);
                _currentState.Append(((Button)sender).Text);
                DisplayBox.Text = _currentState.ToString();
            }
            catch (Exception)
            {
                MessageBox.Show("Incorrect data!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                CalcTextBox.Clear();
                return;
            }

            CalcTextBox.Clear();
            _operation        = ((Button)sender).Text;
            _operationChoosed = true;
        }
Exemplo n.º 2
0
        private void Calc()
        {
            int CalcDueMoney  = Convert.ToInt32(DueMoneyTextBox.Text) - Convert.ToInt32(CalcTextBox.Text);
            int CalcTakeMoney = Convert.ToInt32(TakeMoneyTextBox.Text) + Convert.ToInt32(CalcTextBox.Text);

            if (Convert.ToInt32(DueMoneyTextBox.Text) == 0)
            {
                MetroMessageBox.Show(this, "계산이 완료되었습니다.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

                /* 초과 계산 원할 경우
                 * int CalcChangeMoney = Convert.ToInt32(ChangeMoneyTextBox.Text) + Convert.ToInt32(CalcTextBox.Text);
                 * ChangeMoneyTextBox.Text = CalcChangeMoney.ToString();
                 * TakeMoneyTextBox.Text = CalcTakeMoney.ToString();
                 */
            }
            else
            {
                if (CalcDueMoney <= 0)
                {
                    DueMoneyTextBox.Text    = "0";
                    TakeMoneyTextBox.Text   = CalcTakeMoney.ToString();
                    ChangeMoneyTextBox.Text = CalcDueMoney.ToString().Replace("-", "");

                    UpdateOrderState();
                }
                else
                {
                    DueMoneyTextBox.Text  = CalcDueMoney.ToString();
                    TakeMoneyTextBox.Text = CalcTakeMoney.ToString();
                }
            }
            CalcTextBox.Clear();
        }
Exemplo n.º 3
0
        private void buttonNrt_Click(object sender, EventArgs e)
        {
            try
            {
                _digit1 = Convert.ToDouble(CalcTextBox.Text);
            }
            catch (Exception)
            {
                MessageBox.Show("Incorrect data!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                CalcTextBox.Clear();
                return;
            }

            ValueForm f = new ValueForm();

            f.ShowDialog();

            if (!ValueData.Cancelled)
            {
                NthRoot(_digit1, ValueData.Data);

                _currentState.Append(String.Format("NthRoot({0}), N = {1}", _digit1, ValueData.Data));

                DisplayBox.Text  = _currentState.ToString();
                CalcTextBox.Text = _result.ToString();

                _currentState.Clear();
                _result             = 0;
                _operationCompleted = true;
                _operationChoosed   = false;
            }
        }
Exemplo n.º 4
0
        private void buttonEquals_Click(object sender, EventArgs e)
        {
            try
            {
                _digit2 = Convert.ToDouble(CalcTextBox.Text);
            }
            catch (Exception)
            {
                MessageBox.Show("Incorrect data!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                CalcTextBox.Clear();
                return;
            }

            Calculate();

            _currentState.Append(_digit2);

            DisplayBox.Text  = _currentState.ToString();
            CalcTextBox.Text = _result.ToString();

            _currentState.Clear();
            _result             = 0;
            _operationCompleted = true;
            _operationChoosed   = false;
        }
Exemplo n.º 5
0
 //Clear button click event here clear the texbox
 private void ClearButton_Click(object sender, EventArgs e)
 {
     CalcTextBox.Clear();
     CalcTextBox.Text = "0";
     FirstNumber      = 0.0;
     SecondNumber     = 0.0;
     Result           = 0.0;
 }
Exemplo n.º 6
0
 private void ClearButton_Click(object sender, EventArgs e)
 {
     CalcTextBox.Clear();
     CalcTextBox.Text = "0";
     firstNumber      = 0.0m;
     secondNumber     = 0.0m;
     resultDecimal    = 0.0m;
 }
Exemplo n.º 7
0
 private void ClearButton_Click(object sender, RoutedEventArgs e)
 {
     score  = 0;
     number = 0;
     ScoreTextBlock.Text = "0";
     CalcTextBox.Text    = "0";
     spyMinus            = 0;
     CalcTextBox.SelectAll();
     CalcTextBox.Focus();
 }
Exemplo n.º 8
0
 private void Point_Click(object sender, RoutedEventArgs e)
 {
     if (!new[] { "+", "-", "/", "*" }.Contains(CalcTextBox.Text))
     {
         CalcTextBox.AppendText(".");
     }
     else
     {
         CalcTextBox.Text = ".";
     }
 }
Exemplo n.º 9
0
 public void UpdateTextBox(string digit)
 {
     if (CalcTextBox.Text.Length >= 9)
     {
     }
     else if (!specialChars.Contains(CalcTextBox.Text))
     {
         CalcTextBox.AppendText(digit);
     }
     else
     {
         CalcTextBox.Text = digit;
     }
 }
Exemplo n.º 10
0
 private void ButonMinus_Click(object sender, RoutedEventArgs e)
 {
     tBox   = CalcTextBox.Text;
     number = Double.Parse(tBox);
     if (spy == 1)
     {
         score = score + number;
         spy   = 0;
     }
     else
     {
         if (spy == 3)
         {
             score = score / number;
             spy   = 0;
         }
         else
         {
             if (spyMinus == 0)
             {
                 score    = (score - number) * (-1);
                 spyMinus = 1;
             }
             else
             {
                 if (spy == 4)
                 {
                     score = score * number;
                     spy   = 0;
                 }
                 else
                 {
                     score = score - number;
                 }
             }
         }
     }
     tBox                = score.ToString(CultureInfo.InvariantCulture);
     CalcTextBox.Text    = tBox;
     ScoreTextBlock.Text = tBox + " -";
     spy = 2;
     CalcTextBox.SelectAll();
     CalcTextBox.Focus();
 }
Exemplo n.º 11
0
        private void buttonSqrt_Click(object sender, EventArgs e)
        {
            try
            {
                _result = Math.Sqrt(Convert.ToDouble(CalcTextBox.Text));
                _currentState.Append(String.Format("Sqrt({0})", CalcTextBox.Text));
                DisplayBox.Text = _currentState.ToString();

                CalcTextBox.Text = _result.ToString();
            }
            catch (Exception)
            {
                MessageBox.Show("Incorrect data!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                CalcTextBox.Clear();
                return;
            }

            _currentState.Clear();
            _result             = 0;
            _operationCompleted = true;
            _operationChoosed   = false;
        }
Exemplo n.º 12
0
 private void ButonPlus_Click(object sender, RoutedEventArgs e)
 {
     tBox   = CalcTextBox.Text;
     number = Double.Parse(tBox);
     if (spy == 2)
     {
         score = score - number;
         spy   = 0;
     }
     else
     {
         if (spy == 3)
         {
             score = score / number;
             spy   = 0;
         }
         else
         {
             if (spy == 4)
             {
                 score = score * number;
                 spy   = 0;
             }
             else
             {
                 score = number + score;
             }
         }
     }
     tBox                = score.ToString(CultureInfo.InvariantCulture);
     CalcTextBox.Text    = tBox;
     ScoreTextBlock.Text = tBox + " +";
     spy = 1;
     CalcTextBox.SelectAll();
     CalcTextBox.Focus();
 }
Exemplo n.º 13
0
 private void num00_Click(object sender, EventArgs e)
 {
     CalcTextBox.AppendText("00");
 }