Ejemplo n.º 1
0
        private List<ShelfRowBooks> SplitBooksIntoBookRows(out int rows)
        {
            List<ShelfRowBooks> bookRows = new List<ShelfRowBooks>();
            rows = BooksManager.AllBooks.Count / ShelfRowBooks.BOOKS_PER_ROW;
            rows += BooksManager.AllBooks.Count % ShelfRowBooks.BOOKS_PER_ROW == 0 ? 0 : 1;

            for (int i = 0; i < rows; i++)
            {
                ShelfRowBooks rowBooks = new ShelfRowBooks();
                rowBooks.CanRemoveBooks = CanRemoveBooks;
                rowBooks.RowName = string.Format("book row :{0}", i + 1);
                for (int j = 0; j < ShelfRowBooks.BOOKS_PER_ROW; j++)
                {
                    int pos = i * ShelfRowBooks.BOOKS_PER_ROW + j;
                    if (pos < BooksManager.AllBooks.Count)
                    {
                        rowBooks.Books[j] = BooksManager.AllBooks[pos];
                        rowBooks.BookCount = j + 1;
                    }
                }
                bookRows.Add(rowBooks);
            }

            return bookRows;
        }
Ejemplo n.º 2
0
 private static void AppendLastBlankBookForAddNew(int rows, List<ShelfRowBooks> bookRows)
 {
     if (bookRows[rows - 1].BookCount == ShelfRowBooks.BOOKS_PER_ROW)
     {
         ShelfRowBooks blankRow = new ShelfRowBooks();
         Book blankBook = new Book();
         blankRow.Books[0] = blankBook;
         blankRow.BookCount = 1;
         bookRows.Add(blankRow);
     }
     else
     {
         ShelfRowBooks lastRow = bookRows[rows - 1];
         lastRow.Books[lastRow.BookCount] = new Book();
         lastRow.BookCount++;
     }
 }