Example #1
0
        protected override void OnResizeEnd(EventArgs e)
        {
            Console.WriteLine("My Form Has Been Resized!!!!");

            base.OnResize(e);

            int testNewWidth = this.Width - 150;

            int testNewHeight = this.Height - 100;

            instance.ClearCanvas();

            if (this.panel1.Width != testNewWidth || this.panel1.Height != testNewHeight)
            {
                this.panel1.Width = testNewWidth;

                this.panel1.Height = testNewHeight;

                BFS bfs = new BFS(testNewWidth, testNewHeight, 20);

                displayTree = bfs.runSearch1();

                instance.runThread(displayTree);
            }
            else
            {
                instance.runThread(displayTree);
            }
        }
Example #2
0
            public static void setColor(Object data)
            {
                MethodData methodData = (MethodData)data;

                Graphics graphics = methodData.panel1.CreateGraphics();

                graphics.FillRectangle(System.Drawing.Brushes.White, new Rectangle(0, 0, methodData.panel1.Width, methodData.panel1.Height));

                // graphics.DrawEllipse(new Pen(Color.Black), new Rectangle(50, 50, 20, 20));

                BFS.DisplayTree displayTree = (BFS.DisplayTree)methodData.displayTree;

                if (displayTree != null)
                {
                    int displayTreeNodeCount = displayTree.GetDisplayNodeCount();

                    for (int nodeCounter = 0; nodeCounter < displayTreeNodeCount; nodeCounter++)
                    {
                        // Console.WriteLine("Display Tree First Node X Value: " + displayTree.getDisplayNodeAt(nodeCounter ).GetDisplayStr());

                        graphics.DrawEllipse(new Pen(Color.Black), new Rectangle(displayTree.getDisplayNodeAt(nodeCounter).GetX(), displayTree.getDisplayNodeAt(nodeCounter).GetY(), 20, 20));

                        if (displayTree.getDisplayNodeAt(nodeCounter).GetParent() != null)
                        {
                            graphics.DrawLine(new Pen(Color.Black), displayTree.getDisplayNodeAt(nodeCounter).GetX(), displayTree.getDisplayNodeAt(nodeCounter).GetY(), displayTree.getDisplayNodeAt(nodeCounter).GetParent().GetX(), displayTree.getDisplayNodeAt(nodeCounter).GetParent().GetY());
                        }
                    }
                }

                // Console.WriteLine("Display Tree First Node X Value: " + displayTree.getDisplayNodeAt(0).GetDisplayStr() );

                // Console.WriteLine("Test Thread Has Executed!");
            }
Example #3
0
        public void runThread(BFS.DisplayTree displayTree)
        {
            MethodData methodData = new MethodData(displayTree, this.panel1);

            Thread testThread = new Thread(TestThreadStart.setColor);

            testThread.Start(methodData);

            testThread.Join();
        }
Example #4
0
        protected override void OnShown(EventArgs e)
        {
            Console.WriteLine("My Form Has Been Shown!!!!");

            base.OnShown(e);

            BFS bfs = new BFS(this.Width - 150, this.Height - 100, 20);

            displayTree = bfs.runSearch1();

            instance.runThread(displayTree);
        }
Example #5
0
            public MethodData(BFS.DisplayTree newDisplayTree, Panel newPanel1)
            {
                displayTree = newDisplayTree;

                panel1 = newPanel1;
            }