Beispiel #1
0
        /// <summary>
        /// Navigate to detail page
        /// </summary>
        private void GridView_ItemClick(object sender, PointerRoutedEventArgs e)
        {
            var item       = sender as StackPanel;
            var dataToPass = item.DataContext as BookSummary;

            if (NetworkGet.IsValidID(dataToPass.ID))
            {
                switch ((BookSummaryCollectionType)item.Tag)
                {
                case BookSummaryCollectionType.NewBooks:
                    NBGrid.PrepareConnectedAnimation(Util.TO_BOOK_DETAIL, dataToPass, "NBImage");
                    break;

                case BookSummaryCollectionType.TopBooks:
                    TBGrid.PrepareConnectedAnimation(Util.TO_BOOK_DETAIL, dataToPass, "TBImage");
                    break;

                case BookSummaryCollectionType.PersonalRecommands:
                    PRGrid.PrepareConnectedAnimation(Util.TO_BOOK_DETAIL, dataToPass, "PRImage");
                    break;

                default:
                    return;
                }
                this._navigateType = (BookSummaryCollectionType)item.Tag;
                this._navigateItem = dataToPass;
                Util.MainElem.NavigateToBookDetail(dataToPass, typeof(BookDetailPage));
            }
        }
        /// <summary>
        /// Navigate to detail page
        /// </summary>
        private void Book_Pointed(object sender, ItemClickEventArgs e)
        {
            var dataToPass = e.ClickedItem as BookDetail;

            if (NetworkGet.IsValidID(dataToPass.ID))
            {
                bookGrid.PrepareConnectedAnimation(Util.TO_BOOK_DETAIL, dataToPass, "bookCover");
                this._navigateItem = dataToPass;
                Util.MainElem.NavigateToBookDetail(dataToPass, typeof(BookDetailPage));
            }
        }
        /// <summary>
        /// Navigate to another detail page
        /// </summary>
        private void StackPanel_PointerReleased(object sender, PointerRoutedEventArgs e)
        {
            var dataToPass = (BookSummary)((StackPanel)sender).DataContext;

            if (NetworkGet.IsValidID(dataToPass.ID))
            {
                relatedBookGrid.PrepareConnectedAnimation(Util.TO_BOOK_DETAIL, dataToPass, "relateBookImage");
                this._navigateItem = dataToPass;
                Util.MainElem.NavigateToBookDetail(dataToPass, typeof(BookDetailPage));
            }
        }
Beispiel #4
0
        private async void UpdateLabels()
        {
            Labels.Clear();
            var mainLabels = await NetworkGet.GetMainLabels();

            foreach (var s in mainLabels)
            {
                var l = new Label(s);
                Labels.Add(l);
                l.RetriveSubs();
            }
        }
Beispiel #5
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            if ((string)btn.Content == "Press to logout")
            {
                ShowProgress(true);
                if (await NetworkSet.Logout())
                {
                    notification.Show("Logout success", DELAY);
                    btn.Content = "Confirm";
                    ShowProgress(false);
                }
                else
                {
                    ShowProgress(false);
                    notification.Show("Please try again later", DELAY);
                }
                signUpBtn.Visibility = Storage.SignUpVisibility;
                return;
            }

            if (nameBox.Text.Length < 4 || passBox.Password.Length < 4)
            {
                notification.Show("Please input valid user name & password", DELAY);
                return;
            }

            ShowProgress(true);
            var username = nameBox.Text;
            var pass     = Util.SHA256(passBox.Password);
            var status   = await NetworkGet.Login(username, pass);

            ShowProgress(false);
            switch (status)
            {
            case LoginStatus.Success:
                nameBox.IsEnabled = false;
                passBox.IsEnabled = false;
                notification.Show("Login success", DELAY);
                btn.Content = "Press to logout";
                break;

            case LoginStatus.NoSuchUser:
                notification.Show("No such user name or e-mail", DELAY);
                break;

            case LoginStatus.WrongPassword:
                notification.Show("Wrong password", DELAY);
                break;
            }
            signUpBtn.Visibility = Storage.SignUpVisibility;
        }
Beispiel #6
0
        private async void Refresh()
        {
            this.loadingControl.IsLoading = true;
            this.Danmus.Clear();
            var ids = await NetworkGet.GetMyDanmus();

            foreach (int id in ids)
            {
                var dan = new FullDanmu(id);
                await NetworkGet.GetFullDanmuContent(dan);

                this.Danmus.Add(dan);
            }
            this.loadingControl.IsLoading = false;
        }
Beispiel #7
0
        /// <summary>
        /// Navigate to read book page
        /// </summary>
        private async void AdaptiveGridView_ItemClick(object sender, ItemClickEventArgs e)
        {
            var book   = e.ClickedItem as BookSummary;
            var pdfUrl = await NetworkGet.DownloadBook(book.ID);

            var password = await NetworkGet.GetBookKey(book.ID);

            if (password == null || password.Length == 0)
            {
                notification.Show("It seems that you do not own the book, " +
                                  "please try again", 4000);
                return;
            }
            Util.MainElem.NavigateToReadBook(book.ID, pdfUrl, password);
        }
Beispiel #8
0
        private async void Refresh()
        {
            this.MyReviews.Clear();
            loadingControl.IsLoading = true;
            var ids = await NetworkGet.GetMyReviews();

            foreach (int id in ids)
            {
                var review = new Review(id);
                await NetworkGet.GetReview(review);

                this.MyReviews.Add(review);
            }
            loadingControl.IsLoading = false;
        }
Beispiel #9
0
        internal async Task Reload()
        {
            this.Danmus.Clear();
            this.Finish = false;
            // Read global settings to find how many danmus
            var ids = await NetworkGet.GetDanmuOfBook(this.BookId, this.PageNum);

            foreach (int id in ids)
            {
                var dan = new Danmu(id);
                await NetworkGet.GetDanmuContent(dan);

                this.Danmus.Add(dan);
            }
            this.Finish = true;
        }
Beispiel #10
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;
        }
        private async void Refresh()
        {
            this.loadingControl.IsLoading = true;
            this.WishBooks.Clear();
            var ids = await NetworkGet.GetMyWishlist();

            foreach (int id in ids)
            {
                var book = new BookDetail(id);
                await NetworkGet.GetBookQuasiDetail(book);

                book.AddPrice = await NetworkGet.GetAddPrice(id);

                this.WishBooks.Add(book);
            }
            this.loadingControl.IsLoading = false;
        }
        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;
            }
        }