Esempio n. 1
0
        private async Task <OpenResult> OpenFileAsText(string fileString, BookLocation location)
        {
            await Task.Delay(0);

            Logger.Log($"MainEpubReader: file is a text string; convert to html");

            EpubBook = TextWizard.TextToEpub(fileString);

            if (location == null)
            {
                var chapter = EpubWizard.GetFirstChapter(EpubBook.TableOfContents);
                if (chapter != null)
                {
                    location = EpubChapterData.FromChapter(chapter);
                }
            }

            if (location != null)
            {
                Logger.Log($"MainEpubReader: Show Text: About to move to location as needed. {location}");
                UserNavigatedToArgument = location;
                NavigateTo(ControlId, location); // We won't get a hairpin navigation callback
            }

            return(OpenResult.OK);
        }
        private void UserDidNavigationRequest(EpubChapterData chapter)
        {
            if (chapter == null)
            {
                return;
            }
            var          nav      = Navigator.Get();
            BookLocation location = null;

            if (chapter == Chapters[0])
            {
                // First one is special: we always go to the very start of the book, including stuff that's not in
                // the classic table of contents. For example, Gutenberg Campfire Girls Station Island has a cover that's
                // not in the TOC but which is in the inner.SpecialResources.HtmlInReadingOrder and which is placed first.
                // Additionally, that book also has the weird thing that the ID for the first section (in the TOC) is
                // near the end of the section, so when you click on it, it scrolls to there, but then the next TOC entry
                // (chapter 1) is visible near the top, and so the selection jumps to there.
                location = new BookLocation(0, 0); // first HTML page, at the very top.
            }
            else
            {
                location = EpubChapterData.FromChapter(chapter);
            }
            nav.UserNavigatedTo(ControlId, location);
        }