public async Task <IReadOnlyList <FolderListItem> > GetItemList()
        {
            if (m_db == null)
            {
                m_db = new LocalDatabase();
            }

            List <FolderListItem> itemList = new List <FolderListItem>();
            Size thumSize = await FolderListItem.GetThumSizeFromWindow();

            int          fontSize = FolderListItem.GetFontSizeFromThumImage((int)thumSize.Width);
            BookCategory category = m_db.QueryBookCategory(m_label);

            foreach (BookItem bookItem in m_db.QueryBookItemList(category))
            {
                if (!StorageApplicationPermissions.FutureAccessList.ContainsItem(bookItem.Token))
                {
                    continue;
                }
                IStorageItem storageItem = await getItemAsync(bookItem.Token);

                if (storageItem == null)
                {
                    continue;
                }

                if (storageItem.IsOfType(StorageItemTypes.Folder))
                {
                    itemList.Add(new FolderListItem()
                    {
                        Name       = storageItem.Name,
                        Path       = storageItem.Path,
                        Token      = bookItem.Token,
                        Type       = FolderListItem.FileType.Folder,
                        ThumWidth  = (int)thumSize.Width,
                        ThumHeight = (int)thumSize.Height,
                        TextSize   = fontSize,
                    });
                }
                else
                {
                    itemList.Add(new FolderListItem()
                    {
                        Name       = storageItem.Name,
                        Path       = storageItem.Path,
                        Token      = bookItem.Token,
                        Type       = FolderListItem.GetFileTypeFromStorage((StorageFile)storageItem),
                        ThumWidth  = (int)thumSize.Width,
                        ThumHeight = (int)thumSize.Height,
                        TextSize   = fontSize,
                    });
                }
            }

            return(itemList);
        }
示例#2
0
 public bool DeleteBookCategory(BookCategory category)
 {
     foreach (BookItem item in QueryBookItemList(category))
     {
         DeleteBookItem(item);
     }
     if (Delete <BookCategory>(category.Id) > 0)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#3
0
        public bool InsertBookCategory(BookCategory category)
        {
            if (QueryBookCategory(category.Label) != null)
            {
                return(false);
            }

            if (Insert(category) > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#4
0
 public IEnumerable <BookItem> QueryBookItemList(BookCategory category)
 {
     return(Table <BookItem>().Where(x => x.BookCategoryId == category.Id));
 }