protected override async void OnFileActivated(FileActivatedEventArgs args) { Application.Current.Resources["UserCustomization"] = Customization; var mustCopy = InitializeFilesToGet.GetMustCopyInitialDatabase(); var mainPageType = mustCopy ? typeof(MainInitializationPage) : typeof(MainPage); Frame rootFrame = CreateRootFrame(); if (rootFrame.Content == null) { if (!rootFrame.Navigate(mainPageType)) { throw new Exception("Failed to create initial page"); } } if (!mustCopy) { var p = rootFrame.Content as MainPage; if (p != null) { await p.DoFilesActivated(args); } } // Ensure the current window is active Window.Current.Activate(); }
private async void MainInitializationPage_Loaded(object sender, RoutedEventArgs e) { uiProgressRing.IsActive = true; await InitializeFilesToGet.CopyAssetDatabaseIfNeededAsync(new UwpRangeConverter (uiProgress)); uiProgressRing.IsActive = false; uiStart.IsEnabled = true; }
private async void OnCreateDatabase(object sender, RoutedEventArgs e) { BookDataContext.ResetSingleton("InitialBookData.Db"); var bookdb = BookDataContext.Get(); CommonQueries.BookDoMigrate(bookdb); // might not exist at all; Migrate is the way to force creation of tables. var iftg = new InitializeFilesToGet(); await iftg.CreateDatabaseAsync(bookdb); BookDataContext.ResetSingleton(null); // reset database }
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(); //} }
/// <summary> /// Dwonloads the correct set (5 as of 2021-04-04) of books to pre-populate the app with. /// Would be nice to sometime include popular books as a category :-) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void OnDownloadInitialFiles(object sender, RoutedEventArgs e) { var bookdb = BookDataContext.Get(); var iftg = new InitializeFilesToGet(); await iftg.DownloadBooksAsync(bookdb); }