Exemple #1
0
        private void button_Click(object sender, EventArgs e)
        {
            var radioChecked = radioButtons.Controls.OfType <RadioButton>().FirstOrDefault(r => r.Checked);

            switch (radioChecked.Text)
            {
            case "Busca Uniforme":
                BuscaUniforme buscUni = new BuscaUniforme();
                buscUni.FinishCalculating += FinishCalculating;
                try
                {
                    buscUni.dados.a     = Convert.ToDouble(aTextBox.Text);
                    buscUni.dados.b     = Convert.ToDouble(bTextBox.Text);
                    buscUni.dados.delta = Convert.ToDouble(deltaTextBox.Text);
                    buscUni.dados.func  = funcTextBox.Text;
                    xotimoTextBox.Text  = buscUni.Calcular().ToString();
                }
                catch (FormatException)
                {
                    string aux = lastArchieve.Text;
                    lastArchieve.Text = "Insira um valor válido";
                    var t = new Timer();
                    t.Interval = 2000;
                    t.Tick    += (s, eT) =>
                    {
                        lastArchieve.Text = aux;
                        t.Stop();
                    };
                    t.Start();
                }
                break;

            case "Busca Dicotômica":
                BuscaDic buscDic = new BuscaDic();
                buscDic.FinishCalculating += FinishCalculating;
                try
                {
                    buscDic.infos.a       = Convert.ToDouble(aDicTextBox.Text);
                    buscDic.infos.b       = Convert.ToDouble(bDicTextBox.Text);
                    buscDic.infos.l       = Convert.ToDouble(lTextBox.Text);
                    buscDic.infos.e       = Convert.ToDouble(episTextBox.Text);
                    buscDic.infos.func    = funcDicTextBox.Text;
                    xotimoDicTextBox.Text = buscDic.Calcular().ToString();
                }
                catch (Exception)
                {
                    string aux = lastArchieve.Text;
                    lastArchieve.Text = "Insira um valor válido";
                    var t = new Timer();
                    t.Interval = 2000;
                    t.Tick    += (s, eT) =>
                    {
                        lastArchieve.Text = aux;
                        t.Stop();
                    };
                    t.Start();
                }
                break;

            case "Seção Áurea":
                SecAurea secAurea = new SecAurea();
                secAurea.FinishCalculating += FinishCalculating;
                try
                {
                    secAurea.infos.a        = Convert.ToDouble(aAureaTextBox.Text);
                    secAurea.infos.b        = Convert.ToDouble(bAureaTextBox.Text);
                    secAurea.infos.l        = Convert.ToDouble(lAureaTextBox.Text);
                    secAurea.infos.func     = funcAureaTextBox.Text;
                    xotimoAureaTextBox.Text = secAurea.Calcular().ToString();
                }
                catch (Exception)
                {
                    string aux = lastArchieve.Text;
                    lastArchieve.Text = "Insira um valor válido";
                    var t = new Timer();
                    t.Interval = 2000;
                    t.Tick    += (s, eT) =>
                    {
                        lastArchieve.Text = aux;
                        t.Stop();
                    };
                    t.Start();
                }
                break;

            case "Busca de Fibonacci":
                Fibonacci fib = new Fibonacci();
                fib.FinishCalculating += FinishCalculating;
                try
                {
                    fib.infos.a    = Convert.ToDouble(aFibTextBox.Text);
                    fib.infos.b    = Convert.ToDouble(bFibTextBox.Text);
                    fib.infos.l    = Convert.ToDouble(lFibTextBox.Text);
                    fib.infos.func = funcFibTextBox.Text;
                    xotimoFib.Text = fib.Calcular().ToString();
                }
                catch (Exception)
                {
                    string aux = lastArchieve.Text;
                    lastArchieve.Text = "Insira um valor válido";
                    var t = new Timer();
                    t.Interval = 2000;
                    t.Tick    += (s, eT) =>
                    {
                        lastArchieve.Text = aux;
                        t.Stop();
                    };
                    t.Start();
                }
                break;

            case "Bisseção":
                Bissecao biss = new Bissecao();
                biss.FinishCalculating += FinishCalculating;
                try
                {
                    biss.infos.a             = Convert.ToDouble(aBissecTextBox.Text);
                    biss.infos.b             = Convert.ToDouble(bBissecTextBox.Text);
                    biss.infos.l             = Convert.ToDouble(lBissecTextBox.Text);
                    biss.infos.func          = funcBissecTextBox.Text;
                    xotimoBissecTextBox.Text = biss.Calcular().ToString();
                }
                catch (Exception)
                {
                    string aux = lastArchieve.Text;
                    lastArchieve.Text = "Insira um valor válido";
                    var t = new Timer();
                    t.Interval = 2000;
                    t.Tick    += (s, eT) =>
                    {
                        lastArchieve.Text = aux;
                        t.Stop();
                    };
                    t.Start();
                }
                break;

            case "Newton":
                Newton newt = new Newton();
                newt.FinishCalculating += FinishCalculating;
                try
                {
                    newt.infos.a          = Convert.ToDouble(aNewTextBox.Text);
                    newt.infos.b          = Convert.ToDouble(bNewTextBox.Text);
                    newt.infos.e          = Convert.ToDouble(episNewTextBox.Text);
                    newt.infos.func       = funcNewTextBox.Text;
                    xotimoNewTextBox.Text = newt.Calcular().ToString();
                }
                catch (Exception)
                {
                    string aux = lastArchieve.Text;
                    lastArchieve.Text = "Insira um valor válido";
                    var t = new Timer();
                    t.Interval = 2000;
                    t.Tick    += (s, eT) =>
                    {
                        lastArchieve.Text = aux;
                        t.Stop();
                    };
                    t.Start();
                }
                break;

            default:
                break;
            }
        }