/// <summary> /// Handles the entire problem of reviewing each of the selected books. Will pop up a little pop-up /// and let the user do a review of each one. /// </summary> /// <returns></returns> public async Task RunSavedReviewEachBook() { if (SavedSelectedBooks == null) { return; } var selectedBooks = SavedSelectedBooks; var deleteBook = SavedDeleteBook; // Setup to delete all selected books from the Nook EbookReaderProgressControl progress = null; if (deleteBook) { await SetupProgressFolderAsync(); progress = new EbookReaderProgressControl(); uiAlternateContent.Visibility = Visibility.Visible; uiAlternateContent.Children.Clear(); uiAlternateContent.Children.Add(progress); progress.SetNBooks(selectedBooks.Count); } var bookdb = BookDataContext.Get(); var sh = new ContentDialog() { Title = "Review Book", PrimaryButtonText = "OK", SecondaryButtonText = "Cancel", }; var reviewlist = new ReviewNoteStatusListControl(); reviewlist.SetBookList(selectedBooks); sh.Content = reviewlist; var result = await sh.ShowAsync(); ; #if NEVER_EVER_DEFINED // The old code that did a pop-up per book. The new way does one pop-up with a swipable list. foreach (var bookData in selectedBooks) { var srcfullname = bookData.DownloadData.FullFilePath; var fname = bookData.DownloadData.FileName; var nd = CommonQueries.BookNavigationDataEnsure(bookdb, bookData); var sh = new ContentDialog() { Title = "Review Book", PrimaryButtonText = "OK", SecondaryButtonText = "Cancel", }; var review = new ReviewNoteStatusControl(); string defaultReviewText = null; var BookData = bookData; review.SetBookData(BookData, defaultReviewText); sh.Content = review; var result = await sh.ShowAsync(); switch (result) { case ContentDialogResult.Primary: review.SaveData(); bool deleteOk = true; if (progress != null) { deleteOk = await DeleteDownloadedBookAsync(progress, bookData); } var nav = Navigator.Get(); //TODO: setup Rome?? nav.UpdateProjectRome(ControlId, GetCurrBookLocation()); break; } if (deleteBook) { // TODO: How to delete it? ; } } #endif }
/// <summary> /// Called when the user has navigated to somewhere in the book. The chapter display /// tries to sync itself to the value. The chapter display depends on the caller being /// fully initialized first! /// </summary> /// <param name="sourceId"></param> /// <param name="location"></param> public async void NavigateTo(NavigateControlId sourceId, BookLocation location) { string chapterid = ""; var nav = Navigator.Get(); if (!double.IsNaN(location.ScrollPercent)) { chapterid = await nav.MainBookHandler.GetChapterBeforePercentAsync(location); } else { chapterid = nav.MainBookHandler.GetChapterContainingId(location.Location, location.HtmlIndex); } EpubChapterData foundChapter = null; if (foundChapter == null && location.HtmlIndex >= 0) { var html = Book.ResourcesHtmlOrdered[location.HtmlIndex]; foreach (var chapter in Chapters) { // FAIL: Intro to Planetary Nebulae the location is html 8, id tit1 which is shared by multiple chapters. if (html.Href.EndsWith(chapter.FileName) && chapter.Anchor == chapterid) { foundChapter = chapter; break; } } } // Most common: there's an id, and it matches a single chapter. if (foundChapter == null) { foreach (var chapter in Chapters) { if (chapter.Anchor == chapterid || chapter.FileName == chapterid) { foundChapter = chapter; break; } } } if (foundChapter == null && location.HtmlIndex >= 0) { var html = Book.ResourcesHtmlOrdered[location.HtmlIndex]; foreach (var chapter in Chapters) { // FAIL: Intro to Planetary Nebulae the location is html 8, id tit1 which is shared by multiple chapters. if (html.Href.EndsWith(chapter.FileName)) { foundChapter = chapter; break; } } } // Worse case scenario, but it's better to display something if (foundChapter == null) { foreach (var chapter in Chapters) { if (string.IsNullOrEmpty(chapterid)) { App.Error($"ChapterDisplay:Navigate({location}) was asked to find an empty chapter"); foundChapter = chapter; break; } } } if (foundChapter == null) { // Truly desperate. if (Chapters.Count > 0) { App.Error($"ChapterDisplay:Navigate({location}) completely failed"); foundChapter = Chapters[0]; } else { App.Error($"ChapterDisplay:Navigate({location}) last ditch completely failed -- no chapters at all!"); } } if (foundChapter != null) { // Select this one uiChapterList.SelectedItem = foundChapter; uiChapterList.ScrollIntoView(foundChapter); return; // all done! } }