public frmControladores(IPropiedadesGrafica cont)
        {
            //Seteo la cultura para utilizar el punto como separador decimal
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
            InitializeComponent();
            panel1.Hide();
            panel2.Hide();
            panel3.Hide();
            listBox1.DataSource = generarLista();

            iniciarComponentesGrafica(cont);
            agregarComponentes();
        }
        public Grafica(IPropiedadesGrafica funcion)
        {
            this.funcion = funcion;
            colores[0] = Color.Red;
            colores[1] = Color.Green;
            colores[2] = Color.Orange;
            colores[3] = Color.DarkViolet;
            colores[4] = Color.SaddleBrown;
            colores[5] = Color.LightCoral;
            id = ID;
            ID++;
            ventanaMedidas = new frmMedidas();
            iniciarDataGrid();

            zedGraphControl = new ZedGraph.ZedGraphControl();

            zedGraphControl_2 = new ZedGraph.ZedGraphControl();

            this.dataGrid.RowsAdded += new System.Windows.Forms.DataGridViewRowsAddedEventHandler(this.dataGrid_RowsAdded);

            //Establece el título del gráfico.
            zedGraphControl.GraphPane.Title.Text = "";
            //Damos nombre a los ejes.
            zedGraphControl.GraphPane.XAxis.Title.Text = "";
            zedGraphControl.GraphPane.YAxis.Title.Text = "";
            //Muestra los valores mientras pasamos por la curva
            zedGraphControl.IsShowPointValues = true;
            zedGraphControl.PointValueEvent += new ZedGraphControl.PointValueHandler(MyPointValueHandler);

            zedGraphControl.IsShowContextMenu = false;

            //Establece el título del gráfico.
            zedGraphControl_2.GraphPane.Title.Text = "";
            //Damos nombre a los ejes.
            zedGraphControl_2.GraphPane.XAxis.Title.Text = "";
            zedGraphControl_2.GraphPane.YAxis.Title.Text = "";
            //Muestra los valores mientras pasamos por la curva
            zedGraphControl_2.IsShowPointValues = true;
            zedGraphControl_2.PointValueEvent += new ZedGraphControl.PointValueHandler(MyPointValueHandler2);

            zedGraphControl_2.IsShowContextMenu = false;
        }
        public void iniciarComponentesGrafica(IPropiedadesGrafica funcion)
        {
            if (grafica != null)
            {
                guardarGrafica();
                //remuevo los componentes anteriores antes de instanciar los nuevos.
                quitarComponentes();
            }

            grafica = new Grafica(funcion);
            grafica.setTitulo();
            txtTitulo.Text = grafica.titulo;

            //guido
            seleccionarImagenControlador(funcion);
            imgSalida.Visible = true;
            imgSalida.Image = null;
            imgError.Visible = true;
            imgError.Image = null;
            imgControlador.Visible = true;
        }
        public Grafica(IPropiedadesGrafica funcion)
        {
            this.funcion = funcion;
            colores[0] = Color.Red;
            colores[1] = Color.Green;
            colores[2] = Color.Orange;
            colores[3] = Color.DarkViolet;
            colores[4] = Color.SaddleBrown;
            colores[5] = Color.LightCoral;
            id = ID;
            ID++;
            ventanaMedidas = new frmMedidas();
            esSenoidal = false;
            iniciarDataGrid();

            zedGraphControl = new ZedGraph.ZedGraphControl();

            //Establece el título del gráfico.
            zedGraphControl.GraphPane.Title.Text = "";
            //Damos nombre a los ejes.
            zedGraphControl.GraphPane.XAxis.Title.Text = "";
            zedGraphControl.GraphPane.YAxis.Title.Text = "";
            //Muestra los valores mientras pasamos por la curva
            zedGraphControl.IsShowPointValues = true;
            zedGraphControl.PointValueEvent += new ZedGraphControl.PointValueHandler(MyPointValueHandler);

            zedGraphControl.IsShowContextMenu = false;
            // Cambia la letra del zedgraphcontrol y el tamaño. NO FUNCIONA!!!
            zedGraphControl.Font = new Font("Times New Roman", 20.0f);

            //Muestro siempre el valor base en la senoidal de segundo orden
            if (funcion.GetType() == typeof(EntradaSenoidalOrden2))
            {
                chkGrReferencias = true;
            }
        }
        private void iniciarComponentesGrafica(IPropiedadesGrafica funcion)
        {
            if (grafica != null)
            {
                //guardarGrafica();
                //remuevo los componentes anteriores antes de instanciar los nuevos.
                quitarComponentes();
            }

            grafica = new Grafica(funcion);
            grafica.setTitulo();
            chkEntrada.Checked = grafica.verEntrada;
            chkReferencias.Checked = grafica.chkGrReferencias;
            chkTpoAsentamiento.Checked = grafica.chkGrTpoAsentamiento;
            txtTitulo.Text = grafica.titulo;

            //Asigno los textos de los checkBoton
            if (grafica.funcion.Botones[0] != "")
            {
                chkReferencias.Text = grafica.funcion.Botones[0];
                chkReferencias.Visible = true;
            }
            else
            {
                chkReferencias.Visible = false;
            }

            if (grafica.funcion.Botones[1] != "")
            {
                chkTpoAsentamiento.Text = grafica.funcion.Botones[1];
                chkTpoAsentamiento.Visible = true;
            }
            else
            {
                chkTpoAsentamiento.Visible = false;
            }
        }
        private void seleccionarImagenesGraficas(IPropiedadesGrafica controlador, int error)
        {
            if(controlador.GetType() == typeof(Proporcional))
            {
                switch (error)
                {
                    case 1: imgSalida.Image = Controladores.Properties.Resources.controlador_proporcional_escalon;
                            imgError.Image = Controladores.Properties.Resources.error_escalon;
                            break;
                    case 2: imgSalida.Image = Controladores.Properties.Resources.controlador_proporcional_rampa;
                            imgError.Image = Controladores.Properties.Resources.error_rampa;
                            break;
                    case 3: imgSalida.Image = Controladores.Properties.Resources.controlador_proporcional_cuadratico;
                            imgError.Image = Controladores.Properties.Resources.error_cuadratico;
                            break;
                    default:imgSalida.Image = null;
                            imgError.Image = null;
                            break;
                }
            }

            if (controlador.GetType() == typeof(ProporcionalDerivativo))
            {
                switch (error)
                {
                    case 1: imgSalida.Image = Controladores.Properties.Resources.controlador_proporcional_derivativo_escalon;
                            imgError.Image = Controladores.Properties.Resources.error_escalon;
                            break;
                    case 2: imgSalida.Image = Controladores.Properties.Resources.controlador_proporcional_derivativo_rampa;
                            imgError.Image = Controladores.Properties.Resources.error_rampa;
                            break;
                    case 3: imgSalida.Image = Controladores.Properties.Resources.controlador_proporcional_derivativo_cuadratico;
                            imgError.Image = Controladores.Properties.Resources.error_cuadratico;
                            break;
                    default: imgSalida.Image = null;
                             imgError.Image = null;
                             break;
                }
            }

            if (controlador.GetType() == typeof(ProporcionalIntegral))
            {
                switch (error)
                {
                    case 1: imgSalida.Image = Controladores.Properties.Resources.controlador_proporcional_integral_escalon;
                            imgError.Image = Controladores.Properties.Resources.error_escalon;
                            break;
                    case 2: imgSalida.Image = Controladores.Properties.Resources.controlador_proporcional_integral_rampa;
                            imgError.Image = Controladores.Properties.Resources.error_rampa;
                            break;
                    case 3: imgSalida.Image = Controladores.Properties.Resources.controlador_proporcional_integral_cuadratico;
                            imgError.Image = Controladores.Properties.Resources.error_cuadratico;
                            break;
                    default: imgSalida.Image = null;
                             imgError.Image = null;
                             break;
                }
            }

            if (controlador.GetType() == typeof(ProporcionalIntegralDerivativo))
            {
                switch (error)
                {
                    case 1: imgSalida.Image = Controladores.Properties.Resources.controlador_proporcional_integral_derivativo_escalon;
                            imgError.Image = Controladores.Properties.Resources.error_escalon;
                            break;
                    case 2: imgSalida.Image = Controladores.Properties.Resources.controlador_proporcional_integral_derivativo_rampa;
                            imgError.Image = Controladores.Properties.Resources.error_rampa;
                            break;
                    case 3: imgSalida.Image = Controladores.Properties.Resources.controlador_proporcional_integral_derivativo_cuadratico;
                            imgError.Image = Controladores.Properties.Resources.error_cuadratico;
                            break;
                    default: imgSalida.Image = null;
                             imgError.Image = null;
                             break;
                }
            }
        }
 private void seleccionarImagenControlador(IPropiedadesGrafica controlador)
 {
     //se invoca en iniciarComponentesGrafica
     if (controlador.GetType() == typeof(Proporcional)) imgControlador.Image = Controladores.Properties.Resources.controlador_proporcional;
     else if (controlador.GetType() == typeof(ProporcionalDerivativo)) imgControlador.Image = Controladores.Properties.Resources.controlador_proporcional_derivativo;
     else if (controlador.GetType() == typeof(ProporcionalIntegral)) imgControlador.Image = Controladores.Properties.Resources.controlador_proporcional_integral;
     else if (controlador.GetType() == typeof(ProporcionalIntegralDerivativo)) imgControlador.Image = Controladores.Properties.Resources.controlador_proporcional_integral_derivativo;
 }