private void ShowNextChapter() { if (this.ChapterIndex == book.ChapterCount - 1) { return; } this.ChapterIndex++; ChapterView temp = PrevChapterView; PrevChapterView = CurrChapterView; CurrChapterView = NextChapterView; NextChapterView = temp; UpdateChapterViewVisibilities(); CurrChapterView.ScrollToStart(); if (this.ChapterIndex == book.ChapterCount - 1) { return; } NextChapterView.ShowChapter(book.ReadChapter(this.ChapterIndex + 1)); }
///////////////////////////////////////////////////////////////////// private void ShowChapter(int chapterIndex, int pageIndex = 0, Action <int> onChapterLoaded = null) { if (chapterIndex < 0 || chapterIndex >= book.ChapterCount) { return; } this.ChapterIndex = chapterIndex; if (bookScanner.IsComplete) { this.AbsolutePageNumber = bookScanner.GetAbsolutePageNumber(chapterIndex, pageIndex); } Logger.Log(book.ReadChapter(chapterIndex)); CurrChapterView.ShowChapter(book.ReadChapter(chapterIndex), (int pageCount) => { CurrChapterView.ScrollToPage(pageIndex); onChapterLoaded?.Invoke(pageCount); }); if (chapterIndex != 0) { PrevChapterView.ShowChapter(book.ReadChapter(chapterIndex - 1), (int pageCount) => { PrevChapterView.ScrollToEnd(); }); } if (chapterIndex != book.ChapterCount - 1) { NextChapterView.ShowChapter(book.ReadChapter(chapterIndex + 1), (int pageCount) => { NextChapterView.ScrollToStart(); }); } }