Example #1
0
        public LocalDatabase()
            : base(new SQLitePlatformWinRT(), EnvPath.GetDatabaseFilePath())
        {
            //DropTable<BookCategory>();
            //DropTable<BookItem>();
            CreateTable <BookCategory>();
            CreateTable <BookItem>();

            CreateTable <ScrapbookCategory>();
            CreateTable <ScrapbookItem>();

            CreateTable <Bookmark>();
        }
Example #2
0
        public static string AddStorage(IStorageItem item, DataType type)
        {
            string token = "";

            if (type == DataType.Latest)
            {
                if (!EnvPath.IsLocalFolder(item.Path))
                {
                    token = StorageApplicationPermissions.MostRecentlyUsedList.Add(item, DateTime.Now.ToString("yyyyMMddHHmmss"));
                }
            }
            else
            {
                token = StorageApplicationPermissions.FutureAccessList.Add(item, type.ToString());
            }

            return(token);
        }
        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);
            ScrapbookCategory category = m_db.QueryScrapbookCategory(m_folderName);
            StorageFolder     folder   = await EnvPath.GetScrapbookSubFolder(category.FolderName);

            foreach (ScrapbookItem scrapItem in m_db.QueryScrapbookItemList(category))
            {
                string filePath = Path.Combine(folder.Path, scrapItem.FileName);
                try
                {
                    StorageFile storage = await StorageFile.GetFileFromPathAsync(filePath);

                    itemList.Add(new FolderListItem()
                    {
                        Name       = scrapItem.FileName,
                        Path       = filePath,
                        Token      = "",
                        Type       = FolderListItem.GetFileTypeFromStorage((StorageFile)storage),
                        ThumWidth  = (int)thumSize.Width,
                        ThumHeight = (int)thumSize.Height,
                        TextSize   = fontSize,
                    });
                }
                catch (Exception e)
                {
                    Debug.WriteLine("ScrapbookItemNavigateParameter error=" + e.ToString() + " filePath=" + filePath);
                }
            }

            return(itemList);
        }