Exemplo n.º 1
0
        //将书架中的书籍通过邮件分享txt文件和封面
        private void MenuFlyoutItemShare_Click(object sender, RoutedEventArgs e)
        {
            var s = sender as FrameworkElement;

            shareItem = (BookInShelf)s.DataContext;
            DataTransferManager.ShowShareUI();
        }
Exemplo n.º 2
0
        //添加到书架
        public void AddBookItem(string title)
        {
            BookInShelf item = new BookInShelf(title);

            this.shelfItems.Add(item);
            BookDB.addToBookShelf(item.Id, item.Title, item.Pages);
            UpdateTile();
        }
Exemplo n.º 3
0
        //点击书架的书籍,跳转到阅读页面
        private void read_Click(object sender, ItemClickEventArgs e)
        {
            BookInShelf bookInShelf = e.ClickedItem as BookInShelf;
            string      type        = "0";
            string      id          = bookInShelf.Id;
            string      title       = bookInShelf.Title;
            string      pages       = bookInShelf.Pages;

            string[] parameter = { type, title, pages, id };
            this.Frame.Navigate(typeof(ReadPage), parameter);
        }
Exemplo n.º 4
0
        //从数据库初始化书架信息
        public void ImportDB()
        {
            shelfItems.Clear();
            ObservableCollection <string[]> books = BookDB.getBooksFromShelf();

            foreach (string[] book in books)
            {
                string      id    = book[0];
                string      title = book[1];
                string      pages = book[2];
                BookInShelf item  = new BookInShelf(id, title, pages);
                shelfItems.Add(item);
            }
        }
Exemplo n.º 5
0
        //往书架添加本地txt文件
        private async void addShelf(object sender, RoutedEventArgs e)
        {
            FileOpenPicker openPicker = new FileOpenPicker();

            openPicker.ViewMode = PickerViewMode.Thumbnail;
            openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
            openPicker.FileTypeFilter.Add(".txt");
            StorageFile file = await openPicker.PickSingleFileAsync();

            StorageFolder localFolder = ApplicationData.Current.LocalFolder;
            StorageFolder bookFolder  = await localFolder.CreateFolderAsync("books", CreationCollisionOption.OpenIfExists);

            if (file != null)
            {
                await file.CopyAsync(bookFolder, file.Name, NameCollisionOption.ReplaceExisting);

                string      title       = file.DisplayName;
                BookInShelf bookInShelf = new BookInShelf(title);
                bookInShelfViewModel.AddBookItem(title);
            }
        }