public BookCollectionControl(BookDetailCollection collection, bool isBillboard)
 {
     this.BookCollection = collection;
     this.IsBillboard    = isBillboard;
     this.WaitLoading();
     this.InitializeComponent();
 }
예제 #2
0
 private void Init()
 {
     foreach (BooksOrderType t in Enum.GetValues(typeof(BooksOrderType)))
     {
         BookOrders.Add(new ComboBoxItem {
             Content = t.EnumToString()
         });
     }
     foreach (BillboardsOrderType t in Enum.GetValues(typeof(BillboardsOrderType)))
     {
         BillboardOrders.Add(new ComboBoxItem {
             Content = t.EnumToString()
         });
     }
     foreach (ReadlistsOrderType t in Enum.GetValues(typeof(ReadlistsOrderType)))
     {
         ReadListOrders.Add(new ComboBoxItem {
             Content = t.EnumToString()
         });
     }
     Books = new BookDetailCollection(this.ToQueryObject(ContentType.Books),
                                      "Search result of " + this.QueryText, "");
     Billboards = new BooklistCollection(true, this.ToQueryObject(ContentType.Billboards));
     ReadLists  = new BooklistCollection(false, this.ToQueryObject(ContentType.ReadLists));
 }
예제 #3
0
        internal static async Task <bool> GetBookQuasiDetailContents(BookDetailCollection collection, int[] ids)
        {
            foreach (int id in ids)
            {
                var book = new BookDetail(id);
                await GetBookQuasiDetail(book);

                collection.Books.Add(book);
            }
            return(true);
        }
예제 #4
0
        private async void Refresh()
        {
            // bypass the BooklistCollection.Reload
            listControl.WaitLoading();
            this.ReadLists.Clear();
            var ids = await NetworkGet.GetMyFollowedReadLists();

            foreach (int id in ids)
            {
                var read = new BookDetailCollection(false, id);
                await read.ReloadBooks(false, id, int.MaxValue);                 // get all books

                this.ReadLists.Add(read);
            }
            listControl.Booklist.Finished = true;
        }
예제 #5
0
        public static async Task GetTitleDescription(BookDetailCollection collection, bool isBillboard, int id)
        {
            var query = new QueryObject("GetTitleDescription")
            {
                IsBillboard = isBillboard,
                BookListId  = id
            };

            if (Storage.Test)
            {
                collection.Title       = "Bo4PSSm0";
                collection.Description = "Bo4PSSm0Po83pIiC";
                if (isBillboard)
                {
                    return;
                }
                collection.CreateUser   = "******";
                collection.EditTime     = DateTime.Now;
                collection.FollowAmount = 123;
                collection.Followed     = false;
                return;
            }

            var recv = await Connection.SendAndReceive.GlobalLock(query);

            collection.Title       = recv.Title;
            collection.Description = recv.Description;
            collection.OnPropertyChanged("Title");
            collection.OnPropertyChanged("Description");
            if (isBillboard)
            {
                return;
            }
            collection.CreateUser   = recv.CreateUser;
            collection.EditTime     = recv.TimeStap.Value.GetTime();
            collection.FollowAmount = recv.FollowAmount.Value;
            collection.Followed     = recv.Followed.Value;
            collection.OnPropertyChanged("CreateUser");
            collection.OnPropertyChanged("EditTime");
            collection.OnPropertyChanged("FollowAmount");
            collection.OnPropertyChanged("Followed");
        }
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            var bookId = this.detail.ID;

            switch ((sender as Button).Tag as string)
            {
            case "buy":
                await Util.BuyBookAsync(bookId, this.detail, null, this.notification);

                this.Detail = detail;
                break;

            case "readlist":
                var ids = await NetworkGet.GetMyReadListsWithout(bookId);

                List <string> titles = new List <string>(ids.Length);
                foreach (int id in ids)
                {
                    var readlist = new BookDetailCollection();
                    await NetworkGet.GetTitleDescription(readlist, false, id);

                    titles.Add(readlist.Title);
                }
                if (titles.Count <= 0)
                {
                    break;
                }
                var combo = new ComboBox()
                {
                    FontSize      = 16,
                    ItemsSource   = titles,
                    SelectedIndex = 0
                };
                var dialog = new ContentDialog()
                {
                    Content = combo,
                    Title   = "Add Book to Read List",
                    IsSecondaryButtonEnabled = true,
                    PrimaryButtonText        = "Confirm",
                    SecondaryButtonText      = "Cancel"
                };
                if (await dialog.ShowAsync() == ContentDialogResult.Primary)
                {
                    var successful = await NetworkSet.ChangeReadList(ids[combo.SelectedIndex],
                                                                     BookListChangeType.AddBook,
                                                                     bookId, null);

                    if (successful)
                    {
                        this.detail.CanAddReadList = titles.Count - 1 > 0;
                        this.Detail = detail;
                        notification.Show("Success in adding book to your read list" +
                                          $"\"{combo.SelectedItem as string}\"", 4000);
                    }
                    else
                    {
                        notification.Show("Something wrong in adding book to your read list" +
                                          $"\"{combo.SelectedItem as string}\". " +
                                          "Please try again later.", 4000);
                    }
                }
                break;

            case "wishlist":
                var success = await NetworkSet.ChangeWishlist(bookId, true);

                if (success)
                {
                    this.detail.CanAddWishList = false;
                    this.Detail = detail;
                    notification.Show("Success in adding book to your wish list", 4000);
                }
                else
                {
                    notification.Show("Something wrong in adding book to your wish list. " +
                                      "Please try again later.", 4000);
                }
                break;

            case "preview":
                var content = (sender as Button).Content as string;
                if (content == "Read")
                {
                    var pdfUrl = await NetworkGet.DownloadBook(bookId);

                    var pass = await NetworkGet.GetBookKey(bookId);

                    if (pass == null || pass.Length == 0)
                    {
                        notification.Show("It seems that you haven't bought the book. " +
                                          "Please try again later.", 4000);
                        return;
                    }
                    Util.MainElem.NavigateToReadBook(bookId, pdfUrl, pass);
                }
                else
                {
                    var pdfUrl = await NetworkGet.GetBookPreview(bookId);

                    Util.MainElem.NavigateToReadBook(bookId, pdfUrl);
                }
                break;

            default:
                return;
            }
        }