Ejemplo n.º 1
0
 public bool LoadData(Book_Short item) //Load data offine here
 {
     App.Global.Book_Directory = item.book_dir;
     _Bookmark_Chapters_Index.Clear();
     _Downloaded_Chapters_index.Clear();
     try
     {
         using (StreamReader file = File.OpenText(item.book_dir + "\\detail.json"))
         {
             JsonSerializer serializer = new JsonSerializer();
             _Book = (Book)serializer.Deserialize(file, typeof(Book));
             if (_Book.season_name.Count == 0)
             {
                 _Book.season_name.Add("Quyển 1");
                 _Book.season_index.Add(0);
             }
             _IsBookDownloaded = true;
         }
         if (ReadDownloadedList())
         {
             if (_Downloaded_Chapters_index.Count == _Book.chapter_link.Count())
             {
                 _IsBookContentDownloaded = true;
             }
             else
             {
                 _IsBookContentDownloaded = false;
             }
         }
         else
         {
             _IsBookContentDownloaded = false;
         }
         if (File.Exists(item.book_dir + "\\Bookmarks.json"))
         {
             using (StreamReader file = File.OpenText(item.book_dir + "\\Bookmarks.json"))
             {
                 JsonSerializer serializer = new JsonSerializer();
                 _Bookmark_Chapters_Index = (List <int>)serializer.Deserialize(file, typeof(List <int>));
             }
         }
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Ejemplo n.º 2
0
        public async void OpenDetailScreen(Book_Short x)
        {
            StartLoading();
            var xa = await Task.Run(() => detailScreen.LoadData(x));

            if (xa)
            {
                MainGrid.Visibility     = Visibility.Collapsed;
                detailScreen.Visibility = Visibility.Visible;
            }
            else
            {
                MessageBox.Show("An error occurred while processing, please try again.");
            }

            EndLoading();
        }
Ejemplo n.º 3
0
        public bool LoadData(Book_Short item) //Load data offine here
        {
            if (!App.Global.Book_ViewModel.LoadData(item))
            {
                return(false);
            }
            page_numbers = App.Global.Book_ViewModel.bookTotalChapter / chapter_limit + 1;
            page_index   = 1;

            this.Dispatcher.Invoke(() =>
            {//Gán DataContext được
                bookAuthor.Text       = App.Global.Book_ViewModel.book_author.Replace("\n", "");
                bookTotalChapter.Text = App.Global.Book_ViewModel.bookTotalChapter.ToString();
                bookDec.Text          = App.Global.Book_ViewModel.book_intro;
                bookName.Text         = App.Global.Book_ViewModel.book_name;
                if (App.Global.Book_ViewModel.IsBookDownloaded)
                {
                    //btnAddToLibrary.Visibility = Visibility.Collapsed;
                    btnDownloadContent.Visibility = Visibility.Visible;
                }
                else
                {
                    //btnAddToLibrary.Visibility = Visibility.Visible;
                    btnDownloadContent.Visibility = Visibility.Collapsed;
                }
                BitmapImage image = new BitmapImage();
                image.BeginInit();
                image.CacheOption = BitmapCacheOption.OnLoad;
                if (File.Exists(item.book_dir + "\\img.jpg"))
                {
                    image.UriSource = new Uri(item.book_dir + "\\img.jpg");
                }
                else
                {
                    image.UriSource = new Uri(App.Global.Directory_Folder + "\\Icon\\no-image.jpg");
                }
                image.EndInit();
                bookImg.Source = image;
                LoadPaging(page_index);
                PagePanelReload();
            });
            return(true);
        }