Exemple #1
0
        /// <summary>
        /// Will do an absolute save position. This is almost never needed; instead use the
        /// SavePositionEZ which will save in a CPU and disk friendlier way.
        /// </summary>
        private async Task SavePositionNow()
        {
            if (BookData == null)
            {
                return;
            }
            var bookdb = BookDataContext.Get();

            var currPosition = GetCurrBookLocation().ToJson();

            if (currPosition == lastSavedPosition)
            {
                return;
            }
            var nd = EnsureBookNavigationData(bookdb);

            if (nd == null)
            {
                return;
            }
            nd.CurrSpot       = currPosition;
            lastSavedPosition = currPosition;
            CommonQueries.BookSaveChanges(bookdb);

            var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

            localSettings.Values[CURR_READING_BOOK_ID]  = BookData.BookId;
            localSettings.Values[CURR_READING_BOOK_POS] = currPosition;

            // Update the bookmark file, too.
            await BookMarkFile.SmartSaveAsync(BookMarkFile.BookMarkFileType.RecentOnly);
        }
Exemple #2
0
        private async void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            Logger.Log("MainPage:Loaded:called");
            var bookdb = BookDataContext.Get();

            Logger.Log("MainPage:Loaded:about to migrate");
            CommonQueries.BookDoMigrate(bookdb);
            Logger.Log("MainPage:Loaded:done migration");

            // Reset to the tab the user had originally picked.
            SelectUserTab();
            var(id, _) = MainEpubReader.GetCurrReadingBook();  // _ is pos

            if (App.SavedActivatedBookData != null)
            {
                var nav = Navigator.Get();
                nav.DisplayBook(Navigator.NavigateControlId.InitializationCode, App.SavedActivatedBookData, App.SavedActivatedBookLocation);
            }
            else if (id != null)
            {
                var book = CommonQueries.BookGet(bookdb, id);
                if (book != null)
                {
                    var nav = Navigator.Get();
                    nav.DisplayBook(Navigator.NavigateControlId.InitializationCode, book);
                }
            }
            if (WarmUpDataBase == null)
            {
                WarmUpDataBase = CommonQueries.FirstSearchToWarmUpDatabase();
            }

#if DEBUG
            // There are only shown in debug mode!
            uiLogTab.Visibility    = Visibility.Visible;
            uiDebugMenu.Visibility = Visibility.Visible;
#endif

            await BookMarkFile.SmartReadAsync();

            Logger.Log("MainPage:Loaded:returning");
        }
Exemple #3
0
        private void DoLaunch(LaunchActivatedEventArgs e = null)
        {
            int nerror = 0;

            Logger.Log($"App:DoLaunch:about to test parser");
            nerror += SearchParserTest.Test_Parser(); // Run some tests
            Logger.Log($"App:DoLaunch:about to test html");
            nerror += EpubWizard.Test_HtmlStringIdIndexOf();
            nerror += BookMarkFile.TestAsValidFilename();

            Logger.Log($"App:DoLaunch:about to add to resources");

            // SLOW: this is 2 seconds of startup
            Application.Current.Resources["UserCustomization"] = Customization;

            Logger.Log($"App:DoLaunch:about to copy initial database");
            var mustCopy     = InitializeFilesToGet.GetMustCopyInitialDatabase();
            var mainPageType = mustCopy ? typeof(MainInitializationPage) : typeof(MainPage);

            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                Logger.Log($"App:DoLaunch:about to make frame");
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e != null && e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (e == null || e.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    // When the navigation stack isn't restored navigate to the first page,
                    // configuring the new page by passing required information as a navigation
                    // parameter
                    Logger.Log($"App:DoLaunch:about to navigate");
                    rootFrame.Navigate(mainPageType, e?.Arguments);
                }
                // Ensure the current window is active
                Logger.Log($"App:DoLaunch:about to activate");
                Window.Current.Activate();
                Logger.Log($"App:DoLaunch:done to navigate and activate");
            }

            //if (WarmUpDataBase == null && !mustCopy)
            //{
            //    WarmUpDataBase = CommonQueries.FirstSearchToWarmUpDatabase();
            //}
        }
Exemple #4
0
 private async void OnSetUserJsonFolder(object sender, RoutedEventArgs e)
 {
     await BookMarkFile.SetSaveFolderAsync();
 }
Exemple #5
0
 private async void OnRestoreUserJson(object sender, RoutedEventArgs e)
 {
     await BookMarkFile.SmartReadAsync();
 }
Exemple #6
0
 private async void OnSaveUserAllJson(object sender, RoutedEventArgs e)
 {
     await BookMarkFile.SmartSaveAsync(BookMarkFile.BookMarkFileType.FullFile);
 }
Exemple #7
0
 private async void OnSaveUserJson(object sender, RoutedEventArgs e)
 {
     await BookMarkFile.SmartSaveAsync(BookMarkFile.BookMarkFileType.RecentOnly);
 }