private void PictureBox1_Click(object sender, EventArgs e)
        {
            if (pictureBox1.Enabled != true)
            {
                return;
            }
            if (pictureBox1.Image == null)
            {
                return;
            }

            Point   position = pictureBox1.PointToClient(Cursor.Position);
            EndTile tile     = Program.GetEndTileAtPosition(position);

            if (tile == null)
            {
                return;
            }

            MouseEventArgs mouseEvent = (MouseEventArgs)e;

            if (mouseEvent == null)
            {
                return;
            }

            tile.ToggleTile(mouseEvent);

            ReDraw();

            SetUnsavedChanges(true);
        }
        public static EndTile GetEndTileAtPosition(Point position)
        {
            int pixelX = position.X;
            int pixelY = position.Y;

            //pixelX = 20;    //testing
            //pixelY = 15;    //testing

            int x = pixelX / tileImage.Width;
            int y = pixelY / tileImage.Height;

            //Tile tile = allTiles[x, y];

            //EndTile endTile = (EndTile)tile;
            EndTile endTile = allTiles[x, y];

            if (endTile.IsEndTile != true)
            {
                return(null);
            }

            return(endTile);
        }
        //private static void AddTile(int x, int y, bool isEndTile)
        //{
        //    Tile tile;

        //    if (isEndTile == true)
        //    {
        //        tile = new EndTile(x, y);
        //    }
        //    else
        //    {
        //        tile = new Tile(x, y);
        //    }

        //    allTiles[x, y] = tile;
        //}

        private static void AddDrawTile(int x, int y, bool isEndTile, Graphics graphics)
        {
            //Tile tile;
            EndTile tile;

            if (isEndTile == true)
            {
                //tile = new EndTile(x, y);
                tile = new EndTile(x, y, EndTile.Elec.positive, EndTile.Mech.jagged, EndTile.Plm.open);
            }
            else
            {
                //tile = new Tile(x, y);
                tile = new EndTile(x, y);
            }

            tile.Draw(graphics);

            allTiles[x, y] = tile;

            // Create mirrored version
            if (isEndTile == true)
            {
                //tile = new EndTile(6-x, y);
                tile = new EndTile(6 - x, y, EndTile.Elec.positive, EndTile.Mech.jagged, EndTile.Plm.open);
            }
            else
            {
                //tile = new Tile(6 - x, y);
                tile = new EndTile(6 - x, y);
            }

            tile.Draw(graphics);

            allTiles[6 - x, y] = tile;
        }