Example #1
0
        public void rulerVert()
        {
            Panel1 p = new Panel1();

            p.Size      = new Size(5, 5);
            p.Location  = new Point(((pbBackground.Location.X)), pbBackground.Location.Y + ruler);
            p.BackColor = Color.Black;
            Label l = new Label();

            l.Text      = ruler.ToString();
            l.Location  = new Point(((pbBackground.Location.X + 3)), pbBackground.Location.Y + ruler);
            l.BackColor = Color.Transparent;
            l.AutoSize  = true;

            rulerLabels.Add(l);
            rulerList.Add(p);
            Controls.Add(p);
            Controls.Add(l);
            p.BringToFront();
            l.BringToFront();

            System.Drawing.Drawing2D.GraphicsPath buttonPath = new System.Drawing.Drawing2D.GraphicsPath();
            System.Drawing.Rectangle newPanel = p.ClientRectangle;
            buttonPath.AddEllipse(newPanel);
            p.Region = new System.Drawing.Region(buttonPath);
        }
Example #2
0
        private void Panel_Click(object sender, EventArgs e)
        {
            Panel1 clickedTile   = (Panel1)sender;
            Panel1 highlightTile = new Panel1();

            if (ModifierKeys.HasFlag(Keys.Control)) //if ctrl is pressed
            {                                       //create and add new highlights to list
                allClicked.Add(clickedTile);        //add clicked to list of clicked tiles

                highlightTile = highlight(clickedTile);
                allHighlight.Add(highlightTile);//add highlight to list of highlighted tiles
                //return;
            }
            else//if only 1 tile has been clicked
            {       //reset clicked lists
                deleteList(allHighlight);//deletes all panels in list
                clearList(allHighlight);                //resets the highlist list
                clearList(allClicked);                  //resets all clicked list

                highlightTile = highlight(clickedTile); //create a highlight tile
                //allHighlight.Clear();
                allHighlight.Insert(0, highlightTile);  //replace/add highlight tile as #1 in list
                allClicked.Insert(0, clickedTile);      //replace clicked tile list #1 with new clicked

                position.X = clickedTile.Location.X;    //allows branching from other tiles
                position.Y = clickedTile.Location.Y;    //instead of one snake
            }
            pbBackground.SendToBack();
        }
Example #3
0
 private void showConnections_Click(object sender, EventArgs e)
 {
     if (allClicked.Any())
     {
         if (allClicked.Count == 1)
         {
             foreach (Panel1 hilightedPanel in allClicked.First().connectedList)
             {
                 Color  green          = Color.Green;
                 Panel1 greenHighlight = highlight(hilightedPanel, green); //highlights all of the tiles that are connected green
                 greenHighlight.BringToFront();                            //*******may cause issues with showing the unit******
                 hilightedPanel.BringToFront();                            //*******may cause issues with showing the unit******
                 allHighlight.Add(greenHighlight);                         //adds the highlight to the list so that the highlight can be deleted when you click away
             }
         }
         else
         {
             foreach (Panel1 hilightedPanel in allClicked.First().connectedList)
             {
                 Color  green          = Color.Green;
                 Panel1 greenHighlight = highlight(hilightedPanel, green); //highlights all of the tiles that are connected green
                 greenHighlight.BringToFront();                            //*******may cause issues with showing the unit******
                 hilightedPanel.BringToFront();                            //*******may cause issues with showing the unit******
                 allHighlight.Add(greenHighlight);                         //adds the highlight to the list so that the highlight can be deleted when you click away
             }
             MessageBox.Show("this button only shows connections for the first selected tile, highlighted in green");
         }
     }
     else
     {
         //error message
         MessageBox.Show("Select a tile to show its connections highlighted in green.");
     }
 }
Example #4
0
        public void CreateTile()
        {
            Panel1 newTile = new Panel1(); //creates new tile panel

            numTiles++;

            if (imageAdded == true)                                        //if image has been added to all tiles
            {                                                              //fill color does need it
                newTile.BackgroundImage       = Image.FromFile(imagePath); //get tile from panel selected
                newTile.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
            }
            else
            {
                newTile.BackColor = backgroundTile;               //fills tile with color
                imageAdded        = false;
            }

            newTile.Size        = new Size(wTile, hTile);            //sets size of tile
            newTile.Location    = new Point(position.X, position.Y); //sets position of tile
            newTile.Name        = "tile" + numTiles;                 //changes name of tile to "tile#"
            newTile.MouseClick += Panel_Click;                       //creates event for tile / addes mouseClick event

            intersectsWith(newTile);                                 //checks if the new tile intersects with all other created tiles
            tilesCreated.Add(newTile);                               //adds panel to list of al tiles created

            Controls.Add(newTile);                                   //adds panel to the form

            newTile.BringToFront();                                  //bring before the picturebox background   SAME AS below???
            pbBackground.SendToBack();                               //prevents the BG panel from covering the new highlight panel
        }
Example #5
0
        public void rulerHori() //got bored and made this to see where to start the tile
        {                       //slightly ugly but it does what its supposed to
            if (ruler <= this.Width)
            {
                Panel1 p = new Panel1();
                p.Size      = new Size(5, 5);
                p.Location  = new Point(((pbBackground.Location.X) + ruler), pbBackground.Location.Y);
                p.BackColor = Color.Black;
                Label l = new Label();
                l.Text      = ruler.ToString();
                l.Location  = new Point(((pbBackground.Location.X + 3) + ruler), pbBackground.Location.Y + 2);
                l.BackColor = Color.Transparent;
                l.AutoSize  = true;

                rulerLabels.Add(l);
                rulerList.Add(p);
                Controls.Add(p);
                Controls.Add(l);
                p.BringToFront();
                l.BringToFront();

                System.Drawing.Drawing2D.GraphicsPath buttonPath = new System.Drawing.Drawing2D.GraphicsPath();
                System.Drawing.Rectangle newPanel = p.ClientRectangle;
                buttonPath.AddEllipse(newPanel);
                p.Region = new System.Drawing.Region(buttonPath);
                ruler   += 50;
                rulerVert();
                rulerHori();
            }
        }
Example #6
0
        public Panel1 highlight(Panel panelToHighlight, Color highlightColor)//more generic constructor of the highlight method
        {
            Panel1 highlight = new Panel1();

            highlight.BackColor = highlightColor;
            highlight.Size      = new Size(panelToHighlight.Width + 2, panelToHighlight.Height + 2);           //sets size of highlight tile
            highlight.Location  = new Point(panelToHighlight.Location.X - 1, panelToHighlight.Location.Y - 1); //set location of highlight tile
            Controls.Add(highlight);                                                                           //add highlight tile to form
            return(highlight);
        }
Example #7
0
        private Panel1 highlight(Panel1 clickedTile)//creates a new panel for highlight
        {
            Panel1 highlight = new Panel1();

            highlight.BackColor = Color.Red;                                                         //set color of highlight tile
            highlight.Size      = new Size(clickedTile.Width + 2, clickedTile.Height + 2);           //sets size of highlight tile
            highlight.Location  = new Point(clickedTile.Location.X - 1, clickedTile.Location.Y - 1); //set location of highlight tile
            Controls.Add(highlight);                                                                 //add highlight tile to form

            return(highlight);
        }
Example #8
0
        public void drawCircle(Panel1 p)
        {
            System.Drawing.Drawing2D.GraphicsPath buttonPath = new System.Drawing.Drawing2D.GraphicsPath();

            //set a new rectangle to the same size as the button's ClientRectange property
            System.Drawing.Rectangle newPanel = p.ClientRectangle;

            //create a circle withing the new rectangle
            buttonPath.AddEllipse(newPanel);
            p.Region = new System.Drawing.Region(buttonPath);

            //set the buttons region property to the newly created circle region
            p.BackColor = backgroundTile;
        }
Example #9
0
 private void intersectsWith(Panel1 newTile)
 {
     foreach (Panel1 p in tilesCreated)                                           //checks if tile is overlapping another tile
     {
         if (newTile.Bounds.IntersectsWith(p.Bounds) && (newTile.Name != p.Name)) //checks if intersects with all tiles
         {                                                                        //if newTile IS the tile
             newTile.BackColor = Color.Yellow;                                    //tile changes color to yellow
             return;                                                              //otherwise will keep foreaching and turn tile black again
         }
         else
         {
             newTile.BackColor = backgroundTile;
         }
     }
 }
Example #10
0
        //method puts a unit on the specified panel
        public Unit createUnit(Panel1 startingLocation)
        {
            Unit newUnit = new Unit();

            newUnit.Location = new Point(0, 0);//sets it outside at first
            newUnit.setName("unit " + unitNum);
            //newUnit.setParameters(allClicked.First());
            newUnit.setParameters(startingLocation);
            unitNum++;
            //Controls.Add(newUnit.getUnit());
            Controls.Add(newUnit);
            //newUnit.getUnit().BringToFront();
            newUnit.BringToFront();
            masterUnitList.Add(newUnit);
            return(newUnit);
        }
Example #11
0
 //happens after you have left clicked the panel that contained the unit before and then right
 //clicked the new location
 public void changeLocation(Panel1 newLocation)
 {
     currentLocation.unitsOnThisPanel.Remove(this); //removes the unit from the reference of the old panel
     this.currentLocation = newLocation;            //sets the current location to the new location
     //adds a reference for this unit to the new location
     if (newLocation.unitsOnThisPanel.Any())
     {
         newLocation.unitsOnThisPanel.AddLast(this);
     }
     else
     {
         newLocation.unitsOnThisPanel.AddFirst(this);
     }
     this.Location = newLocation.Location;//sets the visable Unit to the new location
     this.adjustLocation();
 }
Example #12
0
            public Unit(Panel1 startingLocation) //instantiate a Unit
            {
                //on creation, the starting location will be the one that is currently highlighted


                //graphic representaion
                this.unitsPicture = new PictureBox();
                unitsPicture.BringToFront();
                unitsPicture.BackColor = System.Drawing.Color.LimeGreen;
                unitsPicture.Size      = new System.Drawing.Size(startingLocation.Width - 4, startingLocation.Height - 4); //sets size of tile
                                                                                                                           //tile.Location = new Point(x, y);            //sets location of tile
                unitsPicture.Location = new Point(startingLocation.Location.X, startingLocation.Location.Y);
                this.adjustLocation();

                //variable to hold locationID
                this.currentLocation = startingLocation;
            }
Example #13
0
        public Panel1 highlight(Panel1 clickedTile)//creates a new panel for highlight when clicking tiles
        {
            Panel1 highlight = new Panel1();

            if (allClicked.Any())
            {
                highlight.BackColor = Color.Blue; //set color of highlight tile
            }
            else
            {
                highlight.BackColor = Color.Red;                                                    //set color of highlight tile
            }
            highlight.Size     = new Size(clickedTile.Width + 2, clickedTile.Height + 2);           //sets size of highlight tile
            highlight.Location = new Point(clickedTile.Location.X - 1, clickedTile.Location.Y - 1); //set location of highlight tile
            Controls.Add(highlight);                                                                //add highlight tile to form

            return(highlight);
        }
Example #14
0
        public void drawTriangle(Panel1 p)
        {
            // Triangle button
            System.Drawing.Drawing2D.GraphicsPath buttonPath = new System.Drawing.Drawing2D.GraphicsPath();

            //set a new rectangle to the same size as the button's ClientRectange property
            System.Drawing.Rectangle newPanel = p.ClientRectangle;

            Point[] points =
            {
                new Point(p.Width / 2,        0),
                new Point(0,           p.Height),
                new Point(p.Width,     p.Height)
            };

            buttonPath.AddPolygon(points);
            p.Region    = new System.Drawing.Region(buttonPath);
            p.BackColor = backgroundTile;
        }
Example #15
0
        private void connection_Click(object sender, EventArgs e)
        {
            if (allClicked.Any())           //checks if any tiles have been selected
            {
                if (allClicked.Count() > 1) //checks if multiple tiles selected
                {
                    Panel1 firstPanel = allClicked.First();
                    String a          = "";//for use in verifying completion
                    foreach (Panel1 nextpanel in allClicked)
                    {
                        if (nextpanel == firstPanel)
                        {
                            continue;
                        }
                        else
                        {
                            if (firstPanel.connectedList.Any() == false)
                            {
                                firstPanel.connectedList.AddFirst(nextpanel);
                            }
                            else
                            {
                                firstPanel.connectedList.AddLast(nextpanel);
                            }

                            a += nextpanel.Name + ", ";
                        }
                    }
                    //message to verify completion
                    MessageBox.Show("You have added the panels: " + a + "\n to the list of connected panels in " + firstPanel.Name);
                }
                else
                {
                    //error message
                    MessageBox.Show("you must ctrl click multiple squares to add connections. The blue highlighted tiles will be added to the list of connected tiles in the red tile ");
                }
            }
            else
            {
                //error message
                MessageBox.Show("You must ctrl click multiple tiles to be added.");
            }
        }
Example #16
0
            public void setParameters(Panel1 startingLocation)//instantiate a Unit
            {
                this.BringToFront();

                this.BackColor = Color.LimeGreen;

                this.Size = new Size(startingLocation.Width - 20, startingLocation.Height - 20);

                this.Location = new Point(startingLocation.Location.X, startingLocation.Location.Y);

                this.adjustLocation();

                this.currentLocation = startingLocation;

                if (currentLocation.unitsOnThisPanel.Any())
                {
                    currentLocation.unitsOnThisPanel.AddLast(this);
                }
                else
                {
                    currentLocation.unitsOnThisPanel.AddFirst(this);
                }
                MessageBox.Show("added " + currentLocation.unitsOnThisPanel.First().name + " to " + currentLocation.Name);
            }
Example #17
0
 public void changeLocation(Panel1 newLocation)
 {
     this.currentLocation       = newLocation; this.changeLocation(newLocation);//
     this.unitsPicture.Location = newLocation.Location;
     this.adjustLocation();
 }
Example #18
0
        public void Panel_Click(object sender, EventArgs e)
        {
            if (checker_rules_on == true)
            {
            }

            Panel1 clickedTile   = new Panel1();
            Panel1 highlightTile = new Panel1();

            clickedTile = (Panel1)sender;


            MouseEventArgs me = (MouseEventArgs)e; //used to differentiate left vs right click

            if (me.Button == MouseButtons.Right)   //if right click
            {
                //MessageBox.Show("register a right click");
                if (allSelectedUnits[0] != null)//and unit was previously selected
                {
                    if (clickedTile.unitsOnThisPanel.Any())
                    {
                        MessageBox.Show("Tile already on this panel");
                        //this is where we could cave added code for making the panels smaller and exist side by side when on the same tile
                    }
                    //move the unit
                    else
                    {
                        if (checker_rules_on == true)
                        {
                            checkersMovement(clickedTile);
                        }
                        else
                        {
                            allSelectedUnits[0].changeLocation(clickedTile);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Error! Selected Unit could not be added.");
                }
            }
            else//if left click
            {
                if (ModifierKeys.HasFlag(Keys.Control))//if ctrl is pressed
                {                                //create and add new highlights to list
                    allClicked.Add(clickedTile); //add clicked to list of clicked tiles

                    highlightTile = highlight(clickedTile);
                    allHighlight.Add(highlightTile); //add highlight to list of highlighted tiles
                                                     //return;
                }
                else//if only 1 tile has been clicked
                {                                           //reset clicked lists
                    deleteList(allHighlight);               //deletes all panels in list
                    clearList(allHighlight);                //resets the highlist list
                    clearList(allClicked);                  //resets all clicked list

                    highlightTile = highlight(clickedTile); //create a highlight tile
                                                            //allHighlight.Clear();
                    allHighlight.Insert(0, highlightTile);  //replace/add highlight tile as #1 in list
                    allClicked.Insert(0, clickedTile);      //replace clicked tile list #1 with new clicked

                    position.X = clickedTile.Location.X;    //allows branching from other tiles
                    position.Y = clickedTile.Location.Y;    //instead of one snake

                    if (clickedTile.unitsOnThisPanel.Any()) //if newly selected tile has a unit
                    {
                        //MessageBox.Show("panel has a unit");//for use in debugging

                        if (clickedTile.unitsOnThisPanel.Any())
                        {
                            //simultaneiously clears the array of the old selected unit and selects this one
                            allSelectedUnits[0] = clickedTile.unitsOnThisPanel.First();
                        }
                    }
                }
                pbBackground.SendToBack();
            }
        }
Example #19
0
        public void checkersMovement(Panel1 clickedTile)
        {
            if (allClicked.Any())
            {
                int a = allClicked.First().Location.X; //the tile we are going from


                int b = clickedTile.Location.X - (1 + wTile); // right location
                int c = clickedTile.Location.X + (1 + wTile); // left location


                int d = allClicked.First().Location.Y;                //the tile we are going from ;

                int goingUp = clickedTile.Location.Y + (1 + hTile);   //for use in determining if can go up

                int goingDown = clickedTile.Location.Y - (1 + hTile); //for use in determining if can go down



                int jumpRight = clickedTile.Location.X - (2 + (2 * wTile));
                int jumpLeft  = clickedTile.Location.X + (2 + (2 * wTile));

                int jumpDown = clickedTile.Location.Y - (2 + (2 * hTile));
                int jumpUp   = clickedTile.Location.Y + (2 + (2 * hTile));


                if (clickedTile.BackColor.ToArgb() == -16777216) //checks if on black tiles
                {
                    if ((a == b) || (a == c))                    //checks if one space away
                    {
                        //each color can only go up or down
                        if (unit_List_red.Contains(allSelectedUnits[0]))//if one of the units from the top
                        {
                            if (d == goingDown)
                            {
                                allSelectedUnits[0].changeLocation(clickedTile);
                            }
                        }
                        else
                        {
                            if (d == goingUp)
                            {
                                allSelectedUnits[0].changeLocation(clickedTile);
                            }
                        }
                    }
                    else if ((a == jumpRight) && (d == jumpDown))
                    {
                        Panel1 myTile = new Panel1();//will be a reference to the tile we are jumping over
                        foreach (Panel1 tileJumpedOver in tilesCreated)
                        {
                            //if tileJumpedOver's x location is
                            if ((tileJumpedOver.Location.X == b) && (tileJumpedOver.Location.Y == goingDown))
                            {
                                myTile = tileJumpedOver;
                                //MessageBox.Show(myTile.Name);
                            }
                        }

                        if (myTile.unitsOnThisPanel.Any())
                        {
                            //it is an acceptable jump

                            foreach (Unit myUnit in unit_List_black)
                            {
                                if (myUnit == myTile.unitsOnThisPanel.First())
                                {
                                    blackDefeated++;
                                }
                            }
                            foreach (Unit myUnit in unit_List_red)
                            {
                                if (myUnit == myTile.unitsOnThisPanel.First())
                                {
                                    redDefeated++;
                                }
                            }

                            //delete the unit from myTile

                            deleteUnitMethod(myTile.unitsOnThisPanel.First());
                            myTile.unitsOnThisPanel.RemoveFirst();

                            //move the unit
                            allSelectedUnits[0].changeLocation(clickedTile);
                        }
                        else
                        {
                            MessageBox.Show("illegal move");
                        }
                    }

                    else if ((a == jumpRight) && (d == jumpUp))
                    {
                        Panel1 myTile = new Panel1();//will be a reference to the tile we are jumping over
                        foreach (Panel1 tileJumpedOver in tilesCreated)
                        {
                            if ((tileJumpedOver.Location.X == b) && (tileJumpedOver.Location.Y == goingUp))
                            {
                                myTile = tileJumpedOver;
                                //MessageBox.Show(myTile.Name);
                            }
                        }

                        if (myTile.unitsOnThisPanel.Any())
                        {
                            foreach (Unit myUnit in unit_List_black)
                            {
                                if (myUnit == myTile.unitsOnThisPanel.First())
                                {
                                    blackDefeated++;
                                }
                            }
                            foreach (Unit myUnit in unit_List_red)
                            {
                                if (myUnit == myTile.unitsOnThisPanel.First())
                                {
                                    redDefeated++;
                                }
                            }


                            //it is an acceptable jump

                            //delete the unit from myTile
                            deleteUnitMethod(myTile.unitsOnThisPanel.First());
                            myTile.unitsOnThisPanel.RemoveFirst();

                            //move the unit
                            allSelectedUnits[0].changeLocation(clickedTile);
                        }
                        else
                        {
                            MessageBox.Show("illegal move");
                        }
                    }

                    else if ((a == jumpLeft) && (d == jumpDown))
                    {
                        Panel1 myTile = new Panel1();//will be a reference to the tile we are jumping over
                        foreach (Panel1 tileJumpedOver in tilesCreated)
                        {
                            if ((tileJumpedOver.Location.X == c) && (tileJumpedOver.Location.Y == goingDown))
                            {
                                myTile = tileJumpedOver;
                                //MessageBox.Show(myTile.Name);
                            }
                        }

                        if (myTile.unitsOnThisPanel.Any())
                        {
                            foreach (Unit myUnit in unit_List_black)
                            {
                                if (myUnit == myTile.unitsOnThisPanel.First())
                                {
                                    blackDefeated++;
                                }
                            }
                            foreach (Unit myUnit in unit_List_red)
                            {
                                if (myUnit == myTile.unitsOnThisPanel.First())
                                {
                                    redDefeated++;
                                }
                            }
                            //it is an acceptable jump

                            //delete the unit from myTile
                            deleteUnitMethod(myTile.unitsOnThisPanel.First());
                            myTile.unitsOnThisPanel.RemoveFirst();

                            //move the unit
                            allSelectedUnits[0].changeLocation(clickedTile);
                        }
                        else
                        {
                            MessageBox.Show("illegal move");
                        }
                    }

                    else if ((a == jumpLeft) && (d == jumpUp))
                    {
                        Panel1 myTile = new Panel1();//will be a reference to the tile we are jumping over
                        foreach (Panel1 tileJumpedOver in tilesCreated)
                        {
                            if ((tileJumpedOver.Location.X == c) && (tileJumpedOver.Location.Y == goingUp))
                            {
                                myTile = tileJumpedOver;
                                //MessageBox.Show(myTile.Name);
                            }
                        }

                        if (myTile.unitsOnThisPanel.Any())
                        {
                            foreach (Unit myUnit in unit_List_black)
                            {
                                if (myUnit == myTile.unitsOnThisPanel.First())
                                {
                                    blackDefeated++;
                                }
                            }
                            foreach (Unit myUnit in unit_List_red)
                            {
                                if (myUnit == myTile.unitsOnThisPanel.First())
                                {
                                    redDefeated++;
                                }
                            }
                            //it is an acceptable jump

                            //delete the unit from myTile
                            deleteUnitMethod(myTile.unitsOnThisPanel.First());
                            myTile.unitsOnThisPanel.RemoveFirst();

                            //move the unit
                            allSelectedUnits[0].changeLocation(clickedTile);
                        }
                        else
                        {
                            MessageBox.Show("illegal move");
                        }
                    }
                }
            }
        }
Example #20
0
        private void LoadProgram_Click(object sender, EventArgs e)
        {
            /*
             *
             * the Load_Click method must take the information from the saved text file,
             * then break it into inputs to be called by the Create_Tile method and addUnit method
             *
             */

            //read the original text file and put into the string array
            #region loadText

            string totalString   = "";
            string allTileString = "";
            string allUnitString = "";

            /*
             * try
             * {
             *  //Pass the file path and file name to the StreamReader constructor
             *  StreamReader sr = new StreamReader(mydocpath + @"\BoardGame.txt");
             *
             *
             *
             *  //Read the first line of text
             *  //allTileString = sr.ReadLine();
             *  //allUnitString = sr.ReadLine();
             *  totalString = sr.ReadLine();
             *
             *  //close the file
             *  sr.Close();
             *
             *  MessageBox.Show(totalString);
             *  char tileVSUnitDelimiter = tileAndUnitSeperator;//splits the string along this seperator which is removed
             *  string[] arrayOfUnitsAndTiles = totalString.Split(tileVSUnitDelimiter);//cut the loaded string into the tile and unit portions
             *  allTileString = arrayOfUnitsAndTiles[0];
             *  allUnitString = arrayOfUnitsAndTiles[1];
             * }
             * catch (Exception a)
             * {
             *  MessageBox.Show("Exception: " + a.Message);
             *  return;//ends the load method
             * }
             *
             */

            Stream         myStream        = null;
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.InitialDirectory = "c:\\";
            openFileDialog1.Filter           = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
            openFileDialog1.FilterIndex      = 2;
            openFileDialog1.RestoreDirectory = true;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    if ((myStream = openFileDialog1.OpenFile()) != null)
                    {
                        using (myStream)
                        {
                            // Insert code to read the stream here.
                            StreamReader myStreamReader = new StreamReader(myStream);
                            totalString = myStreamReader.ReadLine();
                            myStreamReader.Close();


                            //MessageBox.Show(totalString);
                            char     tileVSUnitDelimiter  = tileAndUnitSeperator;                   //splits the string along this seperator which is removed
                            string[] arrayOfUnitsAndTiles = totalString.Split(tileVSUnitDelimiter); //cut the loaded string into the tile and unit portions
                            allTileString = arrayOfUnitsAndTiles[0];
                            allUnitString = arrayOfUnitsAndTiles[1];
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                }
            }
            else
            {
                MessageBox.Show("Canceled Load");
                return;
            }



            #endregion loadText

            //could be turned into a method for restarting
            #region clearPreexistingStuff
            //need to clear the preexisting stuff on the board before loading
            //clear units
            if (masterUnitList.Any())
            {
                //List<Unit> tempUnitList = masterUnitList;

                foreach (Unit preexistingUnits in masterUnitList)
                {
                    //call method for removing units
                    deleteUnitMethod(preexistingUnits);
                }
                masterUnitList.Clear();
            }

            unitNum = 0;//reset count of units

            //clear tiles
            List <Panel1> allPanels = tilesCreated; //temp list of all of the tiles

            deleteList(allPanels);                  //deletes all the tiles
            tilesCreated.Clear();                   //clears all references from the master list of tiles
            numTiles = 0;                           //reset count of tiles

            #endregion clearPreexistingStuff

            #region loadTiles

            //String value = "This is a short string.";
            //MessageBox.Show(allTileString);//used to verify what is going into the loadTiles area

            if (allTileString != "")
            {
                char     delimiter1   = tileSeperator;//splits the string along this seperator which is removed
                string[] arrayOfTiles = allTileString.Split(delimiter1);

                foreach (string tileString in arrayOfTiles)
                {
                    //split the string into the attributes
                    char     delimiter3            = attributeSeperator;
                    string[] arrayOfTileAttributes = tileString.Split(delimiter3);

                    /*
                     *
                     * //attributes
                     * 0= string tileName = eachpanel.Name;
                     * 1= string tileXLocation = eachpanel.Location.X.ToString();
                     * 2= string tileYLocation = eachpanel.Location.Y.ToString();
                     * 3= string tileBackgroundImage = eachpanel.BackColor.Name;//make sure I know what this actually is
                     * 4= string tileWidth = eachpanel.Width.ToString();
                     * 5= string tileHeight = eachpanel.Height.ToString();
                     *
                     */

                    //make the tile based on the attributes
                    Panel1 newTile = new Panel1();

                    //setting the name
                    newTile.Name = arrayOfTileAttributes[0];
                    numTiles++;

                    //method for setting the Location
                    int X = 0;
                    int Y = 0;
                    int.TryParse(arrayOfTileAttributes[1], out X);
                    int.TryParse(arrayOfTileAttributes[2], out Y);
                    newTile.Location = new Point(X, Y);



                    //method for setting the dimensions
                    int height = 0;
                    int width  = 0;
                    int.TryParse(arrayOfTileAttributes[5], out height);
                    int.TryParse(arrayOfTileAttributes[4], out width);
                    newTile.Size = new Size(width, height);

                    //standard commands to add to the form
                    newTile.MouseClick += Panel_Click; //creates event for tile / addes mouseClick event
                    intersectsWith(newTile);           //checks if the new tile intersects with all other created tiles
                    tilesCreated.Add(newTile);         //adds panel to list of al tiles created

                    Controls.Add(newTile);             //adds panel to the form

                    //method for setting the color
                    int   argbValue = 0;
                    Color tileColor = new Color();
                    //tileColor = Color.FromName(arrayOfTileAttributes[3]);
                    int.TryParse(arrayOfTileAttributes[3], out argbValue);
                    tileColor = Color.FromArgb(argbValue);
                    // MessageBox.Show(tileColor.ToString());
                    newTile.BackColor = tileColor;


                    newTile.BringToFront();    //bring before the picturebox background   SAME AS below???
                    pbBackground.SendToBack(); //prevents the BG panel from covering the new highlight panel
                }
            }
            else
            {
                MessageBox.Show("incorrect format for loading tiles");
            }
            #endregion loadTiles

            #region loadUnits

            if (allUnitString != "")
            {
                char     delimeter2   = tileSeperator;
                string[] arrayOfUnits = allUnitString.Split(delimeter2);

                /*
                 * 0 = string unitName= eachUnit.getName();
                 * 1 = string tileUnitIsOn = eachUnit.getLocation().Name;//gives the name of the tile the unit is on
                 * 2 = string unitColor = eachUnit.getColor().Name;
                 */


                foreach (string unitString in arrayOfUnits)
                {
                    //split the string into the attributes
                    char     delimiter3            = attributeSeperator;
                    string[] arrayOfUnitAttributes = unitString.Split(delimiter3);
                    //make the unit based on the attributes
                    foreach (Panel1 panel in tilesCreated)
                    {
                        if (panel.Name == arrayOfUnitAttributes[1])
                        {
                            Unit thisUnit = createUnit(panel);
                            thisUnit.setName(arrayOfUnitAttributes[0]);

                            Color unitColor = Color.FromName(arrayOfUnitAttributes[2]);
                            thisUnit.setColor(unitColor);
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("no units loaded");
            }



            #endregion loadUnits
        }