Пример #1
0
 public static void RemoveFromFavorites(Manga.Manga manga)
 {
     Task.Run(async() =>
     {
         await Database.MangaDAO.RemoveMangaFromFavoritesAsync(manga.Id);
         await RefreshFavorites();
     });
 }
Пример #2
0
 public static void AddToFavorites(Manga.Manga manga)
 {
     Task.Run(async() =>
     {
         //Debug.WriteLine("add start");
         await Database.MangaDAO.AddMangaToFavoritesAsync(manga.Id);
         //Debug.WriteLine("after add");
         await RefreshFavorites();
         //Debug.WriteLine("add finish");
     });
 }
 private void MangaListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     App.CancellationToken.Cancel();
     Manga.Manga manga = (sender as ListBox).SelectedItem as Manga.Manga;
     if (manga != null)
     {
         string id = String.Copy(manga.Id);
         MangaListBox.SelectedIndex = -1;
         //ObservableMangas.Clear();
         MainWindow.NavigationFrame.Navigate(new MangaPage(id));
         //this.NavigationService.Navigate(new MangaPage(id));
     }
 }
Пример #4
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);
            }));
        }