Esempio n. 1
0
        private async void Btn_Click(object sender, RoutedEventArgs e)
        {
            if (passBox.Password != confirmPassBox.Password)
            {
                notification.Show("Password and confirm password are dismatched", DELAY);
                return;
            }
            if (nameBox.Text.Length < 4 || passBox.Password.Length < 4 || !emailBox.Text.Contains("@"))
            {
                notification.Show("Please input valid user name, e-mail or password", DELAY);
                return;
            }

            ShowProgress(true);
            var pass   = Util.SHA256(passBox.Password);
            var status = await NetworkSet.SignUp(nameBox.Text, emailBox.Text, pass);

            ShowProgress(false);
            if (status)
            {
                notification.Show("Sign up success", DELAY);
            }
            else
            {
                notification.Show("Confliction occured.\r\n" +
                                  "Please try again with different user name and/or e-mail.", DELAY);
            }
        }
        private async void Delete_Invoked(SwipeItem sender, SwipeItemInvokedEventArgs args)
        {
            var book    = args.SwipeControl.DataContext as BookDetail;
            var success = await NetworkSet.ChangeWishlist(book.ID, false);

            if (!success)
            {
                return;
            }
            this.WishBooks.Remove(book);
        }
Esempio n. 3
0
        private async void Delete_Invoked(SwipeItem sender, SwipeItemInvokedEventArgs args)
        {
            var danmu   = args.SwipeControl.DataContext as FullDanmu;
            var success = await NetworkSet.ChangeDanmu(danmu.ID, true);

            if (!success)
            {
                return;
            }
            this.Danmus.Remove(args.SwipeControl.DataContext as FullDanmu);
        }
Esempio n. 4
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;
        }
Esempio n. 5
0
        public async void SendDanmuPressed()
        {
            TextBox text = new TextBox
            {
                PlaceholderText = "The bullet content",
                Header          = "Please input the bullet comment you want to send"
            };
            ContentDialog dialog = new ContentDialog
            {
                Content = text,
                Title   = "Send your bullet",
                IsSecondaryButtonEnabled = true,
                PrimaryButtonText        = "Send",
                SecondaryButtonText      = "Cancle"
            };

            if (await dialog.ShowAsync() == ContentDialogResult.Primary)
            {
                if (text.Text.Length <= 2)
                {
                    notification.Show("You cannot send a danmu with such short content", 4000);
                }
                else if (text.Text.Length >= 100)
                {
                    notification.Show("You cannot send a danmu with such long content", 4000);
                }
                var  page    = GetCurrentPageNum();
                bool success = await NetworkSet.CreateDanmu(text.Text, bookId, page);

                if (success)
                {
                    this.bulletPool.Add(new LiveComment(new Danmu(0)
                    {
                        Content = text.Text
                    }, page));
                    notification.Show($"Success in sending a bullet at page {page} \"{text.Text}\"", 4000);
                }
                else
                {
                    notification.Show($"Something wrong in sending a bullet at page {page}. " +
                                      "Please try again later.", 4000);
                }
            }
        }
Esempio n. 6
0
        private async void Edit_Invoked(SwipeItem sender, SwipeItemInvokedEventArgs args)
        {
            var danmu      = args.SwipeControl.DataContext as FullDanmu;
            var orgContent = danmu.Content;
            var newContent = await Util.InputTextDialogAsync("Editing Bullet Screen",
                                                             "Please input the content of your bullet screen",
                                                             orgContent);

            if (newContent != null && newContent.Length > 0 && newContent != orgContent)
            {
                var success = await NetworkSet.ChangeDanmu(danmu.ID, false, newContent);

                if (!success)
                {
                    return;
                }
                danmu.Content  = newContent;
                danmu.EditTime = DateTime.Now;
                danmu.OnPropertyChanged("Content");
                danmu.OnPropertyChanged("EditTime");
            }
        }
        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;
            }
        }