예제 #1
0
        private void SolveButton_Click(object sender, EventArgs e)
        {
            if (b_input.Text == "...")
            {
                b_input.Text      = "0";
                b_input.ForeColor = Color.White;
            }
            if (c_input.Text == "...")
            {
                c_input.Text      = "0";
                c_input.ForeColor = Color.White;
            }
            bool success = false;

            try
            {
                double a1 = Double.Parse(a_input.Text);
                double b1 = Double.Parse(b_input.Text);
                double c1 = Double.Parse(c_input.Text);
                if (a_input.Text == "0")
                {
                    throw new Exception();
                }
                success = true;
            }
            catch (Exception)
            {
                if (!Error_Window.errorKey)
                {
                    Error_Window error = new Error_Window();
                    Error_Window.errorKey = true;
                    this.Controls.Add(error);
                    error.BringToFront();
                    error.Left = (this.ClientSize.Width - error.Width) / 2;
                    error.Top  = (this.ClientSize.Height - error.Height) / 2 - 100;
                    error.Focus();
                }
            }
            finally
            {
                if (success)
                {
                    double        a_value   = Double.Parse(a_input.Text, CultureInfo.InvariantCulture);
                    double        b_value   = Double.Parse(b_input.Text, CultureInfo.InvariantCulture);
                    double        c_value   = Double.Parse(c_input.Text, CultureInfo.InvariantCulture);
                    double        D         = QESSOLVER.Discriminant(a_value, b_value, c_value);
                    List <object> solutions = QESSOLVER.Solutions(a_value, b_value, c_value);
                    List <double> extrema   = QESSOLVER.Extrema(a_value, b_value, c_value);
                    x1Result.Text = Convert.ToString(solutions[0]);
                    x2Result.Text = Convert.ToString(solutions[1]);
                    DResult.Text  = Convert.ToString(D);
                    TxResult.Text = Convert.ToString(extrema[0]);
                    TyResult.Text = Convert.ToString(extrema[1]);
                }
            }
            this.ActiveControl = QESLabel;
        }
예제 #2
0
 public void CallErrorWindow()
 {
     if (!Error_Window.errorKey)
     {
         Error_Window error = new Error_Window();
         Error_Window.errorKey = true;
         this.Controls.Add(error);
         error.BringToFront();
         error.Left = (this.ClientSize.Width - error.Width) / 2;
         error.Top  = (this.ClientSize.Height - error.Height) / 2 - 100;
         error.Focus();
     }
 }