Пример #1
0
 private void SetData(int pageindex)
 {
     Task.Run(async() =>
     {
         string url  = ViewModelInstance.Instance.UrlService.GetRankListPage(pageindex.ToString());
         string html = await GetHtmlData(url);
         return(html);
     }).ContinueWith((result) =>
     {
         if (result.Result != null)
         {
             DispatcherHelper.CheckBeginInvokeOnUI(() =>
             {
                 bool rs = SetBookList(result.Result.ToString(), pageindex);
                 if (!rs)
                 {
                     ToastHeplper.ShowMessage(" 第" + pageindex + "页数据加载失败");
                 }
                 else
                 {
                     ToastHeplper.ShowMessage("已加载第" + pageindex + "页,共8页");
                 }
             });
         }
     });
 }
Пример #2
0
        public static void GoBack(object sender = null)
        {
            if (ContentFrame.CanGoBack)
            {
                try
                {
                    //CancleHttpRequest();
                    ContentFrame.GoBack();
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                }
            }
            else
            {
                //  bool result = await App.CheckIfHasDownloadTasks();

                if (true)
                {
                    if (CheckIfShutDown())
                    {
                        Application.Current.Exit();
                    }
                    else
                    {
                        ToastHeplper.ShowMessage("再按一次返回键退出");
                    }
                }
            }
        }
Пример #3
0
 public void SetData()
 {
     //设置编辑模式为false
     IsEditing = false;
     Task.Run(async() =>
     {
         string html = await GetHtmlData();
         return(html);
     }).ContinueWith((result) =>
     {
         if (result.Result != null)
         {
             string html = result.Result;
             DispatcherHelper.CheckBeginInvokeOnUI(() =>
             {
                 if (html.Contains("退出") && html.Contains("站长留言") && html.Contains("我的书架"))
                 {
                     SetBookList(html);
                 }
                 else if (html.Contains("您还没有登录"))
                 {
                     ToastHeplper.ShowMessage("您还没有登录");
                     ViewModelInstance.Instance.MainPageViewModelInstance.ChangeLoginState(false);
                 }
                 else
                 {
                     ToastHeplper.ShowMessage("获取数据失败");
                 }
             });
         }
     });
 }
Пример #4
0
        private async void DeleteDownLoadItem(DowmLoadEntity entity)
        {
            entity.IsPause = true;
            await Task.Delay(800);

            if (entity.IsCompleted)
            {
                ToastHeplper.ShowMessage(entity.Entity.BookName + "已下载完毕,正在处理数据,无法取消");
                return;
            }
            this.DownLoadList.Remove(entity);
            try
            {
                string path = Path.Combine(AppDataPath.GetLocalBookFolderPath(), entity.Entity.BookID + ".db");
                if (File.Exists(path))
                {
                    System.IO.File.Delete(AppDataPath.GetBookDBPath(entity.Entity.BookID));
                }
            }
            catch (Exception)
            {
            }
            if (this.DownLoadList.Count == 0)
            {
                IsDownLoading = false;
            }
        }
Пример #5
0
        private void SetData(int pageIndex)
        {
            if (IsLoading)
            {
                return;
            }

            Task.Run(async() =>
            {
                string html = await LoadPageDataByIndex(pageIndex);
                return(html);
            }).ContinueWith((result) =>
            {
                DispatcherHelper.CheckBeginInvokeOnUI(() =>
                {
                    if (NavigationService.ContentFrame.Content is UpdateChapterPage)
                    {
                        if (result.Result != null && SetBookList(result.Result.ToString(), pageIndex))
                        {
                            ToastHeplper.ShowMessage("已加载第" + PageIndex + "页,共" + PageCount + "页");
                        }
                        else
                        {
                            ToastHeplper.ShowMessage("未能获取最新章节数据");
                        }
                    }
                });
            });
        }
Пример #6
0
        private void OnBookItemSelectedCommand(object obj)
        {
            BookEntity entity = obj as BookEntity;

            if (IsEditing)
            {
                entity.IsSelected = !entity.IsSelected;
                return;
            }
            else
            {
                if (entity == null || entity.CatalogList == null || entity.CatalogList.Count == 0)
                {
                    ToastHeplper.ShowMessage("获取数据有误");
                    return;
                }

                if (string.IsNullOrEmpty(entity.LastReadChapterUrl))
                {
                    var item = entity.CatalogList.FirstOrDefault();
                    entity.LastReadChapterUrl  = item.CatalogUrl;;
                    entity.LastReadChapterName = item.CatalogName;
                }
                NavigationService.NavigateTo(typeof(BookContentPage), entity);
            }
        }
Пример #7
0
        private bool CheckInput()
        {
            bool result = true;

            if (string.IsNullOrEmpty(this.UserName))
            {
                ToastHeplper.ShowMessage("请输入用户名");
                return(false);
            }

            if (string.IsNullOrEmpty(this.PassWord))
            {
                ToastHeplper.ShowMessage("请输入密码");
                return(false);
            }

            if (string.IsNullOrEmpty(this.PassWord2))
            {
                ToastHeplper.ShowMessage("请输入确认密码");
                return(false);
            }
            if (!this.PassWord2.Equals(this.PassWord))
            {
                ToastHeplper.ShowMessage("两次密码不一致");
                return(false);
            }
            return(result);
        }
Пример #8
0
        private async void OnLoginCommand(object obj)
        {
            if (IsLoading)
            {
                return;
            }
            else
            {
                IsLoading = true;
                string postdata = string.Empty;
                string html     = string.Empty;
                try
                {
                    if (string.IsNullOrEmpty(this.UserName) || string.IsNullOrEmpty(this.Password))
                    {
#if DEBUG
                        postdata = "username=918201&userpass=8166450";
#endif

#if  !DEBUG
                        ToastHeplper.ShowMessage("用户名和密码不能为空。");
                        return;
#endif
                    }
                    else
                    {
                        postdata = "username="******"&userpass="******"{\"success\":true}"))
                    {
                        ToastHeplper.ShowMessage("登陆成功");

                        ViewModelInstance.Instance.SettingPageViewModelInstance.SetAutoLogin(IsAutoLogin);
                        SetCookie(ViewModelInstance.Instance.UrlService.GetLoginPage(), IsAutoLogin);
                        ViewModelInstance.Instance.MainPageViewModelInstance.ChangeLoginState(true);

                        NavigationService.ContentFrame.Navigate(typeof(HomePage));
                        NavigationService.ClearStack();
                    }
                    else
                    {
                        ToastHeplper.ShowMessage("账号或密码错误,请重新输入。");
                    }
                }
                catch (Exception)
                {
                    return;
                }
                finally
                {
                    IsLoading = false;
                }
            }
        }
Пример #9
0
        private void QQTextButton_Click(object sender, RoutedEventArgs e)
        {
            string      str = "568856882";
            DataPackage dp  = new DataPackage();

            dp.SetText(str);
            Clipboard.SetContent(dp);
            ToastHeplper.ShowMessage("已复制群号到剪切板");
        }
Пример #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="str"> 0  上一章  1 下一章</param>
        public void OnSwtichCommand(object str, bool page = false)
        {
            if (IsLoading)
            {
                return;
            }
            try
            {
                if (this.BookEntity.CatalogList == null || this.BookEntity.CatalogList.Count <= 1)
                {
                    ToastHeplper.ShowMessage("暂未获取到章节列表,无法切换");
                    return;
                }

                BookCatalog temp = null;
                //上一章
                if (str.ToString().Equals("0"))
                {
                    temp = GetPreCatalog();
                    this.NextCatalogContent = this.CurrentCatalogContent;
                }
                //下一章
                else if (str.ToString().Equals("1"))
                {
                    if (!string.IsNullOrEmpty(NextCatalogContent))
                    {
                        string tempStr = NextCatalogContent;
                        NextCatalogContent = null;
                        SetCurrentContent(NextCatalog, tempStr);
                        return;
                    }
                    else
                    {
                        temp = GetNextCatalog();
                    }
                }
                else if (str is BookCatalog)
                {
                    temp = str as BookCatalog;
                    this.NextCatalogContent = null;
                }

                if (temp != null && temp.CatalogName != null && temp.CatalogUrl != null)
                {
                    SetData(temp);
                }
                else
                {
                    NavigationService.NavigateTo(typeof(BookCatalogPage), this.BookEntity);
                    return;
                }
            }
            catch (Exception)
            {
                NavigationService.NavigateTo(typeof(BookCatalogPage), this.BookEntity);
            }
        }
Пример #11
0
        private void AlipayTextButton_Click(object sender, RoutedEventArgs e)
        {
            string      str = "*****@*****.**";
            DataPackage dp  = new DataPackage();

            dp.SetText(str);
            Clipboard.SetContent(dp);
            ToastHeplper.ShowMessage("已复制支付婊账号到剪切板");
        }
Пример #12
0
 private void OnSearchCommand(object obj)
 {
     this.SearchResultList.Clear();
     if (obj == null || string.IsNullOrEmpty(obj.ToString()))
     {
         ToastHeplper.ShowMessage("请输入搜索条件");
         return;
     }
     SetData(obj.ToString());
 }
Пример #13
0
        public async void AddNewDownloadItem(BookEntity entity)
        {
            if (this.DownLoadList.ToList().FirstOrDefault(p => p.Entity.BookID == entity.BookID) != null)
            {
                ToastHeplper.ShowMessage("已经在下载队列中");
                return;
            }

            if (this.DownLoadList.Count == maxDownloadCount)
            {
                ToastHeplper.ShowMessage("最多同时下载" + maxDownloadCount + "本");
                return;
            }

            DowmLoadEntity temp = new DowmLoadEntity();

            temp.Entity = entity.Clone();

            //无网络
            if (NetworkHelper.Current.Network == 4)
            {
                ToastHeplper.ShowMessage("无网络连接,请检查网络后重试");
                return;
            }
            //wifi
            else if (NetworkHelper.Current.Network == 3)
            {
                StartNew(temp);
            }
            //流量
            else
            {
                if (!ViewModelInstance.Instance.SettingPageViewModelInstance.IfDownloadInWAAN)
                {
                    var msgDialog = new Windows.UI.Popups.MessageDialog("你现在使用的是手机流量,确定下载?\n你可以在设置中取消此提示。")
                    {
                        Title = "使用流量下载"
                    };
                    msgDialog.Commands.Add(new Windows.UI.Popups.UICommand("我是土豪", uiCommand =>
                    {
                        StartNew(temp);
                    }));
                    msgDialog.Commands.Add(new Windows.UI.Popups.UICommand("还是算了吧", uiCommand =>
                    {
                        return;
                    }));
                    await msgDialog.ShowAsync();
                }
                else
                {
                    StartNew(temp);
                }
            }
        }
Пример #14
0
        public void RemoveBookList(List <BookEntity> removeBookList)
        {
            if (IsLoading)
            {
                return;
            }
            IsLoading = true;

            Task.Run(async() =>
            {
                bool result = true;
                foreach (var item in removeBookList)
                {
                    if (!IsLoading)
                    {
                        result = false;
                        break;
                    }
                    string url  = ViewModelInstance.Instance.UrlService.GetBookShelfPage() + "?id=" + item.BookID;
                    string html = await http.WebRequestGet(url);
                    if (html.Contains("取消收藏成功"))
                    {
                        DispatcherHelper.CheckBeginInvokeOnUI(() =>
                        {
                            ShelfBookList.Remove(item);
                        });
                    }
                    else
                    {
                        result = false;
                    }
                }
                return(result);
            }).ContinueWith((result) =>
            {
                DispatcherHelper.CheckBeginInvokeOnUI(() =>
                {
                    IsLoading = false;
                    if (result.Result)
                    {
                        //   ToastHeplper.ShowMessage("操作完毕");
                        removeBookList.Clear();
                        OnEditCommand(false);
                        RefreshList();
                    }
                    else
                    {
                        ToastHeplper.ShowMessage("取消收藏失败。");
                    }
                }
                                                      );
            });
        }
Пример #15
0
        private async void OnClearCommand(object obj)
        {
            if (this.BookList.Count < 1)
            {
                return;
            }

            if (!IsEditing)
            {
                return;
            }

            int count = 0;

            ObservableCollection <BookEntity> tempList = new ObservableCollection <BookEntity>();

            foreach (var item in this.BookList)
            {
                if (item.IsSelected)
                {
                    tempList.Add(item);
                    count++;
                }
            }
            if (count == 0)
            {
                ToastHeplper.ShowMessage("请选择需要删除的记录");
                return;
            }

            var msgDialog = new Windows.UI.Popups.MessageDialog("\n确定删除历史记录?")
            {
                Title = "历史记录"
            };

            msgDialog.Commands.Add(new Windows.UI.Popups.UICommand("确定", uiCommand =>
            {
                foreach (var item in tempList)
                {
                    this.BookList.Remove(item);
                    DBHistory.DeleteHistory(AppDataPath.GetHistoryDBPath(), item);
                }

                this.InitData();
                SetBookEditStatus(false);
            }));
            msgDialog.Commands.Add(new Windows.UI.Popups.UICommand("取消", uiCommand =>
            {
                return;
            }));
            await msgDialog.ShowAsync();
        }
Пример #16
0
 private void OnRequestCommand(object obj)
 {
     if (IsLoading)
     {
         return;
     }
     if (PageIndex == PageCount)
     {
         ToastHeplper.ShowMessage("已经是最后一页");
         return;
     }
     SetData(PageIndex + 1);
 }
Пример #17
0
 private void OnPrePageCommandd(object obj)
 {
     if (IsLoading)
     {
         return;
     }
     if (PageIndex == 1)
     {
         ToastHeplper.ShowMessage("已经是第一页");
         return;
     }
     SetData(PageIndex - 1);
 }
Пример #18
0
        public void SetData()
        {
            if (IsLoading)
            {
                return;
            }
            DispatcherHelper.CheckBeginInvokeOnUI(() =>
            {
                IsLoading = true;
            });

            Task.Run(async() =>
            {
                string html = await GetHtmlData();
                return(html);
            }).ContinueWith((result) =>
            {
                DispatcherHelper.CheckBeginInvokeOnUI(() =>
                {
                    try
                    {
                        if (result != null)
                        {
                            if (SetBookList(result.Result))
                            {
                                ToastHeplper.ShowMessage("数据已更新 ");
                            }
                            else
                            {
                                throw new Exception();
                            }
                        }
                        else
                        {
                            throw new Exception();
                        }
                    }
                    catch (Exception)
                    {
                        ToastHeplper.ShowMessage("未能获取数据 ");
                    }
                    finally
                    {
                        DispatcherHelper.CheckBeginInvokeOnUI(() =>
                        {
                            IsLoading = false;
                        });
                    }
                });
            });
        }
Пример #19
0
        private void OnRefreshCommand(object obj)
        {
            if (IsLoading)
            {
                return;
            }

            if (string.IsNullOrEmpty(SearchPara))
            {
                ToastHeplper.ShowMessage("请输入搜索条件");
                return;
            }
            SetData(SearchPara);
        }
Пример #20
0
        public void SetBookList(string html)
        {
            if (!string.IsNullOrEmpty(html))
            {
                var list = AnalysisSoduService.GetBookShelftListFromHtml(html);
                if (list == null)
                {
                    this.IsShow = true;
                }
                else
                {
                    this.ShelfBookList?.Clear();
                    this.IsShow = false;

                    if (list.Count > 0)
                    {
                        var temp = list.OrderByDescending(p => DateTime.Parse(p.UpdateTime)).ToList();
                        foreach (var item in temp)
                        {
                            var entity = DBBookShelf.GetBook(AppDataPath.GetBookShelfDBPath(), item);
                            if (!string.IsNullOrEmpty(entity?.LastReadChapterName))
                            {
                                item.LastReadChapterName = entity.LastReadChapterName;
                                var sim = LevenshteinDistancePercent(item.LastReadChapterName, item.NewestChapterName);
                                if (sim)
                                {
                                    item.UnReadCountData = "";
                                }
                                else
                                {
                                    item.UnReadCountData = "(有更新)";
                                }
                            }
                            else
                            {
                                item.UnReadCountData     = "(有更新)";
                                item.LastReadChapterName = item.NewestChapterName;
                            }
                            ShelfBookList.Add(item);
                        }
                        DBBookShelf.ClearBooks(AppDataPath.GetBookShelfDBPath());
                        DBBookShelf.InsertOrUpdateBooks(AppDataPath.GetBookShelfDBPath(), ShelfBookList.ToList());
                    }
                }
                ToastHeplper.ShowMessage("个人书架已更新");
            }
        }
Пример #21
0
        private void OnDwonLoadhCommand(object obj)
        {
            if (IsLoading)
            {
                return;
            }
            if (this.CurrentBookEntity != null && this.CurrentBookEntity.CatalogList != null && this.CurrentBookEntity.CatalogList.Count > 0)
            {
                var result = DBLocalBook.GetAllLocalBookList(AppDataPath.GetLocalBookDBPath());
                if (result != null && result.FirstOrDefault(p => p.BookID == this.CurrentBookEntity.BookID) != null)
                {
                    ToastHeplper.ShowMessage("该图书已经下载过");
                }

                ViewModelInstance.Instance.DownLoadCenterViewModelInstance.AddNewDownloadItem(this.CurrentBookEntity);
            }
        }
Пример #22
0
        private async void RemoveBookList(List <BookEntity> removeList)
        {
            DispatcherHelper.CheckBeginInvokeOnUI(() =>
            {
                IsLoading = true;
            });
            await Task.Run(() =>
            {
                foreach (var item in removeList)
                {
                    try
                    {
                        string path = Path.Combine(AppDataPath.GetLocalBookFolderPath(), item.BookID + ".db");
                        if (File.Exists(path))
                        {
                            File.Delete(path);
                        }
                        DBLocalBook.DeleteLocalBookByBookID(AppDataPath.GetLocalBookDBPath(), item.BookID);

                        DispatcherHelper.CheckBeginInvokeOnUI(() =>
                        {
                            DBLocalBook.DeleteLocalBookByBookID(AppDataPath.GetLocalBookDBPath(), item.BookID);
                            this.LocalBookList.Remove(item);
                        });

                        string coverPath = AppDataPath.GetLocalBookCoverPath(item.BookID);
                        if (File.Exists(coverPath))
                        {
                            File.Delete(AppDataPath.GetLocalBookCoverPath(item.BookID));
                        }
                    }
                    catch (Exception)
                    {
                        ToastHeplper.ShowMessage(item.BookName + "删除失败,请重新尝试");
                        continue;
                    }
                }
            });

            DispatcherHelper.CheckBeginInvokeOnUI(() =>
            {
                IsLoading = false;
                OnEditCommand();
            });
        }
Пример #23
0
        public void InitData(object obj = null)
        {
            IsLoading = true;

            Task.Run(() =>
            {
                try
                {
                    HttpBaseProtocolFilter filter         = new HttpBaseProtocolFilter();
                    HttpCookieCollection cookieCollection = filter.CookieManager.GetCookies(new Uri(ViewModelInstance.Instance.UrlService.GetHomePage()));
                    var cookieItem = cookieCollection.FirstOrDefault(p => p.Name.Equals("sodu_user"));

                    if (cookieItem == null)
                    {
                        ViewModelInstance.Instance.IsLogin = false;
                    }
                    else
                    {
                        cookieItem.Expires = null;
                        filter.CookieManager.SetCookie(cookieItem);
                    }
                    DispatcherHelper.CheckBeginInvokeOnUI(async() =>
                    {
                        ViewModelInstance.Instance.MainPageViewModelInstance.ChangeLoginState(false);
                        ViewModelInstance.Instance.MyBookShelfViewModelInstance.ShelfBookList.Clear();
                        ToastHeplper.ShowMessage("注销成功");
                        await Task.Delay(500);
                        NavigationService.ContentFrame.Navigate(typeof(HomePage));
                        NavigationService.ClearStack();
                    });
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                }
                finally
                {
                    DispatcherHelper.CheckBeginInvokeOnUI(() =>
                    {
                        IsLoading = false;
                    });
                }
            });
        }
Пример #24
0
        public async void NavigateToPage(Type pageType, object para = null)
        {
            try
            {
                if (pageType != null)
                {
                    this.IsLeftPanelOpen = false;
                    NavigationService.NavigateTo(pageType, para);

                    await Task.Delay(30);

                    this.IsLeftPanelOpen = false;
                }
            }
            catch (Exception)
            {
                ToastHeplper.ShowMessage("导航出现异常");
            }
        }
Пример #25
0
        private async void RegisterMethod()
        {
            try
            {
                //  如果正在加载,或者提示不需要刷新
                if (IsLoading)
                {
                    return;
                }
                IsLoading = true;
                string html = null;
                await Task.Run(async() =>
                {
                    string uri      = ViewModelInstance.Instance.UrlService.GetRegisterPostPage();
                    string postData = "username="******"&userpass="******"{\"success\":true}"))
                {
                    ToastHeplper.ShowMessage("注册成功");
                    ViewModelInstance.Instance.MainPageViewModelInstance.ChangeLoginState(true);
                }
                else if (html.Contains("{\"success\":false}"))
                {
                    throw new Exception("注册失败,该用户可能已经注册过");
                }
                else
                {
                    throw new Exception("注册失败");
                }
            }
            catch (Exception ex)
            {
                ToastHeplper.ShowMessage(ex.Message);
            }
            finally
            {
                IsLoading = false;
            }
        }
Пример #26
0
        public void InitData2(object obj = null)
        {
            IsLoading = true;

            Task.Run(async() =>
            {
                string html = await GetHtmlData();
                return(html);
            }).ContinueWith((result) =>
            {
                string html = result.Result;
                DispatcherHelper.CheckBeginInvokeOnUI(() =>
                {
                    try
                    {
                        if (html != null && html.Contains("to delete public domains' cookies"))
                        {
                            ViewModelInstance.Instance.MainPageViewModelInstance.ChangeLoginState(false);
                            ViewModelInstance.Instance.MyBookShelfViewModelInstance.ShelfBookList.Clear();
                            ToastHeplper.ShowMessage("注销成功");
                        }
                        else
                        {
                            ToastHeplper.ShowMessage("注销失败请重新尝试");
                            NavigationService.GoBack();
                        }
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.Message);
                    }
                    finally
                    {
                        DispatcherHelper.CheckBeginInvokeOnUI(() =>
                        {
                            IsLoading = false;
                        });
                    }
                });
            });
        }
Пример #27
0
 public void AddEntityToList(BookEntity entity)
 {
     Task.Run(async() =>
     {
         if (ShelfBookList.ToList().Find(p => p.BookID == entity.BookID) == null)
         {
             string html = await(new HttpHelper()).WebRequestGet(string.Format(ViewModelInstance.Instance.UrlService.GetAddToShelfPage(), entity.BookID));
             if (html.Contains("{\"success\":true}"))
             {
                 DispatcherHelper.CheckBeginInvokeOnUI(() =>
                 {
                     var temp = entity.Clone();
                     temp.LastReadChapterName = temp.NewestChapterName;
                     temp.UnReadCountData     = null;
                     var result = DBBookShelf.InsertOrUpdateBook(AppDataPath.GetBookShelfDBPath(), temp);
                     ShelfBookList.Insert(0, temp);
                     RefreshList();
                 });
             }
             else
             {
                 ToastHeplper.ShowMessage(entity.BookName + " 添加至个人书架失败");
             }
         }
         else
         {
             DispatcherHelper.CheckBeginInvokeOnUI(() =>
             {
                 var temp = ShelfBookList.ToList().Find(p => p.BookID == entity.BookID);
                 var sim  = LevenshteinDistancePercent(temp.LastReadChapterName, entity.NewestChapterName);
                 if (!sim)
                 {
                     temp.LastReadChapterName = temp.NewestChapterName;
                     temp.UnReadCountData     = null;
                     var result = DBBookShelf.InsertOrUpdateBook(AppDataPath.GetBookShelfDBPath(), temp);
                 }
             });
         }
     });
 }
Пример #28
0
        public void InitHitoryData()
        {
            if (IsLoading)
            {
                return;
            }
            IsLoading = true;

            BookList.Clear();

            Task.Run(() =>
            {
                try
                {
                    var list = DBHistory.GetBookHistories(AppDataPath.GetHistoryDBPath());
                    if (list != null)
                    {
                        DispatcherHelper.CheckBeginInvokeOnUI(() =>
                        {
                            list.ForEach(x => this.BookList.Add(x));
                        });
                    }
                }
                catch (Exception)
                {
                    DispatcherHelper.CheckBeginInvokeOnUI(() =>
                    {
                        ToastHeplper.ShowMessage("加载历史记录有误");
                    });
                }
                finally
                {
                    DispatcherHelper.CheckBeginInvokeOnUI(() =>
                    {
                        IsLoading = false;
                    });
                }
            });
        }
Пример #29
0
 public void SetData(string para)
 {
     this.SearchPara = para;
     Task.Run(async() =>
     {
         string uri  = string.Format(ViewModelInstance.Instance.UrlService.GetSearchPage(), System.Net.WebUtility.UrlEncode(para));
         string html = await GetHtmlData(uri);
         return(html);
     }).ContinueWith((resultHtml) =>
     {
         DispatcherHelper.CheckBeginInvokeOnUI(() =>
         {
             if (resultHtml.Result != null && SetBookList(resultHtml.Result.ToString()))
             {
                 ToastHeplper.ShowMessage("共返回" + this.SearchResultList.Count + "条结果");
             }
             else
             {
                 ToastHeplper.ShowMessage("无搜索结果");
             }
         });
     });
 }
Пример #30
0
        public void OnBookItemSelectedChangedCommand(object obj)
        {
            BookEntity entity = obj as BookEntity;

            if (entity != null)
            {
                MenuModel menu = new MenuModel()
                {
                    MenuName = entity.BookName, MenuType = typeof(UpdateChapterPage)
                };

                //判断是否自动添加书到收藏
                if (ViewModelInstance.Instance.IsLogin && ViewModelInstance.Instance.SettingPageViewModelInstance.IfAutAddToShelf)
                {
                    ViewModelInstance.Instance.MyBookShelfViewModelInstance.AddEntityToList(entity);
                }
                NavigateToPage(typeof(UpdateChapterPage), entity);
            }
            else
            {
                ToastHeplper.ShowMessage("数据有误,请重新尝试");
            }
        }