예제 #1
0
 public GraphComponent(RectangleF Rect, Color color, int Spacing = 1, bool Dots = false) : base(Rect)
 {
     this.Dots    = Dots;
     this.spacing = Spacing;
     Color        = color;
     this.Rect    = Rect;
     Array        = new double[(int)Rect.Width / spacing];
     StartIndex   = Array.Length;
     TextRect     = new Rectangle((int)Rect.Width, 0, TextDisplayWidth, (int)Rect.Height);
     TextDisplay  = new TextDisplay(TextRect);
     ChildElements.Add(TextDisplay);
 }
        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;
        }