Ejemplo n.º 1
0
        private List<PrintPage> BuildPages(List<PrintRow> allEntities, List<PrintRow> initialEntities)
        {
            List<PrintPage> pages = new List<PrintPage>();
            int pageCount = 0;
            while (allEntities.Count > 0)
            {
                pageCount++;
                int itemsPerPage = maxItemsPerPage;
                if (pageCount == 1)
                {
                    itemsPerPage = maxItemsForFirstPage;
                }
                var newGroup = allEntities.Take(itemsPerPage);
                var initialNewGroup = initialEntities.Take(itemsPerPage);
                var newPrintPage = new PrintPage() { Rows = new List<PrintRow>() };
                foreach (var item in newGroup)
                {
                    int indexOf = newGroup.ToList().IndexOf(item);
                    var newRow = new PrintRow()
                    {
                        Description = item.Description,
                        NrCrt = item.NrCrt,
                        Value = item.Value,
                        Type = item.Type,
                    };
                    if (initialEntities.Count > indexOf)
                    {
                        newRow.InitialValue = initialEntities[indexOf].Value;
                    }
                    newPrintPage.Rows.Add(newRow);
                }
                pages.Add(newPrintPage);

                allEntities = allEntities.Skip(itemsPerPage).ToList();
                initialEntities = initialEntities.Skip(itemsPerPage).ToList();
            }

            return pages;
        }
Ejemplo n.º 2
0
        private List<PrintPage> BuildPages(List<PrintRow> allEntities)
        {
            List<PrintPage> pages = new List<PrintPage>();
            int pageCount = 0;
            while (allEntities.Count > 0)
            {
                pageCount++;
                int itemsPerPage = maxItemsPerPage;
                if (pageCount == 1)
                {
                    itemsPerPage = maxItemsForFirstPage;
                }
                var newGroup = allEntities.Take(itemsPerPage);
                var newPrintPage = new PrintPage() { Rows = new List<PrintRow>(), LastPageVisibility = Visibility.Collapsed };
                foreach (var item in newGroup)
                {
                    newPrintPage.Rows.Add(new PrintRow()
                    {
                        Description = item.Description,
                        NrCrt = item.NrCrt,
                        Value = item.Value,
                        Type = item.Type
                    });
                }
                pages.Add(newPrintPage);

                allEntities = allEntities.Skip(itemsPerPage).ToList();
            }

            return pages;
        }