private void Form1_Resize(object sender, EventArgs e)
 {
     //called when the form is resized so that the variables don't run out of bounds
     world = new ArrayGraphics(pbCamvas.Size.Width, pbCamvas.Size.Height);
     world.FillRectangle(Constants.start.X, Constants.start.Y, Constants.start.Width, Value.Start);
     world.FillRectangle(Constants.finish.X, Constants.finish.Y, Constants.finish.Width, Value.Finish);
 }
        private void button2_Click(object sender, EventArgs e)
        {
            /*
             * Function Loads data form a file and Updates the GUI
             * Called when the load button is pressed
             */
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.InitialDirectory = "~";
            openFileDialog1.Filter           = "csv files (*.csv)|*.csv|All files (*.*)|*.*";
            openFileDialog1.FilterIndex      = 2;
            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    using (StreamReader sr = new StreamReader(openFileDialog1.FileName))
                    {
                        world = new ArrayGraphics(pbCamvas.Size.Width, pbCamvas.Size.Height);
                        string[] line = sr.ReadLine().Split(',');
                        world.FillRectangle(Convert.ToInt32(line[0]), Convert.ToInt32(line[1]), Convert.ToInt32(line[2]), Value.Start);
                        Constants.start.X      = Convert.ToInt32(line[0]);
                        Constants.start.Y      = Convert.ToInt32(line[1]);
                        Constants.start.Width  = Convert.ToInt32(line[2]);
                        Constants.start.Height = Convert.ToInt32(line[2]);
                        line = sr.ReadLine().Split(',');
                        world.FillRectangle(Convert.ToInt32(line[0]), Convert.ToInt32(line[1]), Convert.ToInt32(line[2]), Value.Finish);
                        Constants.finish.X      = Convert.ToInt32(line[0]);
                        Constants.finish.Y      = Convert.ToInt32(line[1]);
                        Constants.finish.Width  = Convert.ToInt32(line[2]);
                        Constants.finish.Height = Convert.ToInt32(line[2]);
                        while (!sr.EndOfStream)
                        {
                            string[] ln = sr.ReadLine().Split(',');
                            if (Convert.ToInt32(ln[3]) == 0)
                            {
                                world.FillRectangle(Convert.ToInt32(ln[0]), Convert.ToInt32(ln[1]), Convert.ToInt32(ln[2]), Value.Obstacle);
                                //adding the obstacles to state space
                            }
                            else
                            {
                                world.FillTriangle(Convert.ToInt32(ln[0]), Convert.ToInt32(ln[1]), Convert.ToInt32(ln[2]), Value.Obstacle);
                                //adding the obstacles to state space
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("File Loaded ");
                }
                pbCamvas.Invalidate();
            }
        }