예제 #1
0
        private void SingleOperation_Click(object sender, EventArgs e)
        {
            Button b      = (Button)sender;
            double number = Convert.ToDouble(textBox1.Text);

            switch (b.Text)
            {
            case "x*x":
                textBox1.Text = Convert.ToString(c.Power(number));
                break;

            case "1/x":
                if (number != 0)
                {
                    textBox1.Text = Convert.ToString(c.Inverse(number));
                }
                else
                {
                    MessageBox.Show("На ноль делить нельзя");
                    MainText();
                    SecondaryText();
                }
                break;

            case "%":
                if (textBox1.Text != "0")
                {
                    textBox1.Text = Convert.ToString(c.Percent(number));
                }
                break;

            case "sqrt":
                textBox1.Text = Convert.ToString(c.Sqrt(number));
                break;
            }
        }