public async override Task OnLaunchedAsync(ILaunchActivatedEventArgs e) { this.NavigationService.Navigate(typeof(Views.MainPage)); var channelURI = await PushHandlingHelper.RegisterForPushAsync(); Debug.WriteLine(channelURI); }
private async void InternalLaunchAsync(ILaunchActivatedEventArgs e) { UIElement splashScreen = default(UIElement); if (this.SplashFactory != null) { splashScreen = this.SplashFactory(e.SplashScreen); Window.Current.Content = splashScreen; } this.RootFrame = this.RootFrame ?? new Frame(); this.RootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0]; this.NavigationService = new Services.NavigationService(this.RootFrame); // the user may override to set custom content await OnInitializeAsync(); if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { try { /* TODO: restore state */ } finally { await this.OnLaunchedAsync(e); } } else { await this.OnLaunchedAsync(e); } // if the user didn't already set custom content use rootframe if (Window.Current.Content == splashScreen) { Window.Current.Content = this.RootFrame; } if (Window.Current.Content == null) { Window.Current.Content = this.RootFrame; } Window.Current.Activate(); Windows.UI.Core.SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested; }
async void CallInternalLaunchAsync(ILaunchActivatedEventArgs e) { CurrentState = States.BeforeLaunch; await InternalLaunchAsync(e); CurrentState = States.AfterLaunch; }
private async void InternalLaunchAsync(ILaunchActivatedEventArgs e) { if (this.SplashFactory != null) { Window.Current.Content = this.SplashFactory(e.SplashScreen); Window.Current.Activate(); Window.Current.Content = null; } this.RootFrame = this.RootFrame ?? new Frame(); this.RootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0]; this.NavigationService = new Services.NavigationService.NavigationService(this.RootFrame); // the user may override to set custom content await OnInitializeAsync(); // if the user didn't set custom content, use frame if (Window.Current.Content == null) { Window.Current.Content = this.RootFrame; } if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { try { /* TODO: restore state */ } catch { /* TODO: handle fail */ } } else { // this is to handle any other type of launch await this.OnLaunchedAsync(e); } Window.Current.Activate(); }
/// <summary> /// Helper method to extract the full Push JSON provided to Parse, including any /// non-visual custom information. Overloads exist for all data types which may be /// provided by Windows, I.E. LaunchActivatedEventArgs and PushNotificationReceivedEventArgs. /// Returns an empty dictionary if this push type cannot include non-visual data or /// this event was not triggered by a push. /// </summary> public static IDictionary<string, object> PushJson(ILaunchActivatedEventArgs eventArgs) { if (eventArgs == null || eventArgs.Kind != ActivationKind.Launch || eventArgs.Arguments == null) { return new Dictionary<string, object>(); } return PushJson(eventArgs.Arguments); }
private async void CallInternalLaunchAsync(ILaunchActivatedEventArgs args) { this.CurrentState = ApplicationState.BeforeLaunch; await this.InternalLaunchAsync(args); this.CurrentState = ApplicationState.AfterLaunch; }
public override Task OnLaunchedAsync(ILaunchActivatedEventArgs e) { // Navigate to main page this.NavigationService.Navigate(typeof(Views.MainPage)); // Register voice commands async return(InstallVoiceCommandsAsync()); }
public override async Task OnLaunchedAsync(ILaunchActivatedEventArgs e) { // handle long-running tasks await Task.Delay(5000); // first screen this.NavigationService.Navigate(typeof(Views.MainPage)); }
public override Task OnLaunchedAsync(ILaunchActivatedEventArgs e) { // Navigate to main page this.NavigationService.Navigate(typeof(Views.MainPage)); // Register voice commands async return InstallVoiceCommandsAsync(); }
private async Task <bool> CallAutoRestoreAsync(ILaunchActivatedEventArgs e, bool restored) { if (!EnableAutoRestoreAfterTerminated || !AutoRestoreAfterTerminated) { return(false); } return(await _LifecycleLogic.AutoRestoreAsync(e, NavigationService)); }
private async void InternalLaunchAsync(ILaunchActivatedEventArgs e) { UIElement splashScreen = default(UIElement); if (this.SplashFactory != null) { splashScreen = this.SplashFactory(e.SplashScreen); Window.Current.Content = splashScreen; } this.RootFrame = this.RootFrame ?? new Frame(); this.RootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0]; this.NavigationService = new Services.NavigationService.NavigationService(this.RootFrame); // the user may override to set custom content await OnInitializeAsync(); if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { try { /* TODOAdaptiveUISample: restore state */ } finally { await this.OnLaunchedAsync(e); } } else { await this.OnLaunchedAsync(e); } // if the user didn't already set custom content use rootframe if (Window.Current.Content == splashScreen) { Window.Current.Content = this.RootFrame; } if (Window.Current.Content == null) { Window.Current.Content = this.RootFrame; } Window.Current.Activate(); // Install VCD try { var storageFile = await Windows.Storage.StorageFile .GetFileFromApplicationUriAsync(new Uri("ms-appx:///vcd.xml")); await Windows.ApplicationModel.VoiceCommands.VoiceCommandDefinitionManager .InstallCommandDefinitionsFromStorageFileAsync(storageFile); } catch { if (Debugger.IsAttached) { Debugger.Break(); } } // Hook up the default Back handler Windows.UI.Core.SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested; }
public override Task OnLaunchedAsync(ILaunchActivatedEventArgs e) { // Load the database SQLiteService.LoadDatabase(); this.NavigationService.Navigate(typeof(Views.MainPage)); return Task.FromResult<object>(null); }
public override Task OnLaunchedAsync(ILaunchActivatedEventArgs e) { // Load the database SQLiteService.LoadDatabase(); this.NavigationService.Navigate(typeof(Views.MainPage)); return(Task.FromResult <object>(null)); }
/// <summary> /// Helper method to extract the full Push JSON provided to Parse, including any /// non-visual custom information. Overloads exist for all data types which may be /// provided by Windows, I.E. LaunchActivatedEventArgs and PushNotificationReceivedEventArgs. /// Returns an empty dictionary if this push type cannot include non-visual data or /// this event was not triggered by a push. /// </summary> private static IDictionary <string, object> PushJson(ILaunchActivatedEventArgs eventArgs) { if (eventArgs == null || eventArgs.Kind != ActivationKind.Launch || eventArgs.Arguments == null) { return(new Dictionary <string, object>()); } return(PushJson(eventArgs.Arguments)); }
private Frame InitializeFrame(ILaunchActivatedEventArgs e) { // do not recreate the frame if (Window.Current.Content is Frame) { return(Window.Current.Content as Frame); } // first show the splash var splashScreen = default(UIElement); if (SplashFactory != null) { splashScreen = SplashFactory(e.SplashScreen); Window.Current.Content = splashScreen; Window.Current.Activate(); } // next create frame var frame = new Frame { Language = Windows.Globalization.ApplicationLanguages.Languages[0] }; frame.Navigated += (s, args) => { SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = (ShowShellBackButton && frame.CanGoBack) ? AppViewBackButtonVisibility.Visible : AppViewBackButtonVisibility.Collapsed; }; Window.Current.Content = frame; // next setup the default view var navigationService = new Services.NavigationService.NavigationService(frame); WindowWrapper.Current().NavigationServices.Add(navigationService); // expire any state (based on expiry) DateTime cacheDate; var otherwise = DateTime.MinValue.ToString(); if (DateTime.TryParse(navigationService.FrameFacade.GetFrameState(CacheDateKey, otherwise), out cacheDate)) { var cacheAge = DateTime.Now.Subtract(cacheDate); if (cacheAge >= CacheMaxDuration) { // clear state in every nav service in every view foreach (var service in WindowWrapper.ActiveWrappers.SelectMany(x => x.NavigationServices)) { service.FrameFacade.ClearFrameState(); } } } else /* no date, that's okay */ } {
public async Task <bool> AutoRestoreAsync(ILaunchActivatedEventArgs e, INavigationService nav) { var restored = false; var launchedEvent = e as ILaunchActivatedEventArgs; if (BootStrapper.DetermineStartCause(e) == AdditionalKinds.Primary || launchedEvent?.TileId == "") { restored = await nav.LoadAsync(); } return(restored); }
/// <summary> /// Initializes a new instance of the <see cref="DeepLinkParser" /> class. /// </summary> /// <param name="args">The <see cref="IActivatedEventArgs"/> instance containing the event data.</param> /// <exception cref="System.ArgumentException">'args' is not a LaunchActivatedEventArgs instance</exception> protected DeepLinkParser(IActivatedEventArgs args) { inputArgs = args as ILaunchActivatedEventArgs; if (inputArgs == null) { throw new ArgumentException("'args' is not a LaunchActivatedEventArgs instance", nameof(args)); } ParseUriString(inputArgs.Arguments); }
public static async Task OnLaunchedAsync(ILaunchActivatedEventArgs args) { await ParseInstallation.CurrentInstallation.SaveAsync(); await ParseAnalytics.TrackAppOpenedAsync(args); }
public async Task <bool> AutoRestoreAsync(ILaunchActivatedEventArgs e, INavigationService nav) { var restored = false; var launchedEvent = e as ILaunchActivatedEventArgs; if (DetermineStartCause(e) == AdditionalKinds.Primary || launchedEvent?.TileId == "") { restored = await nav.RestoreSavedNavigationAsync(); DebugWrite($"{nameof(restored)}:{restored}", caller: nameof(nav.RestoreSavedNavigationAsync)); } return(restored); }
/// <summary> /// Tracks this application being launched. If the LaunchActivatedEventArgs /// parameter contains push data passed through from a Toast's "launch" /// parameter, then we extract and report information to correlate this /// application open with that push. /// </summary> /// <param name="launchArgs">The LaunchActivatedEventArgs available in an /// Application.OnLaunched override.</param> /// <returns>An Async Task that can be waited on or ignored.</returns> public static Task TrackAppOpenedAsync(ILaunchActivatedEventArgs launchArgs) { // Short-circuit if the Launch event isn't from an actual app launch. // We'll still phone home if the launchArgs passed in is null, though, // so here we only check for a non-Launch ActivationKind. if (launchArgs != null && launchArgs.Kind != ActivationKind.Launch) { return ((Task)null).Safe(); } object pushHash; IDictionary<string, object> contentJson = ParsePush.PushJson(launchArgs); contentJson.TryGetValue("push_hash", out pushHash); return ParseAnalytics.TrackAppOpenedWithPushHashAsync((string)pushHash); }
private void GetActivationInfo() { AppActivationArguments args = AppInstance.GetCurrent().GetActivatedEventArgs(); ExtendedActivationKind kind = args.Kind; OutputMessage($"ActivationKind: {kind}"); if (kind == ExtendedActivationKind.Launch) { ILaunchActivatedEventArgs launchArgs = args.Data as ILaunchActivatedEventArgs; if (launchArgs != null) { string argString = launchArgs.Arguments; string[] argStrings = argString.Split(); foreach (string arg in argStrings) { if (!string.IsNullOrWhiteSpace(arg)) { OutputMessage(arg); } } } } else if (kind == ExtendedActivationKind.File) { IFileActivatedEventArgs fileArgs = args.Data as IFileActivatedEventArgs; if (fileArgs != null) { IStorageItem file = fileArgs.Files.FirstOrDefault(); OutputMessage(file.Name); } } else if (kind == ExtendedActivationKind.Protocol) { IProtocolActivatedEventArgs protocolArgs = args.Data as IProtocolActivatedEventArgs; if (protocolArgs != null) { Uri uri = protocolArgs.Uri; OutputMessage(uri.AbsoluteUri); } } else if (kind == ExtendedActivationKind.StartupTask) { IStartupTaskActivatedEventArgs startupArgs = args.Data as IStartupTaskActivatedEventArgs; if (startupArgs != null) { OutputMessage(startupArgs.TaskId); } } }
public override async Task<bool> OnLaunchAsync(ILaunchActivatedEventArgs e) { if (e.TileId.StartsWith("Run_")) { JsonObject args = JsonObject.Parse(e.Arguments); if (args.ContainsKey("url")) { var url = args.GetNamedString("url"); // LaunchUriAsynch returns false if launch failed return !(await Launcher.LaunchUriAsync(new Uri(url))); } } return true; }
public override async Task <bool> OnLaunchAsync(ILaunchActivatedEventArgs e) { if (e.TileId.StartsWith("Run_")) { JsonObject args = JsonObject.Parse(e.Arguments); if (args.ContainsKey("url")) { var url = args.GetNamedString("url"); // LaunchUriAsynch returns false if launch failed return(!(await Launcher.LaunchUriAsync(new Uri(url)))); } } return(true); }
/// <summary> /// Tracks this application being launched. If the LaunchActivatedEventArgs /// parameter contains push data passed through from a Toast's "launch" /// parameter, then we extract and report information to correlate this /// application open with that push. /// </summary> /// <param name="launchArgs">The LaunchActivatedEventArgs available in an /// Application.OnLaunched override.</param> /// <returns>An Async Task that can be waited on or ignored.</returns> public static Task TrackAppOpenedAsync(ILaunchActivatedEventArgs launchArgs) { // Short-circuit if the Launch event isn't from an actual app launch. // We'll still phone home if the launchArgs passed in is null, though, // so here we only check for a non-Launch ActivationKind. if (launchArgs != null && launchArgs.Kind != ActivationKind.Launch) { return(((Task)null).Safe()); } object pushHash; IDictionary <string, object> contentJson = AVPush.PushJson(launchArgs); contentJson.TryGetValue("push_hash", out pushHash); return(AVAnalytics.TrackAppOpenedWithPushHashAsync((string)pushHash)); }
/// <summary> /// Attempt to restore a lifecycle session /// </summary> /// <param name="args"> /// The launch arguments. /// </param> /// <param name="nav"> /// The navigation service. /// </param> /// <returns> /// The <see cref="Task"/> of <see cref="bool" />. This represents whether the session was restored /// </returns> public async Task <bool> AutoRestoreAsync(ILaunchActivatedEventArgs args, INavigationService nav) { if (Bootstrapper.DetermineStartCause(args) != AdditionalKinds.Primary && args?.TileId != string.Empty) { return(false); } var restored = await nav.RestoreSavedNavigationAsync(); this.loggingService.WriteLine( $"{nameof(restored)}:{restored}", caller: nameof(nav.RestoreSavedNavigationAsync)); return(restored); }
protected void InternalLaunch(ILaunchActivatedEventArgs e) { if (e.PreviousExecutionState != ApplicationExecutionState.Running) { InitializeFrame(e); } //adding a default navigation service if (!NavigationServices.IsRegistered("Default")) { NavigationServices.Register("Default", WindowWrapper.Current().NavigationService); } // okay, now handle launch switch (e.PreviousExecutionState) { case ApplicationExecutionState.Terminated: { OnStart(StartKind.Launch, e); SubscribeBackButton(); break; } case ApplicationExecutionState.ClosedByUser: case ApplicationExecutionState.NotRunning: // launch if not restored OnStart(StartKind.Launch, e); SubscribeBackButton(); break; case ApplicationExecutionState.Running: OnStart(StartKind.Activate, e); break; default: { // launch if not restored OnStart(StartKind.Launch, e); break; } } }
/// <summary> /// Tracks this application being launched. If the LaunchActivatedEventArgs /// parameter contains push data passed through from a Toast's "launch" /// parameter, then we extract and report information to correlate this /// application open with that push. /// </summary> /// <param name="launchArgs">The LaunchActivatedEventArgs available in an /// Application.OnLaunched override.</param> /// <returns>An Async Task that can be waited on or ignored.</returns> public static Task TrackAppOpenedAsync(ILaunchActivatedEventArgs launchArgs) { // Short-circuit if the Launch event isn't from an actual app launch. // We'll still phone home if the launchArgs passed in is null, though, // so here we only check for a non-Launch ActivationKind. if (launchArgs != null && launchArgs.Kind != ActivationKind.Launch) { return ((Task)null).Safe(); } IDictionary<string, object> contentJson = ParsePush.PushJson(launchArgs); object alert; string pushHash = null; if(contentJson.TryGetValue("alert", out alert)) { pushHash = ParseAnalyticsUtilities.MD5DigestFromPushPayload(alert); } return ParseAnalytics.TrackAppOpenedWithPushHashAsync(pushHash); }
private void InternalLaunch(ILaunchActivatedEventArgs e) { var splashScreen = default(UIElement); if (SplashFactory != null) { splashScreen = SplashFactory(e.SplashScreen); Window.Current.Content = splashScreen; } RootFrame = RootFrame ?? new Frame(); RootFrame.Language = ApplicationLanguages.Languages[0]; NavigationService = Kernel.Resolve <INavigationService>(); // the user may override to set custom content OnInitialize(); if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { Kernel.OnRelaunched(); try { NavigationService.RestoreSavedNavigation(); } finally { OnRelaunched(e); } } else { Kernel.OnLaunched(); OnLaunched(e); } // if the user didn't already set custom content use rootframe if (Window.Current.Content == splashScreen || Window.Current.Content == null) { Window.Current.Content = RootFrame; } Window.Current.Activate(); // Hook up the default Back handler SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested; }
private async void InternalLaunchAsync(ILaunchActivatedEventArgs e) { UIElement splashScreen = default(UIElement); if (this.SplashFactory != null) { splashScreen = this.SplashFactory(e.SplashScreen); Window.Current.Content = splashScreen; } this.RootFrame = this.RootFrame ?? new Frame(); this.RootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0]; this.NavigationService = new Services.NavigationService.NavigationService(this.RootFrame); // the user may override to set custom content await OnInitializeAsync(); if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { try { /* TODOAzureSample: restore state */ NavigationService.RestoreSavedNavigation(); } finally { await this.OnLaunchedAsync(e); } } else { await this.OnLaunchedAsync(e); } // if the user didn't already set custom content use rootframe if (Window.Current.Content == splashScreen) { Window.Current.Content = this.RootFrame; } if (Window.Current.Content == null) { Window.Current.Content = this.RootFrame; } Window.Current.Activate(); // Hook up the default Back handler Windows.UI.Core.SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested; }
private static MainPage ActivateNewMainPage(ILaunchActivatedEventArgs e, Frame rootFrame) { if (rootFrame == null) { throw new Exception("Tried to activate null frame"); } 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 rootFrame.Navigate(typeof(MainPage), e?.Arguments ?? ""); } // Ensure the current window is active Window.Current?.Activate(); return(rootFrame.Content as MainPage); }
private async Task InternalLaunchAsync(ILaunchActivatedEventArgs args) { Bootstrapper.DebugWrite($"Previous: { args.PreviousExecutionState.ToString() }"); this.OriginalActivatedArgs = args; if (args.PreviousExecutionState != ApplicationExecutionState.Running) { try { await this.InitializeFrameAsync(args); } catch (Exception ex) { Bootstrapper.DebugWrite($"InternalLaunch Exception:{ex.Message}"); } } var restored = false; switch (args.PreviousExecutionState) { case ApplicationExecutionState.Suspended: case ApplicationExecutionState.Terminated: { this.OnResuming(this, null, AppExecutionState.Terminated); restored = await this.CallAutoRestoreAsync(args, restored); break; } } if (!restored) { var kind = args.PreviousExecutionState == ApplicationExecutionState.Running ? StartKind.Activate : StartKind.Launch; await this.CallOnStartAsync(true, kind); } this.CallActivateWindow(ActivateWindowSources.Launching); }
/// <summary> /// Tracks this application being launched. If the LaunchActivatedEventArgs /// parameter contains push data passed through from a Toast's "launch" /// parameter, then we extract and report information to correlate this /// application open with that push. /// </summary> /// <param name="launchArgs">The LaunchActivatedEventArgs available in an /// Application.OnLaunched override.</param> /// <returns>An Async Task that can be waited on or ignored.</returns> public static Task TrackAppOpenedAsync(ILaunchActivatedEventArgs launchArgs) { // Short-circuit if the Launch event isn't from an actual app launch. // We'll still phone home if the launchArgs passed in is null, though, // so here we only check for a non-Launch ActivationKind. if (launchArgs != null && launchArgs.Kind != ActivationKind.Launch) { return(((Task)null).Safe()); } IDictionary <string, object> contentJson = ParsePush.PushJson(launchArgs); object alert; string pushHash = null; if (contentJson.TryGetValue("alert", out alert)) { pushHash = ParseAnalyticsUtilities.MD5DigestFromPushPayload(alert); } return(ParseAnalytics.TrackAppOpenedWithPushHashAsync(pushHash)); }
public override Task OnLaunchedAsync(ILaunchActivatedEventArgs e) { Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().SetPreferredMinSize(new Windows.Foundation.Size(320, 500)); // Apply shell drawn Back button this.RootFrame.Navigated += (s, a) => { if (this.RootFrame.CanGoBack) { // Setting this visible is ignored on Mobile and when in tablet mode! SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible; } else { SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed; } }; // Navigate to MainPage this.NavigationService.Navigate(typeof(Views.UserSelect)); return(Task.FromResult <object>(null)); }
/// <summary> /// InitializeFrameAsync creates a default Frame preceeded by the optional /// splash screen, then OnInitialzieAsync, then the new frame (if necessary). /// This is private because there's no reason for the developer to call this. /// </summary> private async Task InitializeFrameAsync(ILaunchActivatedEventArgs e) { // first show the splash FrameworkElement splash = null; if (SplashFactory != null) { Window.Current.Content = splash = SplashFactory(e.SplashScreen); Window.Current.Activate(); } // allow the user to do things, even when restoring await OnInitializeAsync(e); // create the default frame only if there's nothing already there // if it is not null, by the way, then the developer injected something & they win if (Window.Current.Content == splash || Window.Current.Content == null) { // build the default frame Window.Current.Content = NavigationServiceFactory(BackButton.Attach, ExistingContent.Include).Frame; } }
public override Task OnLaunchedAsync(ILaunchActivatedEventArgs e) { Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().SetPreferredMinSize(new Windows.Foundation.Size(320, 500)); // Apply shell drawn Back button this.RootFrame.Navigated += (s, a) => { if (this.RootFrame.CanGoBack) { // Setting this visible is ignored on Mobile and when in tablet mode! SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible; } else { SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed; } }; // Navigate to MainPage this.NavigationService.Navigate(typeof(Views.UserSelect)); return Task.FromResult<object>(null); }
public abstract Task OnLaunchedAsync(ILaunchActivatedEventArgs e);
private async void InternalLaunchAsync(ILaunchActivatedEventArgs e) { UIElement splashScreen = default(UIElement); if (this.SplashFactory != null) { splashScreen = this.SplashFactory(e.SplashScreen); Window.Current.Content = splashScreen; } this.RootFrame = this.RootFrame ?? new Frame(); this.RootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0]; this.NavigationService = new Services.NavigationService.NavigationService(this.RootFrame); // the user may override to set custom content await OnInitializeAsync(); if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { try { /* TODOAdaptiveUISample: restore state */ } finally { await this.OnLaunchedAsync(e); } } else { await this.OnLaunchedAsync(e); } // if the user didn't already set custom content use rootframe if (Window.Current.Content == splashScreen) { Window.Current.Content = this.RootFrame; } if (Window.Current.Content == null) { Window.Current.Content = this.RootFrame; } Window.Current.Activate(); // Install VCD try { var storageFile = await Windows.Storage.StorageFile .GetFileFromApplicationUriAsync(new Uri("ms-appx:///vcd.xml")); await Windows.ApplicationModel.VoiceCommands.VoiceCommandDefinitionManager .InstallCommandDefinitionsFromStorageFileAsync(storageFile); } catch { if (Debugger.IsAttached) { Debugger.Break(); } } // Hook up notifications // Modify variables at the begining of this page and uncomment these lines //var channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync(); //NotificationHub hub = new NotificationHub(hubPath, connectionStr); //await hub.RegisterNativeAsync(channel.Uri); // Hook up background task for notifications await RegisterRawNotificationBackgroundTask(); await RegisterActionableToastBackgroundTask(); // Hook up the default Back handler Windows.UI.Core.SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested; }
private async void InternalLaunchAsync(ILaunchActivatedEventArgs e) { UIElement splashScreen = default(UIElement); if (SplashFactory != null) { splashScreen = SplashFactory(e.SplashScreen); Window.Current.Content = splashScreen; } // setup frame RootFrame = RootFrame ?? new Frame(); RootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0]; NavigationService = new Services.NavigationService.NavigationService(RootFrame); // expire state var state = NavigationService.State(); if (state.Values.ContainsKey(CacheKey)) { DateTime cacheDate; if (DateTime.TryParse(state.Values[CacheKey]?.ToString(), out cacheDate)) { var cacheAge = DateTime.Now.Subtract(cacheDate); if (cacheAge >= CacheMaxDuration) { foreach (var item in state.Containers) { state.DeleteContainer(item.Key); } state.Values.Clear(); } } } // the user may override to set custom content await OnInitializeAsync(); switch (e.PreviousExecutionState) { case ApplicationExecutionState.NotRunning: case ApplicationExecutionState.Running: case ApplicationExecutionState.Suspended: { // launch if not restored await OnStartAsync(StartKind.Launch, e); break; } case ApplicationExecutionState.Terminated: await OnStartAsync(StartKind.Launch, e); break; case ApplicationExecutionState.ClosedByUser: { // restore if you need to/can do var restored = NavigationService.RestoreSavedNavigation(); if (!restored) { await OnStartAsync(StartKind.Launch, e); } break; } } // if the user didn't already set custom content use rootframe if (Window.Current.Content == splashScreen) { Window.Current.Content = RootFrame; } if (Window.Current.Content == null) { Window.Current.Content = RootFrame; } // ensure active Window.Current.Activate(); // Hook up the default Back handler Windows.UI.Core.SystemNavigationManager.GetForCurrentView().BackRequested += (s, args) => { args.Handled = true; OnBackRequested(); }; // Hook up keyboard and mouse Back handler var keyboard = new Services.KeyboardService.KeyboardService(); keyboard.AfterBackGesture = () => OnBackRequested(); // Hook up keyboard and house Forward handler keyboard.AfterForwardGesture = () => OnForwardRequested(); }
public override void OnLaunched(ILaunchActivatedEventArgs e) { NavigationService.Navigate(NavigationService.DefaultPage); }
/// <summary> /// This handles all the preliminary stuff unique to Launched before calling OnStartAsync(). /// This is private because it is a specialized prelude to OnStartAsync(). /// OnStartAsync will not be called if state restore is determined /// </summary> private async void InternalLaunchAsync(ILaunchActivatedEventArgs e) { DebugWrite($"Previous:{e.PreviousExecutionState.ToString()}"); OriginalActivatedArgs = e; if (e.PreviousExecutionState != ApplicationExecutionState.Running) { try { await InitializeFrameAsync(e); } catch (Exception) { // nothing } } // okay, now handle launch bool restored = false; switch (e.PreviousExecutionState) { case ApplicationExecutionState.Suspended: case ApplicationExecutionState.Terminated: { OnResuming(this, null, AppExecutionState.Terminated); /* * Restore state if you need to/can do. * Remember that only the primary tile should restore. * (this includes toast with no data payload) * The rest are already providing a nav path. * * In the event that the cache has expired, attempting to restore * from state will fail because of missing values. * This is okay & by design. */ if (DetermineStartCause(e) == AdditionalKinds.Primary) { restored = await NavigationService.RestoreSavedNavigationAsync(); DebugWrite($"{nameof(restored)}:{restored}", caller: nameof(NavigationService.RestoreSavedNavigationAsync)); } break; } case ApplicationExecutionState.ClosedByUser: case ApplicationExecutionState.NotRunning: default: break; } // handle pre-launch if ((e as LaunchActivatedEventArgs)?.PrelaunchActivated ?? false) { var runOnStartAsync = false; _HasOnPrelaunchAsync = true; await OnPrelaunchAsync(e, out runOnStartAsync); if (!runOnStartAsync) { return; } } if (!restored) { DebugWrite("Calling", caller: nameof(OnStartAsync)); _HasOnStartAsync = true; await OnStartAsync(StartKind.Launch, e); } // ensure active (this will hide any custom splashscreen) Window.Current.Activate(); }
/// <summary> /// This handles all the preliminary stuff unique to Launched before calling OnStartAsync(). /// This is private because it is a specialized prelude to OnStartAsync(). /// OnStartAsync will not be called if state restore is determined /// </summary> private async void InternalLaunchAsync(ILaunchActivatedEventArgs e) { if (e.PreviousExecutionState != ApplicationExecutionState.Running) { await InitializeFrameAsync(e); } // okay, now handle launch switch (e.PreviousExecutionState) { //case ApplicationExecutionState.ClosedByUser: case ApplicationExecutionState.Terminated: { /* * Restore state if you need to/can do. * Remember that only the primary tile should restore. * (this includes toast with no data payload) * The rest are already providing a nav path. * * In the event that the cache has expired, attempting to restore * from state will fail because of missing values. * This is okay & by design. */ if (DetermineStartCause(e) == AdditionalKinds.Primary) { var restored = NavigationService.RestoreSavedNavigation(); if (!restored) { await OnStartAsync(StartKind.Launch, e); } } else { await OnStartAsync(StartKind.Launch, e); } SubscribeBackButton(); break; } case ApplicationExecutionState.ClosedByUser: case ApplicationExecutionState.NotRunning: // launch if not restored await OnStartAsync(StartKind.Launch, e); SubscribeBackButton(); break; default: { // launch if not restored await OnStartAsync(StartKind.Launch, e); break; } } // ensure active (this will hide any custom splashscreen) Window.Current.Activate(); // Hook up keyboard and mouse Back handler var keyboard = new Services.KeyboardService.KeyboardService(); keyboard.AfterBackGesture = () => { //the result is no matter var handled = false; RaiseBackRequested(ref handled); }; // Hook up keyboard and mouse Forward handler keyboard.AfterForwardGesture = RaiseForwardRequested; }
/// <summary> /// InitializeFrameAsync creates a default Frame preceeded by the optional /// splash screen, then OnInitialzieAsync, then the new frame (if necessary). /// This is private because there's no reason for the developer to call this. /// </summary> private async Task InitializeFrameAsync(ILaunchActivatedEventArgs e) { // first show the splash Page splash = null; if (SplashFactory != null) { Window.Current.Content = splash = SplashFactory(e.SplashScreen); Window.Current.Activate(); } // allow the user to do things, even when restoring await OnInitializeAsync(e); // create the default frame only if there's nothing already there if (Window.Current.Content == splash || Window.Current.Content == null) { // build the default frame var result = FrameFactory(true); Window.Current.Content = result.Frame; } }
private async void InternalLaunchAsync(ILaunchActivatedEventArgs e) { UIElement splashScreen = default(UIElement); if (SplashFactory != null) { splashScreen = SplashFactory(e.SplashScreen); Window.Current.Content = splashScreen; } RootFrame = RootFrame ?? new Frame(); RootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0]; NavigationService = new Services.NavigationService.NavigationService(RootFrame); // the user may override to set custom content await OnInitializeAsync(); switch (e.PreviousExecutionState) { case ApplicationExecutionState.NotRunning: case ApplicationExecutionState.Running: case ApplicationExecutionState.Suspended: { // launch if not restored await OnStartAsync(StartKind.Launch, e); break; } case ApplicationExecutionState.Terminated: case ApplicationExecutionState.ClosedByUser: { if (EnableRestoreNavigationState) { // restore if you need to/can do var restored = NavigationService.RestoreSavedNavigation(); if (!restored) await OnStartAsync(StartKind.Launch, e); } else { await OnStartAsync(StartKind.Launch, e); } break; } } // if the user didn't already set custom content use rootframe if (Window.Current.Content == splashScreen) { Window.Current.Content = RootFrame; } if (Window.Current.Content == null) { Window.Current.Content = RootFrame; } // ensure active Window.Current.Activate(); // Hook up the default Back handler Windows.UI.Core.SystemNavigationManager.GetForCurrentView().BackRequested += (s, args) => { args.Handled = true; OnBackRequested(); }; // Hook up keyboard and mouse Back handler var keyboard = new Services.KeyboardService.KeyboardService(); keyboard.AfterBackGesture = () => OnBackRequested(); // Hook up keyboard and house Forward handler keyboard.AfterForwardGesture = () => OnForwardRequested(); }
public override Task OnLaunchedAsync(ILaunchActivatedEventArgs e) { this.NavigationService.Navigate(typeof(Views.MainPage)); return(Task.FromResult <object>(null)); }
// this is private because it is a specialized prelude to OnStartAsync private async void InternalLaunchAsync(ILaunchActivatedEventArgs e) { // create the root frame var defaultFrame = InitializeFrame(e); // the user may override to set custom content await OnInitializeAsync(e); // okay, now handle launch switch (e.PreviousExecutionState) { case ApplicationExecutionState.NotRunning: case ApplicationExecutionState.Running: case ApplicationExecutionState.Suspended: { // launch if not restored await OnStartAsync(StartKind.Launch, e); break; } case ApplicationExecutionState.ClosedByUser: case ApplicationExecutionState.Terminated: { // restore if you need to/can do // restore if there is no TileId or if the app is luanched via the primary tile // TODO: is it actually possible to have a TileID of null? Don't think so. if (e.TileId == null || e.TileId == "App") { // In the event that the cache ahs expired, attempting to restore // from state will fail because of missing values. This is by design. var restored = NavigationService.RestoreSavedNavigation(); if (!restored) { await OnStartAsync(StartKind.Launch, e); } } else { await OnStartAsync(StartKind.Launch, e); } break; } } // ensure active (this will hide any custom splashscreen) Window.Current.Activate(); // Hook up the default Back handler global::Windows.UI.Core.SystemNavigationManager.GetForCurrentView().BackRequested += (s, args) => { // only handle as long as there is a default backstack args.Handled = !NavigationService.CanGoBack; RaiseBackRequested(); }; // Hook up keyboard and mouse Back handler var keyboard = new Services.KeyboardService.KeyboardService(); keyboard.AfterBackGesture = () => RaiseBackRequested(); // Hook up keyboard and house Forward handler keyboard.AfterForwardGesture = () => RaiseForwardRequested(); }
private async void InternalLaunchAsync(ILaunchActivatedEventArgs e) { // first handle prelaunch, which will not continue if ((e.Kind == ActivationKind.Launch) && ((e as LaunchActivatedEventArgs)?.PrelaunchActivated ?? false)) { OnPrelaunch(); return; } // now handle normal activation UIElement splashScreen = default(UIElement); if (SplashFactory != null) { splashScreen = SplashFactory(e.SplashScreen); Window.Current.Content = splashScreen; } // setup frame var frame = new Frame { Language = global::Windows.Globalization.ApplicationLanguages.Languages[0] }; frame.Navigated += (s, args) => { global::Windows.UI.Core.SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = (ShowShellBackButton && frame.CanGoBack) ? AppViewBackButtonVisibility.Visible : AppViewBackButtonVisibility.Collapsed; }; // setup default view var view = WindowWrapper.ActiveWrappers.First(); var navigationService = new Services.NavigationService.NavigationService(frame); view.NavigationServices.Add(navigationService); // expire state (based on expiry) DateTime cacheDate; var otherwise = DateTime.MinValue.ToString(); if (DateTime.TryParse(navigationService.Frame.GetFrameState(CacheKey, otherwise), out cacheDate)) { var cacheAge = DateTime.Now.Subtract(cacheDate); if (cacheAge >= CacheMaxDuration) { // clear state in every nav service in every view foreach (var service in WindowWrapper.ActiveWrappers.SelectMany(x => x.NavigationServices)) { service.Frame.ClearFrameState(); } } } else { // no date, that's okay } // the user may override to set custom content await OnInitializeAsync(); switch (e.PreviousExecutionState) { case ApplicationExecutionState.NotRunning: case ApplicationExecutionState.Running: case ApplicationExecutionState.Suspended: { // launch if not restored await OnStartAsync(StartKind.Launch, e); break; } case ApplicationExecutionState.ClosedByUser: case ApplicationExecutionState.Terminated: { // restore if you need to/can do var restored = navigationService.RestoreSavedNavigation(); if (!restored) { await OnStartAsync(StartKind.Launch, e); } break; } } // if the user didn't already set custom content use rootframe if (Window.Current.Content == splashScreen) { Window.Current.Content = frame; } if (Window.Current.Content == null) { Window.Current.Content = frame; } // ensure active Window.Current.Activate(); // Hook up the default Back handler global::Windows.UI.Core.SystemNavigationManager.GetForCurrentView().BackRequested += (s, args) => { // TODO: handled=true canisn't true at end of backstack args.Handled = true; RaiseBackRequested(); }; // Hook up keyboard and mouse Back handler var keyboard = new Services.KeyboardService.KeyboardService(); keyboard.AfterBackGesture = () => RaiseBackRequested(); // Hook up keyboard and house Forward handler keyboard.AfterForwardGesture = () => RaiseForwardRequested(); }
public override Task OnLaunchedAsync(ILaunchActivatedEventArgs e) { this.NavigationService.Navigate(typeof(Views.MainPage)); return Task.FromResult<object>(null); }
public virtual Task<bool> OnLaunchAsync(ILaunchActivatedEventArgs e) { return Task.FromResult<bool>(true); }
/// <summary> /// InitializeFrameAsync creates a default Frame preceeded by the optional /// splash screen, then OnInitialzieAsync, then the new frame (if necessary). /// This is private because there's no reason for the developer to call this. /// </summary> private async Task InitializeFrameAsync(ILaunchActivatedEventArgs e) { // first show the splash FrameworkElement splash = null; if (SplashFactory != null) { Window.Current.Content = splash = SplashFactory(e.SplashScreen); Window.Current.Activate(); } // allow the user to do things, even when restoring await OnInitializeAsync(e); // create the default frame only if there's nothing already there // if it is not null, by the way, then the developer injected something & they win if (Window.Current.Content == splash || Window.Current.Content == null) { // build the default frame var result = FrameFactory(true); result.Frame.Content = splash; Window.Current.Content = result.Frame; } }
/// <summary> /// This handles all the preliminary stuff unique to Launched before calling OnStartAsync(). /// This is private because it is a specialized prelude to OnStartAsync(). /// OnStartAsync will not be called if state restore is determined /// </summary> private async Task InternalLaunchAsync(ILaunchActivatedEventArgs e) { DebugWrite($"Previous:{e.PreviousExecutionState.ToString()}"); OriginalActivatedArgs = e; if (e.PreviousExecutionState != ApplicationExecutionState.Running) { try { await InitializeFrameAsync(e); } catch (Exception) { // nothing } } // okay, now handle launch bool restored = false; switch (e.PreviousExecutionState) { case ApplicationExecutionState.Suspended: case ApplicationExecutionState.Terminated: { OnResuming(this, null, AppExecutionState.Terminated); /* * Restore state if you need to/can do. * Remember that only the primary tile or when user has * switched to the app (for instance via the task switcher) * should restore. (this includes toast with no data payload) * The rest are already providing a nav path. * * In the event that the cache has expired, attempting to restore * from state will fail because of missing values. * This is okay & by design. */ restored = await CallAutoRestoreAsync(e, restored); break; } case ApplicationExecutionState.ClosedByUser: case ApplicationExecutionState.NotRunning: default: break; } // handle pre-launch if ((e as LaunchActivatedEventArgs)?.PrelaunchActivated ?? false) { var runOnStartAsync = false; _HasOnPrelaunchAsync = true; await OnPrelaunchAsync(e, out runOnStartAsync); if (!runOnStartAsync) { return; } } if (!restored) { var kind = e.PreviousExecutionState == ApplicationExecutionState.Running ? StartKind.Activate : StartKind.Launch; await CallOnStartAsync(true, kind); } CallActivateWindow(WindowLogic.ActivateWindowSources.Launching); }
/// <summary> /// This handles all the preliminary stuff unique to Launched before calling OnStartAsync(). /// This is private because it is a specialized prelude to OnStartAsync(). /// OnStartAsync will not be called if state restore is determined /// </summary> private async void InternalLaunchAsync(ILaunchActivatedEventArgs e) { await InitializeFrameAsync(e); // okay, now handle launch switch (e.PreviousExecutionState) { case ApplicationExecutionState.ClosedByUser: case ApplicationExecutionState.Terminated: { /* Restore state if you need to/can do. Remember that only the primary tile should restore. (this includes toast with no data payload) The rest are already providing a nav path. In the event that the cache has expired, attempting to restore from state will fail because of missing values. This is okay & by design. */ if (DecipherStartCause(e) == AdditionalKinds.Primary) { var restored = NavigationService.RestoreSavedNavigation(); if (!restored) { await OnStartAsync(StartKind.Launch, e); } } else { await OnStartAsync(StartKind.Launch, e); } break; } default: { // launch if not restored await OnStartAsync(StartKind.Launch, e); break; } } // ensure active (this will hide any custom splashscreen) Window.Current.Activate(); // Hook up the default Back handler global::Windows.UI.Core.SystemNavigationManager.GetForCurrentView().BackRequested += (s, args) => { // only handle as long as there is a default backstack args.Handled = !NavigationService.CanGoBack; RaiseBackRequested(); }; // Hook up keyboard and mouse Back handler var keyboard = new Services.KeyboardService.KeyboardService(); keyboard.AfterBackGesture = () => RaiseBackRequested(); // Hook up keyboard and house Forward handler keyboard.AfterForwardGesture = () => RaiseForwardRequested(); }
// this is private because there's no reason for the developer to call this private Frame InitializeFrame(ILaunchActivatedEventArgs e) { // do not recreate the frame if (Window.Current.Content is Frame) return Window.Current.Content as Frame; // first show the splash var splashScreen = default(UIElement); if (SplashFactory != null) { splashScreen = SplashFactory(e.SplashScreen); Window.Current.Content = splashScreen; Window.Current.Activate(); } else { // if there is no SplashScreen then the default/static splash will show. } // in any case, next create a new, default frame var defaultFrame = new Frame { Language = Windows.Globalization.ApplicationLanguages.Languages[0] }; // set default frame as primary, default visual Window.Current.Content = defaultFrame; // next setup the default view var navigationService = new Services.NavigationService.NavigationService(defaultFrame); WindowWrapper.Current().NavigationServices.Add(navigationService); // this anon method will be used to refresh the shell back button Action updateShellBack = () => { // show the shell back only if there is anywhere to go in the default frame SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = (ShowShellBackButton && NavigationService.Frame.CanGoBack) ? AppViewBackButtonVisibility.Visible : AppViewBackButtonVisibility.Collapsed; }; // update shell back when backstack changes // only the default frame in this case because secondary should not dismiss the app defaultFrame.RegisterPropertyChangedCallback(Frame.BackStackDepthProperty, (s, args) => updateShellBack()); // update shell back when navigation occurs // only the default frame in this case because secondary should not dismiss the app defaultFrame.Navigated += (s, args) => updateShellBack(); // expire any state (based on expiry) DateTime cacheDate; // default the cache age to very fresh if not known var otherwise = DateTime.MinValue.ToString(); if (DateTime.TryParse(navigationService.FrameFacade.GetFrameState(CacheDateKey, otherwise), out cacheDate)) { var cacheAge = DateTime.Now.Subtract(cacheDate); if (cacheAge >= CacheMaxDuration) { // clear state in every nav service in every view foreach (var service in WindowWrapper.ActiveWrappers.SelectMany(x => x.NavigationServices)) { service.FrameFacade.ClearFrameState(); } } } else { // no date, that's okay } // finally return our new frame return defaultFrame; }