private void InsertCellControls() { for (int x = 0; x < m_XCount; x++) { for (int y = 0; y < m_YCount; y++) { CellControl cellControl = new CellControl(x, y); m_CellControls[y * m_XCount + x] = cellControl; cellControl.Parent = this; } } }
private void SizeAndPositionControls() { //Ensure that the client area is always square int cellWidth = Math.Min(this.ClientSize.Height / m_YCount, this.ClientSize.Width / m_XCount); Size cellSize = new Size(cellWidth, cellWidth); for (int x = 0; x < m_XCount; x++) { for (int y = 0; y < m_YCount; y++) { CellControl cellControl = m_CellControls[y * m_XCount + x]; cellControl.Size = cellSize; cellControl.Location = new Point(cellWidth * x, cellWidth * y); } } }