Ejemplo n.º 1
0
 public ChapterPage(string title, Manga.Chapter chapter, List <Manga.Chapter> chapters, int removeLastPageCount)
 {
     InitializeComponent();
     //MainWindow.AddToFrameHistory(MainWindow.ExplorerPage.ChapterPage);
     MangaTitle            = title;
     Chapter               = chapter;
     Chapters              = chapters;
     pageCount             = removeLastPageCount;
     ImageList.ItemsSource = ObservableImages;
     ChapterNumber.Text    = Chapter.Number.ToString();
     if (MangaTitle.Length < 23)
     {
         MangaTitleText.Text = MangaTitle;
     }
     else
     {
         MangaTitleText.Text = MangaTitle.Substring(0, 23) + "...";
     }
     if (pageCount > 1)
     {
         MainWindow.navigationService.RemoveBackEntry();                     // Keeps only last chapter in history and the Page for the Manga after that
     }
     Task.Run(() => Database.ChapterDAO.UpdateHasViewedAsync(Chapter.Id));
     GetImages();
 }
Ejemplo n.º 2
0
        public MangaPage(string id)
        {
            InitializeComponent();
            Debug.WriteLine("MangaPage id: " + id);
            //ChapterList
            //MainWindow.AddToFrameHistory(MainWindow.ExplorerPage.MangaPage);
            CategoriesList.ItemsSource = ObservableCategories;
            ChapterList.ItemsSource    = ObservableChapters;
            Task.Run(async() => await Http.HttpMangaEden.GetManga(id, (Manga.Manga manga) =>
            {
                this.Manga = manga;
                //Debug.WriteLine("image string: " + manga.ImageString);
                Task.Run(async() =>
                {
                    await Database.MangaDAO.CreateMangaAsyncLite(Manga);
                    await Database.MangaDAO.UpdateMangaAsync(Manga);
                });

                //if (MainWindow.ObservableFavoriteMangas.Where())
                //if (MainWindow.ObservableFavoriteMangas.Where((mangaTmp) => mangaTmp.Id == Manga.Id)
                //MainWindow.ObservableFavoriteMangas.Contains(MainWindow.ObservableFavoriteMangas.Where((mangaTmp) => mangaTmp.Id == Manga.Id).Cast<Manga.Manga>);
                //MainWindow.ObservableFavoriteMangas.Contains(((mangaQuery) => mangaQuery.Id == Manga.Id).Fr);//
                //Manga.Manga tmpManga = MainWindow.ObservableFavoriteMangas.Where(mangaQuery => mangaQuery.Id == Manga.Id).FirstOrDefault();
                if (MainWindow.ObservableFavoriteMangas.Where(mangaQuery => mangaQuery.Id == Manga.Id).FirstOrDefault() is Manga.Manga)
                {
                    //Debug.WriteLine("found favorite");
                    favoriteStatus = true;
                }
                else
                {
                    //Debug.WriteLine("not found favorite");
                    favoriteStatus = false;
                }
                Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new ThreadStart(delegate
                {
                    MangaTitle.Text   = manga.Title;
                    MangaImage.Source = new BitmapImage(new Uri(manga.ImageString));
                    MangaArtist.Inlines.Add(manga.Artist);
                    MangaAuthor.Inlines.Add(manga.Author);
                    MangaDescription.Text = manga.Description;
                    MangaStatus.Text      = manga.Status.ToString();
                    if (favoriteStatus)
                    {
                        UnFavoriteButton.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        FavoriteButton.Visibility = Visibility.Visible;
                    }
                }));
                foreach (string category in manga.Categories)
                {
                    Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new ThreadStart(delegate
                    {
                        ObservableCategories.Add(category);
                    }));
                }
                foreach (Manga.Chapter chapter in manga.Chapters)
                {
                    Manga.Chapter modifiedChapter = Database.ChapterDAO.CreateAndGetChapterLite(chapter, Manga.Id);               // checks if chapter has already been viewed
                    Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new ThreadStart(delegate
                    {
                        ObservableChapters.Add(modifiedChapter);
                    }));
                }
                return(true);
            }));
        }