示例#1
0
 public void MostrarResultadoTP4(Resultado_4 rdos)
 {
     lbl_mensaje_tp4.Visible = true;
     lbl_mensaje_tp4.Text    = rdos.Mensaje;
     lbl_mensaje_tp4.Font    = new Font(lbl_textoMC.Font.Name, 10);
     panel_tp4.Controls.Add(lbl_mensaje_tp4);
     lbl_rdo_tp4.AutoSize = false;
     lbl_rdo_tp4.Size     = new System.Drawing.Size(120, 17);
     lbl_rdo_tp4.Font     = new Font(lbl_rdo_tp4.Font.Name, 10);
     //lbl_rdo_tp4.Location = new Point(pointX, pointY);
     lbl_rdo_tp4.Text      = Math.Round(rdos.Solucion, 5).ToString() + " V.A";//Math.Abs(Math.Round(rdos.Solucion, 5)).ToString() + " V.A";
     lbl_rdo_tp4.ForeColor = Color.Red;
     lbl_rdo_tp4.Visible   = true;
     panel_tp4.Controls.Add(lbl_rdo_tp4);
     panel_tp4.Update();
     panel_tp4.Refresh();
     panel_tp4.Show();
 }
示例#2
0
        // -----------------------------------------   PRÁCTICO 4   -------------------------------------------------------//
        private void Btn_obtener_tp4_Click(object sender, EventArgs e)
        {
            if (txt_funcion_TP4.Text.Trim() == string.Empty || txt_a_tp4.Text.Trim() == string.Empty ||
                txt_b_tp4.Text.Trim() == string.Empty || ((cmb_metodos_tp4.Text == "Trapecio Múltiple" ||
                                                           cmb_metodos_tp4.Text == "Simpson 1/3 Múltiple") && txt_n_tp4.Text.Trim() == string.Empty))
            {
                if (txt_funcion_TP4.Text.Trim() == string.Empty)
                {
                    txt_funcion_TP4.BackColor = Color.Red;
                }
                if (txt_a_tp4.Text.Trim() == string.Empty)
                {
                    txt_a_tp4.BackColor = Color.Red;
                }
                if (txt_b_tp4.Text.Trim() == string.Empty)
                {
                    txt_b_tp4.BackColor = Color.Red;
                }
                if (txt_n_tp4.Text.Trim() == string.Empty)
                {
                    txt_n_tp4.BackColor = Color.Red;
                }
                MessageBox.Show("Por favor ingrese todos los datos");
            }
            else
            {
                string funcion = txt_funcion_TP4.Text;
                double a       = double.Parse(txt_a_tp4.Text);
                double b       = double.Parse(txt_b_tp4.Text);
                int    n       = 0;
                if (txt_n_tp4.Text.Trim() != string.Empty)
                {
                    n = int.Parse(txt_n_tp4.Text);
                }

                Resultado_4 nuevo = new Resultado_4("", true);
                switch (cmb_metodos_tp4.SelectedIndex)
                {
                case 0:
                    nuevo = Practico4.Trapecio_Simple(funcion, a, b);
                    break;

                case 1:
                    nuevo = Practico4.Trapecio_Multiple(funcion, a, b, n);
                    break;

                case 2:
                    nuevo = Practico4.Un_Tercio_Simple(funcion, a, b);
                    break;

                case 3:
                    if (n % 2 != 0)
                    {
                        double h        = (b - a) / n;
                        double Xnmenos3 = b - (3 * h);
                        nuevo = Practico4.Un_Tercio_Multiple(funcion, a, Xnmenos3, n - 3);
                        Resultado_4 nuevo2 = Practico4.Tres_Octavos(funcion, Xnmenos3, b);
                        nuevo.Solucion += nuevo2.Solucion;
                    }
                    else
                    {
                        nuevo = Practico4.Un_Tercio_Multiple(funcion, a, b, n);
                    }
                    break;

                case 4:
                    nuevo = Practico4.Tres_Octavos(funcion, a, b);
                    break;
                }
                MostrarResultadoTP4(nuevo);
            }
        }