/* No encapsulo este metodo en la clase Function porque romperia con la abstracción de la clase y todas las subclases de esta heredarian este método. */
        private Function SelectFunction(string functionName, double a, double b, double c)
        {
            if (CosXFunction.GetFormula().Equals(functionName))
            {
                return(new CosXFunction(a, b));
            }
            else if (SenXFunction.GetFormula().Equals(functionName))
            {
                return(new SenXFunction(a, b));
            }
            else if (ExponentialFunction.GetFormula().Equals(functionName))
            {
                return(new ExponentialFunction(a, b));
            }
            else if (FirstGradeFunction.GetFormula().Equals(functionName))
            {
                return(new FirstGradeFunction(a, b));
            }
            else if (SecondGradeFunction.GetFormula().Equals(functionName))
            {
                return(new SecondGradeFunction(a, b, c));
            }
            else if (FractionalFunction.GetFormula().Equals(functionName))
            {
                return(new FractionalFunction(a, b));
            }

            return(null);
        }
        /* No encapsulo este metodo en la clase Function porque romperia con la abstracción de la clase y todas las subclases de esta heredarian este método. */
        private String[] InitializeFunctionComboBox()
        {
            String[] functionList =
            {
                CosXFunction.GetFormula(),
                SenXFunction.GetFormula(),
                ExponentialFunction.GetFormula(),
                FirstGradeFunction.GetFormula(),
                SecondGradeFunction.GetFormula(),
                FractionalFunction.GetFormula()
            };

            return(functionList);
        }
        public PointCollection[] DrawGraphic(Graphic g, double canvasWidth, double canvasHeight, FuncRect funcRect)
        {
            PointCollection points = new PointCollection();
            Polyline        graphicPolyline = new Polyline();
            double          xReal, yReal, xScreen, yScreen;

            /* Sustituyo el FuncRect real por los limites que ha introducido el usuario (en caso de que los modifique) */
            FuncRect real   = funcRect;
            FuncRect screen = DeclareFuncRect(0, canvasWidth, 0, canvasHeight);
            int      numberOfPoints = (int)screen.XMax;

            int i     = 0;
            int j     = 0;
            int limit = 0;

            if (g.Function.Formula.Equals(ExponentialFunction.GetFormula()) && g.ParamB < 0 ||
                g.Function.Formula.Equals(FractionalFunction.GetFormula()))
            {
                PointCollection[] listOfPoints = new PointCollection[2];
                while (j < 2)
                {
                    do
                    {
                        i++;
                        xReal = real.XMin + i * (real.XMax - real.XMin) / numberOfPoints;
                        yReal = g.Function.CalculateF(xReal);

                        xScreen = ConvertXFromRealToPant(xReal, screen.XMin, screen, real);
                        yScreen = ConvertYFromRealToPant(yReal, screen.YMin, screen, real);

                        points.Add(new Point(xScreen, yScreen));
                    } while (Convert.ToInt32(xReal) < limit);

                    listOfPoints[j] = points;
                    points          = new PointCollection();
                    j++;

                    xReal += 1;
                    limit  = (int)real.XMax;
                    i      = (int)(-(real.XMin) * numberOfPoints / (real.XMax - real.XMin));
                }

                return(listOfPoints);
            }
            else
            {
                PointCollection[] listOfPoints = new PointCollection[1];

                for (i = 0; i <= numberOfPoints; i++)
                {
                    xReal = real.XMin + i * (real.XMax - real.XMin) / numberOfPoints;
                    yReal = g.Function.CalculateF(xReal);

                    xScreen = ConvertXFromRealToPant(xReal, screen.XMin, screen, real);
                    yScreen = ConvertYFromRealToPant(yReal, screen.YMin, screen, real);
                    points.Add(new Point(xScreen, yScreen));
                }

                listOfPoints[0] = points;

                return(listOfPoints);
            }
        }