/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used when the application is launched to open a specific file, to display /// search results, and so forth. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected async override void OnLaunched(LaunchActivatedEventArgs e) { #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { this.DebugSettings.EnableFrameRateCounter = true; } Debug.WriteLine("AppOnLaunched"); #endif #if WINDOWS_UWP SyncAppAccentColor(); //var search = await LightKindomHtmlClient.SearchBookAsync("青春"); //var featured = await LightKindomHtmlClient.GetFeaturedBooks(); //var comments = await LightKindomHtmlClient.GetCommentsAsync("797", "72"); //var chptr = await LightKindomHtmlClient.GetChapterAsync("797", "129", "72"); //var chptr = await LightKindomHtmlClient.GetSeriesAsync("72"); //var chapter = new Uri("http://linovel.com/book/read?chapterId=798&volId=129&bookId=72"); //var client = new Windows.Web.Http.HttpClient(); //var content = await client.GetStringAsync(chapter); //var result = await LightKindomHtmlClient.GetCommentedLinesListAsync("4516"); //var anotherresult = await LightKindomHtmlClient.GetCommentsAsync("36","4516"); //var chptr = await LightKindomHtmlClient.GetSeriesIndexAsync(); //var result = await LightKindomHtmlClient.SearchBookAsync("青春"); #endif mainDispatcher = Window.Current.Dispatcher; mainViewId = ApplicationView.GetForCurrentView().Id; 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) { ExtendedSplash extendedSplash; if (Window.Current.Content == null) { extendedSplash = new ExtendedSplash(e.SplashScreen); } else { extendedSplash = Window.Current.Content as ExtendedSplash; } extendedSplash.RegisterFrameArriveDimmsion(); // Create a Frame to act as the navigation context and navigate to the first page rootFrame = extendedSplash.RootFrame; // TODO: change this value to a cache size that is appropriate for your application rootFrame.CacheSize = 3; //Associate the frame with a SuspensionManager key try { SuspensionManager.RegisterFrame(rootFrame, "AppFrame"); } catch (Exception) { } Window.Current.Content = extendedSplash; Window.Current.Activate(); // Place the frame in the current Window // Window.Current.Content = rootFrame; } else { Window.Current.Activate(); } #region Preloading #if WINDOWS_PHONE_APP //Windows.UI.ViewManagement.ApplicationView.GetForCurrentView() // .SetDesiredBoundsMode(Windows.UI.ViewManagement.ApplicationViewBoundsMode.UseVisible); var statusBar = StatusBar.GetForCurrentView(); statusBar.BackgroundOpacity = 0; statusBar.ForegroundColor = (Windows.UI.Color)Resources["AppBackgroundColor"]; #endif //return; await AppGlobal.LoadHistoryDataAsync(); await AppGlobal.LoadBookmarkDataAsync(); await CachedClient.InitializeCachedSetAsync(); AppGlobal.RefreshAutoLoadPolicy(); #endregion if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { // Restore the saved session state only when appropriate try { #if WINDOWS_PHONE_APP rootFrame.ContentTransitions = new TransitionCollection() { new NavigationThemeTransition() { DefaultNavigationTransitionInfo = new ContinuumNavigationTransitionInfo() } }; #endif await SuspensionManager.RestoreAsync(); if (rootFrame.Content != null && Window.Current.Content != rootFrame) { Window.Current.Content = rootFrame; return; } } catch (SuspensionManagerException) { // Something went wrong restoring state. // Assume there is no state and continue } } if (rootFrame.Content == null) { #if WINDOWS_PHONE_APP // Removes the turnstile navigation for startup. rootFrame.ContentTransitions = null; rootFrame.Navigated += this.RootFrame_FirstNavigated; #endif } // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter bool navResult = true; if (string.IsNullOrEmpty(e.Arguments)) { var entity = rootFrame.BackStack.FirstOrDefault(pse => pse.SourcePageType == typeof(HubPage)); if (rootFrame.CurrentSourcePageType != typeof(HubPage) && entity == null) { navResult = rootFrame.Navigate(typeof(HubPage), e.Arguments); } else { while (rootFrame.CurrentSourcePageType != typeof(HubPage) && rootFrame.CanGoBack) { rootFrame.GoBack(); } } } else { var entity = rootFrame.BackStack.FirstOrDefault(pse => pse.SourcePageType == typeof(ReadingPage)); if (entity == null && rootFrame.CurrentSourcePageType != typeof(ReadingPage)) { navResult = rootFrame.Navigate(typeof(ReadingPage), e.Arguments); } else { while (rootFrame.CurrentSourcePageType != typeof(ReadingPage) && rootFrame.CanGoBack) { rootFrame.GoBack(); } var page = rootFrame.Content as ReadingPage; var navigationId = NovelPositionIdentifier.Parse((string)e.Arguments); if (navigationId.SeriesId != page.ViewModel.SeriesId.ToString()) { navResult = rootFrame.Navigate(typeof(ReadingPage), e.Arguments); } } } if (!navResult) { navResult = rootFrame.Navigate(typeof(HubPage), null); } AppGlobal.Settings.UpdateSavedAppVersion(); //App.CurrentState.SignInAutomaticlly(); // Ensure the current window is active //Window.Current.Activate(); }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used when the application is launched to open a specific file, to display /// search results, and so forth. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected async override void OnLaunched(LaunchActivatedEventArgs e) { #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { this.DebugSettings.EnableFrameRateCounter = true; } Debug.WriteLine("AppOnLaunched"); #endif #if WINDOWS_UWP SyncAppAccentColor(); //var search = await LightKindomHtmlClient.SearchBookAsync("青春"); //var featured = await LightKindomHtmlClient.GetFeaturedBooks(); //var comments = await LightKindomHtmlClient.GetCommentsAsync("797", "72"); //var chptr = await LightKindomHtmlClient.GetChapterAsync("797", "129", "72"); //var chptr = await LightKindomHtmlClient.GetSeriesAsync("72"); //var chapter = new Uri("http://linovel.com/book/read?chapterId=798&volId=129&bookId=72"); //var client = new Windows.Web.Http.HttpClient(); //var content = await client.GetStringAsync(chapter); //var result = await LightKindomHtmlClient.GetCommentedLinesListAsync("4516"); //var anotherresult = await LightKindomHtmlClient.GetCommentsAsync("36","4516"); //var chptr = await LightKindomHtmlClient.GetSeriesIndexAsync(); //var result = await LightKindomHtmlClient.SearchBookAsync("青春"); #endif mainDispatcher = Window.Current.Dispatcher; mainViewId = ApplicationView.GetForCurrentView().Id; 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) { ExtendedSplash extendedSplash; if (Window.Current.Content == null) { extendedSplash = new ExtendedSplash(e.SplashScreen); } else { extendedSplash = Window.Current.Content as ExtendedSplash; } extendedSplash.RegisterFrameArriveDimmsion(); // Create a Frame to act as the navigation context and navigate to the first page rootFrame = extendedSplash.RootFrame; // TODO: change this value to a cache size that is appropriate for your application rootFrame.CacheSize = 3; //Associate the frame with a SuspensionManager key try { SuspensionManager.RegisterFrame(rootFrame, "AppFrame"); } catch (Exception) { } Window.Current.Content = extendedSplash; Window.Current.Activate(); // Place the frame in the current Window // Window.Current.Content = rootFrame; } else { Window.Current.Activate(); } #region Preloading #if WINDOWS_PHONE_APP //Windows.UI.ViewManagement.ApplicationView.GetForCurrentView() // .SetDesiredBoundsMode(Windows.UI.ViewManagement.ApplicationViewBoundsMode.UseVisible); var statusBar = StatusBar.GetForCurrentView(); statusBar.BackgroundOpacity = 0; statusBar.ForegroundColor = (Windows.UI.Color)Resources["AppBackgroundColor"]; #endif //return; await AppGlobal.LoadHistoryDataAsync(); await AppGlobal.LoadBookmarkDataAsync(); await CachedClient.InitializeCachedSetAsync(); AppGlobal.RefreshAutoLoadPolicy(); #endregion if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { // Restore the saved session state only when appropriate try { #if WINDOWS_PHONE_APP rootFrame.ContentTransitions = new TransitionCollection() { new NavigationThemeTransition() { DefaultNavigationTransitionInfo = new ContinuumNavigationTransitionInfo() } }; #endif await SuspensionManager.RestoreAsync(); if (rootFrame.Content != null && Window.Current.Content != rootFrame) { Window.Current.Content = rootFrame; return; } } catch (SuspensionManagerException) { // Something went wrong restoring state. // Assume there is no state and continue } } if (rootFrame.Content == null) { #if WINDOWS_PHONE_APP // Removes the turnstile navigation for startup. rootFrame.ContentTransitions = null; rootFrame.Navigated += this.RootFrame_FirstNavigated; #endif } // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter bool navResult = true; if (string.IsNullOrEmpty(e.Arguments)) { var entity = rootFrame.BackStack.FirstOrDefault(pse => pse.SourcePageType == typeof(HubPage)); if (rootFrame.CurrentSourcePageType != typeof(HubPage) && entity == null) navResult = rootFrame.Navigate(typeof(HubPage), e.Arguments); else { while (rootFrame.CurrentSourcePageType != typeof(HubPage) && rootFrame.CanGoBack) rootFrame.GoBack(); } } else { var entity = rootFrame.BackStack.FirstOrDefault(pse => pse.SourcePageType == typeof(ReadingPage)); if (entity == null && rootFrame.CurrentSourcePageType != typeof(ReadingPage)) navResult = rootFrame.Navigate(typeof(ReadingPage), e.Arguments); else { while (rootFrame.CurrentSourcePageType != typeof(ReadingPage) && rootFrame.CanGoBack) rootFrame.GoBack(); var page = rootFrame.Content as ReadingPage; var navigationId = NovelPositionIdentifier.Parse((string)e.Arguments); if (navigationId.SeriesId != page.ViewModel.SeriesId.ToString()) navResult = rootFrame.Navigate(typeof(ReadingPage), e.Arguments); } } if (!navResult) { navResult = rootFrame.Navigate(typeof(HubPage), null); } AppGlobal.Settings.UpdateSavedAppVersion(); //App.CurrentState.SignInAutomaticlly(); // Ensure the current window is active //Window.Current.Activate(); }