public System.Windows.Forms.Control[] AddElementToScreen(int i_NumberOfTypes, Bitmap i_Color, Tile i_Tile) { PictureBox tempTile; const int k_NumberOfTriesToRandom = 10; int numberOfTriesToRandomCTR = 0; System.Windows.Forms.Control[] tempList = new System.Windows.Forms.Control[i_NumberOfTypes]; int panellRange = i_Tile.k_StartingCord + i_Tile.m_Bound * i_Tile.m_TileSize; //int panellRange = i_Tile.k_StartingCord + i_Tile.m_Bound * (i_Tile.m_TileSize + i_Tile.k_SpaceBetweenTiles) - i_Tile.k_SpaceBetweenTiles; for (int i = 0; i < i_NumberOfTypes; i++) { tempTile = new PictureBox(); tempTile.Visible = true; tempTile.Width = i_Tile.m_TileSize; tempTile.Height = i_Tile.m_TileSize; tempTile.Tag = m_TileIndex++; tempTile.Top = ItemUtils.getRandomCordInRangeFreeFlow(panellRange, i_Tile.m_TileSize); tempTile.Left = ItemUtils.getRandomCordInRangeFreeFlow(panellRange, i_Tile.m_TileSize); while ((ItemUtils.isOnTop(tempTile.Top, tempTile.Left, i_Tile.m_TileSize, m_ElementCord)) && numberOfTriesToRandomCTR < k_NumberOfTriesToRandom) { tempTile.Top = ItemUtils.getRandomCordInRangeFreeFlow(panellRange, i_Tile.m_TileSize); tempTile.Left = ItemUtils.getRandomCordInRangeFreeFlow(panellRange, i_Tile.m_TileSize); numberOfTriesToRandomCTR++; } numberOfTriesToRandomCTR = 0; this.m_ElementCord.Add(Tuple.Create(tempTile.Top, tempTile.Left)); tempTile.SizeMode = PictureBoxSizeMode.StretchImage; tempTile.Image = i_Color; tempList[i] = tempTile; } return(tempList); }
Control[] IMove.AddElementToScreen(int i_NumberOfTypes, Bitmap i_Color, Tile i_Tile) { PictureBox tempTile; System.Windows.Forms.Control[] tempList = new System.Windows.Forms.Control[i_NumberOfTypes]; int panellRange = i_Tile.k_StartingCord + i_Tile.m_Bound * i_Tile.m_TileSize; for (int i = 0; i < i_NumberOfTypes; i++) { tempTile = new PictureBox(); tempTile.Visible = true; tempTile.Width = i_Tile.m_TileSize; tempTile.Height = i_Tile.m_TileSize; tempTile.Tag = m_TileIndex++; int rowIndex = ItemUtils.getRandomCordInRangeMatrix(i_Tile.m_Bound); int colIndex = ItemUtils.getRandomCordInRangeMatrix(i_Tile.m_Bound); while (m_Grid[rowIndex, colIndex].ID == 0) { rowIndex = ItemUtils.getRandomCordInRangeMatrix(i_Tile.m_Bound); colIndex = ItemUtils.getRandomCordInRangeMatrix(i_Tile.m_Bound); } m_Grid[rowIndex, colIndex].ID == tempTile.Tag tempTile.Top = tempTile.Left = this.m_ElementCord.Add(Tuple.Create(tempTile.Top, tempTile.Left)); tempTile.SizeMode = PictureBoxSizeMode.StretchImage; tempTile.Image = i_Color; tempList[i] = tempTile; } return(tempList); }