/// <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 override void OnLaunched(LaunchActivatedEventArgs e) { SettingsImplementation.Init(); #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { this.DebugSettings.EnableFrameRateCounter = true; } #endif 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 rootFrame = new Frame(); // TODO: change this value to a cache size that is appropriate for your application rootFrame.CacheSize = 1; Xamarin.Forms.Forms.Init(e); if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { // TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // Removes the turnstile navigation for startup. if (rootFrame.ContentTransitions != null) { this.transitions = new TransitionCollection(); foreach (var c in rootFrame.ContentTransitions) { this.transitions.Add(c); } } rootFrame.ContentTransitions = null; rootFrame.Navigated += this.RootFrame_FirstNavigated; // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter if (!rootFrame.Navigate(typeof(MainPage), e.Arguments)) { throw new Exception("Failed to create initial page"); } } // Ensure the current window is active Window.Current.Activate(); }
public async void Run(IBackgroundTaskInstance taskInstance) { SettingsImplementation.Init(); // Get a deferral, to prevent the task from closing prematurely // while asynchronous code is still running. var deferral = taskInstance.GetDeferral(); // Download the feed. var rates = await LoadExchangeRates(); // Update the live tile with the feed items. UpdateTile(rates); // Inform the system that the task is finished. deferral.Complete(); }
/// <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 override void OnLaunched(LaunchActivatedEventArgs e) { SettingsImplementation.Init(); #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { this.DebugSettings.EnableFrameRateCounter = true; } #endif 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) { //Color currentAccentColorHex = ((SolidColorBrush)Application.Current.Resources["SystemControlHighlightAccentBrush"]).Color; //Color currentInactiveAccentColorHex = ((Color)Application.Current.Resources["SystemDisabledWindowAppbarColor"]); //if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.ApplicationView")) //{ // var titleBar = ApplicationView.GetForCurrentView().TitleBar; // if (titleBar != null) // { // titleBar.ButtonBackgroundColor = currentAccentColorHex; // titleBar.ButtonForegroundColor = Colors.White; // titleBar.BackgroundColor = currentAccentColorHex; // titleBar.ForegroundColor = Colors.White; // titleBar.InactiveBackgroundColor = currentInactiveAccentColorHex; // titleBar.ButtonInactiveBackgroundColor = currentInactiveAccentColorHex; // } //} ////Mobile customization //if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar")) //{ // var statusBar = StatusBar.GetForCurrentView(); // if (statusBar != null) // { // statusBar.BackgroundOpacity = 1; // statusBar.BackgroundColor = currentAccentColorHex; // statusBar.ForegroundColor = Colors.White; // } //} // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); // TODO: change this value to a cache size that is appropriate for your application rootFrame.CacheSize = 1; Xamarin.Forms.Forms.Init(e); if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { // TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } 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 if (!rootFrame.Navigate(typeof(MainPage), e.Arguments)) { throw new Exception("Failed to create initial page"); } } //if (ApiInformation.IsPropertyPresent(typeof(LaunchActivatedEventArgs).FullName, nameof(LaunchActivatedEventArgs.TileId))) //{ // // If clicked on from tile // if (e.TileId != null) // { // //// If tile notification(s) were present // //if (e.TileActivatedInfo.RecentlyShownNotifications.Count > 0) // //{ // // // Get arguments from the notifications that were recently displayed // // string currencyRedirectionArgument = e.TileActivatedInfo.RecentlyShownNotifications // // .Select(i => i.Arguments) // // .Where(x => x.Contains(Constants.CurrencyRedirectionArgumentSeparator) && x.StartsWith(Constants.CurrencyRedirectionArgumentCode)) // // .FirstOrDefault(); // // var redirectionToCurrency = string.IsNullOrEmpty(currencyRedirectionArgument) ? null : currencyRedirectionArgument.Split(Constants.CurrencyRedirectionArgumentSeparator[0]).Last(); // // if (!string.IsNullOrEmpty(redirectionToCurrency)) // // { // // Settings.SetLastViewedCurrency(redirectionToCurrency); // // ServiceLocator.Current.GetInstance<ICurrencyNavigateService>().NavigateToCurrency(redirectionToCurrency); // // } // //} // } //} // Ensure the current window is active Window.Current.Activate(); }