public void SetFunctionId()
        {
            currentExample = Examples[currentFunctionId];
            StringFormat SF = new StringFormat()
            {
                Alignment     = StringAlignment.Center,
                LineAlignment = StringAlignment.Center
            };

            polynomialDisplay.PrepareWrite();
            polynomialDisplay.gfx.DrawString(currentExample.functionString, new Font("Arial Black", 10), Brushes.Black, polynomialDisplay.Rect.Width / 2, polynomialDisplay.Rect.Height / 2, SF);
            polynomialDisplay.PrepareDraw();

            parser.InputString = currentExample.functionString;
            parser.Parse();
            FunctionFractalWindow.Controller.CoefficientArray = parser.CoefficientArray;
            FunctionFractalWindow.Controller.Compute();
            for (int i = 0; i < ExampleLocationWindows.Length; i++)
            {
                if (currentExample.exampleLocations.Count > i)
                {
                    int j = (i + currentLocationOffsetId) % currentExample.exampleLocations.Count;
                    ExampleLocationWindows[i].Controller.CoefficientArray = parser.CoefficientArray;
                    ExampleLocationWindows[i].Controller.CameraPos        = currentExample.exampleLocations[j].position;
                    ExampleLocationWindows[i].Controller.Zoom             = currentExample.exampleLocations[j].zoom;
                    ExampleLocationWindows[i].Controller.Iterations       = currentExample.exampleLocations[j].iter;
                    ExampleLocationWindows[i].Controller.Compute();
                    ExampleLocationWindows[i].Enabled = true;
                }
                else
                {
                    ExampleLocationWindows[i].Enabled = false;
                }
            }
        }
        public ExampleLocationComponent(float x, float y, AutoZoomController zoomController, Main M) : base(new RectangleF(x, y, Width, Height))
        {
            this.M = M;
            this.zoomController = zoomController;
            string Data = Resources.ExampleLocations;

            string[] lines = Data.Split(new string[] { "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries);

            List <ExampleLocationStructs> locations = new List <ExampleLocationStructs>();

            for (int i = lines.Length - 1; i >= 0; i--)
            {
                string[] parts = lines[i].Split(':');
                if (parts[0] == "function")
                {
                    var exampleFunction = new ExampleFunctionStruct();
                    exampleFunction.exampleLocations = locations;
                    exampleFunction.functionString   = parts[1];
                    locations = new List <ExampleLocationStructs>();
                    Examples.Insert(0, exampleFunction);
                }
                else if (parts[0] == "location")
                {
                    var      exampleLocation = new ExampleLocationStructs();
                    string[] locationParts   = parts[1].Split('|');
                    exampleLocation.position = new Complex();
                    if (!double.TryParse(locationParts[0], out exampleLocation.position.real))
                    {
                        Console.WriteLine(locationParts[0] + " is not a valid double");
                        break;
                    }
                    if (!double.TryParse(locationParts[1], out exampleLocation.position.imag))
                    {
                        Console.WriteLine(locationParts[1] + " is not a valid double");
                        break;
                    }
                    if (!double.TryParse(locationParts[2], out exampleLocation.zoom))
                    {
                        Console.WriteLine(locationParts[2] + " is not a valid double");
                        break;
                    }
                    if (!int.TryParse(locationParts[3], out exampleLocation.iter))
                    {
                        Console.WriteLine(locationParts[3] + " is not a valid integer");
                        break;
                    }
                    locations.Add(exampleLocation);
                }
                else
                {
                    Console.WriteLine(parts[0] + " is not a valid modifier");
                    break;
                }
            }
            for (int i = 0; i < ExampleLocationWindows.Length; i++)
            {
                ExampleLocationWindows[i] = new FractalWindow(new RectangleF(10 + SideButtonWidth + (FractalWindowSize + 10) * i, FractalWindowSize + 32, FractalWindowSize, FractalWindowSize));
                ChildElements.Add(ExampleLocationWindows[i]);
                ExampleLocationWindows[i].EnableInteraction = false;
                ExampleLocationWindows[i].MouseDownEvent   += FractalWindowClick;
            }

            int X = (FractalWindowSize + 10) * (ExampleLocationWindows.Length - 1);

            FunctionFractalWindow = new FractalWindow(new RectangleF(10 + SideButtonWidth + X, 10, FractalWindowSize, FractalWindowSize));
            FunctionFractalWindow.EnableInteraction = false;
            FunctionFractalWindow.MouseDownEvent   += FractalWindowClick;
            ChildElements.Add(FunctionFractalWindow);
            polynomialDisplay = new TextDisplay(new RectangleF(10 + SideButtonWidth, 10, X - 10, FractalWindowSize));
            polynomialDisplay.PrepareDraw();
            ChildElements.Add(polynomialDisplay);
            currentExample  = Examples[0];
            MouseDownEvent += MainWindowClicked;
        }
        public override void Show(Main M)
        {
            PointF[] Points = new PointF[Array.Length];

            double slope = (Rect.Height / (max - min));

            double offset = (-(max) * slope + Rect.Height / 2);
            double LineSpace;
            double StartPoint;

            if (max == min)
            {
                LineSpace  = 1;
                StartPoint = max;
                slope      = 0;
                offset     = 0;
            }
            else
            {
                double Power    = IntegerLogPower(max - min);//gets the closest power of 10 below (max - min)
                double Fraction = (max - min) / Power;
                int    K        = (int)(Fraction / 5);
                LineSpace  = ((1 - K) / 2.0 + K) * Power;
                StartPoint = LineSpace * (Math.Ceiling(min / LineSpace));
            }
            GL.LineWidth(2);
            GL.Color3(0, 0, 0);
            GL.Begin(PrimitiveType.Lines);
            StringFormat SF = new StringFormat()
            {
                LineAlignment = StringAlignment.Center
            };

            TextDisplay.PrepareWrite();
            if (DrawLines)
            {
                for (double i = StartPoint; i <= max; i += LineSpace)
                {
                    double Y = Rect.Height / 2 - (i * slope + offset);
                    GL.Vertex2(0, Y);
                    GL.Vertex2(Rect.Width, Y);
                    TextDisplay.gfx.DrawString(i.ToString(), Font, Brushes.White, 7, (int)Y, SF);
                }
            }

            TextDisplay.PrepareDraw();
            GL.End();
            GL.Color3(Color);
            if (Dots)
            {
                GL.Begin(PrimitiveType.Quads);
                int Radius = 3;
                for (int i = StartIndex; i < Points.Length; i++)
                {
                    double X = i * spacing;
                    double Y = Rect.Height / 2 - (Array[i] * slope + offset);
                    GL.Vertex2(X - Radius, Y - Radius);
                    GL.Vertex2(X + Radius, Y - Radius);
                    GL.Vertex2(X + Radius, Y + Radius);
                    GL.Vertex2(X - Radius, Y + Radius);
                }
                GL.End();
            }
            else
            {
                GL.Begin(PrimitiveType.LineStrip);
                for (int i = StartIndex; i < Points.Length; i++)
                {
                    GL.Vertex2(i * spacing, Rect.Height / 2 - (Array[i] * slope + offset));
                }
                GL.End();
            }
        }