Esempio n. 1
0
 void CreateCells(int columnCount, int rowCount)
 {
     allCells = new CellCollection(Enumerable.Range(0, columnCount * rowCount).Select(delegate(int index)
     {
         int column, row;
         GridMath.CalculateColumnRow(index, columnCount, out column, out row);
         return(new Cell.Cell(column, row));
     }));
 }
        public IGrid Create()
        {
            SquareGrid grid = new SquareGrid(gridConfig);

            int cellCount = gridConfig.RowCount * gridConfig.ColumnCount;

            for (int i = 0; i < cellCount; i++)
            {
                int row, column;
                GridMath.CalculateColumnRow(i, gridConfig.ColumnCount, out column, out row);
                grid.GetCell(column, row).Content = randomContentProvider.Get();
            }

            return(grid);
        }
Esempio n. 3
0
        public void CalculateColumnRow()
        {
            int column = 5;
            int row    = 10;
            int total  = column * row;

            int calcColumn;
            int calcRow;

            int currentColumn = 0;
            int currentRow    = 0;

            for (int i = 0; i < total; i++)
            {
                GridMath.CalculateColumnRow(i, column, out calcColumn, out calcRow);
                Assert.AreEqual(currentColumn, calcColumn, string.Format("Column calculation wrong - cell: {0}", i));
                Assert.AreEqual(currentRow, calcRow, string.Format("Row calculation wrong - cell: {0}", i));
                if (++currentColumn >= column)
                {
                    currentColumn = 0;
                    currentRow++;
                }
            }
        }