/// <summary> /// NavigateTo means navigate to a spot in the book. Will also do a navigation with User... /// </summary> /// <param name="sourceId"></param> /// <param name="location"></param> public void NavigateTo(NavigateControlId sourceId, BookLocation location) { var bookdb = BookDataContext.Get(); if (Logger.LogExtraTiming) { Logger.Log($"MainEpubReader: Navigation: to {location}"); } // Save the fact that we navigated to here. Only the main reader saves this information var navigationData = CommonQueries.BookNavigationDataFind(bookdb, BookData.BookId); if (navigationData == null) { navigationData = new BookNavigationData() { BookId = BookData.BookId, CurrStatus = BookNavigationData.UserStatus.Reading }; CommonQueries.BookNavigationDataAdd(bookdb, navigationData, CommonQueries.ExistHandling.IfNotExists); } navigationData.CurrSpot = location.Location; navigationData.CurrStatus = BookNavigationData.UserStatus.Reading; // If I'm navigating then I'm reading? // And now actually navigate. There are two types of navigation: navigation // via tags and navigation by percent. // Both need to be handled. var percent = location.HtmlPercent; if (percent >= 0.0) { if (Logger.LogExtraTiming) { Logger.Log($"MainEpubReader: Navigation: to percent"); } NavigateToPercent(location); } else { if (Logger.LogExtraTiming) { Logger.Log($"MainEpubReader: Navigation: via location, not percent ({location})"); } NavigateToLocation(location); } }
private BookNavigationData EnsureBookNavigationData(BookDataContext bookdb) { var nd = CommonQueries.BookNavigationDataFind(bookdb, BookData.BookId); if (nd == null) { nd = new BookNavigationData() { BookId = BookData.BookId, CurrSpot = GetCurrBookLocation().ToJson() }; CommonQueries.BookNavigationDataAdd(bookdb, nd, CommonQueries.ExistHandling.IfNotExists); nd = CommonQueries.BookNavigationDataFind(bookdb, BookData.BookId); } if (nd == null) { App.Error($"ERROR: trying to ensure navigation data, but don't have one."); } return(nd); }