コード例 #1
0
        private void addRow(ColoringBookVM coloringBook)
        {
            var texts = new[]
            {
                coloringBook.Name,
                coloringBook.Author,
                coloringBook.TotalPages.ToString(),
                $"{coloringBook.TotalPagesColored} ({coloringBook.TotalPagesColoredPercent:#,##0.##} %)",
            };
            var viewItem = new ListViewItem(texts);

            coloringBooksLv.Items.Add(viewItem);
        }
コード例 #2
0
        public List <ColoringBookVM> GetAll()
        {
            var items  = readFromFileOrdered();
            var result = new List <ColoringBookVM>();

            foreach (var item in items)
            {
                var coloringBook = new ColoringBookVM
                {
                    ID         = item.ID,
                    Name       = item.Name,
                    Author     = item.Author,
                    TotalPages = item.TotalPages,
                    //nevýkonné - opakované načítání souborů
                    TotalPagesColored = getColoredPagesCount(item.ID),
                };
                coloringBook.TotalPagesColoredPercent = coloringBook.TotalPages > 0
                                        ? 100.0 * coloringBook.TotalPagesColored / coloringBook.TotalPages
                                        : 0;
                result.Add(coloringBook);
            }
            return(result);
        }