/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="args">Details about the launch request and process.</param> protected async override void OnLaunched(LaunchActivatedEventArgs args) { // Initialize base PerformBaseInitialize(); var rootFrame = InitializeRootFrameAndResourceLoader(args.PreviousExecutionState); if (_isIsinitialization) { await UpdateSampleRate(); var extendedSplashscreen = new ExtendedSplashScreen(args.SplashScreen, args.Arguments); rootFrame.Content = extendedSplashscreen; Window.Current.Activate(); _isIsinitialization = false; } else { if (args.Arguments.StartsWith("light-jumplist:")) { Messenger.Default.Send(new GenericMessage <string>(args.Arguments), CommonSharedStrings.ContentFrameNavigateToken); } // We only handle normal launch here. OnLaunchEvent(args.Arguments, rootFrame); } }
/// <summary> /// Handles application initialization after file activation completes. /// </summary> /// <param name="rootFrame">Instance of <see cref="Frame"/>.</param> /// <param name="args">Instance of <see cref="FileActivatedEventArgs"/>.</param> private async void OnFileActivated(Frame rootFrame, FileActivatedEventArgs args) { if (args.Kind != ActivationKind.File) { return; } //Disable previous playlist restore PlaybackControl.Instance.SetRestore(false); // Initialize the root frame and wait for it completes loading. if (rootFrame.Content == null) { var task = new TaskCompletionSource <object>(); var extendedSplashscreen = new ExtendedSplashScreen(args.SplashScreen, task); rootFrame.Content = extendedSplashscreen; _isIsinitialization = false; Window.Current.Activate(); base.OnFileActivated(args); await task.Task; } else { Window.Current.Activate(); base.OnFileActivated(args); } // Ensure the current window is active // Pass files to FileOpenFailure await FileOpen.OpenFilesAsync(args.Files); }
private async Task InitAsync(SplashScreen splash) { #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { this.DebugSettings.EnableFrameRateCounter = true; } #endif var appShell = AppShell.GetForCurrentView(); if (appShell == null) { //create app shell to hold app content appShell = AppShell.CreateForWindow(Window.Current); //create extended splash screen ExtendedSplashScreen extendedSplash = new ExtendedSplashScreen(splash, false); //temporarily place splash into the root frame appShell.UnderlyingFrame.Content = extendedSplash; SetupWindowServices(Window.Current); await InitializeMvvmCrossAsync(); //setup the title bar await SetupTitleBarAsync(); InitializeStyle(); } CoreApplication.EnablePrelaunch(true); // Ensure the current window is active Window.Current.Activate(); }
/// <summary> /// 在应用程序由最终用户正常启动时进行调用。 /// 将在启动应用程序以打开特定文件等情况下使用。 /// </summary> /// <param name="e">有关启动请求和过程的详细信息。</param> protected override void OnLaunched(LaunchActivatedEventArgs e) { if (e.PreviousExecutionState != ApplicationExecutionState.Running) { bool loadState = (e.PreviousExecutionState == ApplicationExecutionState.Terminated); ExtendedSplashScreen extendedSplash = new ExtendedSplashScreen(e.SplashScreen, loadState); Window.Current.Content = extendedSplash; } Window.Current.Activate(); }
private static async Task <UIElement> BuildExtendedSplashScreenAsync(Window hostWindow, ExtendedSplashScreenContent extendedSplashScreenContent, IActivatedEventArgs args) { // 用于等待 ExtendedSplashScreen 构造完成。因为 RunAsync 方法第二个参数签名是 async void,不是 async Task。 TaskCompletionSource <UIElement> containerTcs = new TaskCompletionSource <UIElement>(); await hostWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { ExtendedSplashScreen extendedSplashScreen = await ExtendedSplashScreen.CreateAsync(args.SplashScreen, extendedSplashScreenContent); containerTcs.SetResult(extendedSplashScreen); }); return(await containerTcs.Task); }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override void OnLaunched(LaunchActivatedEventArgs e) { if (e.PreviousExecutionState != ApplicationExecutionState.Running) { bool loadState = (e.PreviousExecutionState == ApplicationExecutionState.Terminated); var extendedSplash = new ExtendedSplashScreen(e.SplashScreen, loadState); Window.Current.Content = extendedSplash; } OverrideTitleBarColor(); // Ensure the current window is active Window.Current.Activate(); }
/// <summary> /// Chamado quando o aplicativo é iniciado normalmente pelo usuário final. Outros pontos de entrada /// serão usados, por exemplo, quando o aplicativo for iniciado para abrir um arquivo específico. /// </summary> /// <param name="e">Detalhes sobre a solicitação e o processo de inicialização.</param> protected override void OnLaunched(LaunchActivatedEventArgs e) { ApplicationViewTitleBar formattableTitleBar = ApplicationView.GetForCurrentView().TitleBar; var green = Color.FromArgb(255, 16, 124, 16); formattableTitleBar.ButtonBackgroundColor = green; formattableTitleBar.BackgroundColor = green; formattableTitleBar.ButtonInactiveBackgroundColor = green; formattableTitleBar.InactiveBackgroundColor = green; Frame rootFrame = Window.Current.Content as Frame; // Não repita a inicialização do aplicativo quando a Janela já tiver conteúdo, // apenas verifique se a janela está ativa if (rootFrame == null) { // Crie um Quadro para atuar como o contexto de navegação e navegue para a primeira página rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { // TODO: Carregue o estado do aplicativo suspenso anteriormente } // Coloque o quadro na Janela atual Window.Current.Content = rootFrame; if (e.PreviousExecutionState != ApplicationExecutionState.Running) { bool loadState = (e.PreviousExecutionState == ApplicationExecutionState.Terminated); ExtendedSplashScreen extendedSplash = new ExtendedSplashScreen(e.SplashScreen, loadState); Window.Current.Content = extendedSplash; } } if (e.PrelaunchActivated == false) { if (rootFrame.Content == null) { // Quando a pilha de navegação não for restaurada, navegar para a primeira página, // configurando a nova página passando as informações necessárias como um parâmetro // parâmetro //rootFrame.Navigate(typeof(MainPage), e.Arguments); } // Verifique se a janela atual está ativa Window.Current.Activate(); } }
/// <summary> /// Initializes a new instance of the <see cref="MainView"/> class. /// </summary> /// <param name="splash">The Splash Screen data for the loading screen.</param> public MainView(SplashScreen splash) { this.InitializeComponent(); ExtendedSplashScreen.InitializeAnimation(splash); ConnectionProfile connections = NetworkInformation.GetInternetConnectionProfile(); if (connections != null) { ViewModel.Login(); } else { Messenger.Default.Send(new ConnectionStatusMessage(ConnectionStatus.Offline)); } }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override void OnLaunched(LaunchActivatedEventArgs e) { #if !DEBUG MobileCenter.Start("1fba816a-eea6-42a8-bf46-0c0fcc1589db", typeof(Analytics), typeof(Crashes)); #endif if (e.PreviousExecutionState != ApplicationExecutionState.Running) { var extendedSplash = new ExtendedSplashScreen(e.SplashScreen); Window.Current.Content = extendedSplash; } OverrideTitleBarColor(); // Ensure the current window is active Window.Current.Activate(); }
/// <summary> /// Chamado quando notificações são clicadas /// </summary> /// <param name="args"></param> protected override void OnActivated(IActivatedEventArgs args) { Frame rootFrame = Window.Current.Content as Frame; // Não repita a inicialização do aplicativo quando a Janela já tiver conteúdo, // apenas verifique se a janela está ativa if (rootFrame == null) { // Crie um Quadro para atuar como o contexto de navegação e navegue para a primeira página rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; if (args.PreviousExecutionState == ApplicationExecutionState.Terminated) { // TODO: Carregue o estado do aplicativo suspenso anteriormente } // Coloque o quadro na Janela atual Window.Current.Content = rootFrame; if (args.PreviousExecutionState != ApplicationExecutionState.Running) { bool loadState = (args.PreviousExecutionState == ApplicationExecutionState.Terminated); ExtendedSplashScreen extendedSplash = new ExtendedSplashScreen(args.SplashScreen, loadState); Window.Current.Content = extendedSplash; } } if (args is ToastNotificationActivatedEventArgs) { var toastActivationArgs = args as ToastNotificationActivatedEventArgs; // Parse the query string (using QueryString.NET) QueryString q = QueryString.Parse(toastActivationArgs.Argument); if (!q.Contains("action")) { return; } // See what action is being requested switch (q["action"]) { //case "acceptResponderRequest": // ResponderService.Service.AcceptRequest(q["conversationId"]); // //if (rootFrame.Content.GetType() == typeof(MainPage)) // //{ // // MainPage mp = rootFrame.Content as MainPage; // // mp.ViewModel.NavigationService.Navigate("Responder", q["conversationId"]); // //} // AnalyticsTracker.Send(HitBuilder.CreateCustomEvent("Responder Notification", "Accept").Build()); // break; //case "launchResponder": // if (rootFrame.Content.GetType() == typeof(MainPage)) // { // MainPage mp = rootFrame.Content as MainPage; // mp.ViewModel.NavigationService.Navigate("Responder", q["conversationId"]); // } // AnalyticsTracker.Send(HitBuilder.CreateCustomEvent("Responder Notification", "Launch").Build()); // break; } } }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </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; } #endif if (_bootStrapper == null) { // load bootstrapper here to avoid xaml parsing errors by retrieving ResWrapper from app resources _bootStrapper = new BootStrapper(); _vm = ServiceLocator.Current.GetInstance <OverviewViewModel>(); } 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(); rootFrame.NavigationFailed += OnNavigationFailed; 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) { var settingsVm = ServiceLocator.Current.GetInstance <SettingsViewModel>(); SettingsService.Instance.AppTheme = settingsVm.SettingsPartViewModel.UseLightThemeButton ? ApplicationTheme.Light : ApplicationTheme.Dark; // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter var extendedSplashScreen = new ExtendedSplashScreen(); rootFrame.Content = extendedSplashScreen; _navigationService = ServiceLocator.Current.GetInstance <Core.Services.INavigationService>(); _navigationService.Initialize(rootFrame); Window.Current.Activate(); await _vm.InitCommand.ExecuteAsync(); } // Ensure the current window is active Window.Current.Activate(); }
/// <summary> /// Wird aufgerufen, wenn die Anwendung durch den Endbenutzer normal gestartet wird. Weitere Einstiegspunkte /// werden verwendet, wenn die Anwendung zum Öffnen einer bestimmten Datei, zum Anzeigen /// von Suchergebnissen usw. gestartet wird. /// </summary> /// <param name="e">Details über Startanforderung und -prozess.</param> protected override void OnLaunched(LaunchActivatedEventArgs e) { #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { this.DebugSettings.EnableFrameRateCounter = true; } #endif #if WINDOWS_PHONE_APP if (e.PreviousExecutionState != ApplicationExecutionState.Running) { bool loadState = (e.PreviousExecutionState == ApplicationExecutionState.Terminated); var splash = new ExtendedSplashScreen(); Window.Current.Content = splash; Window.Current.Activate(); } #endif Frame rootFrame = Window.Current.Content as Frame; // App-Initialisierung nicht wiederholen, wenn das Fenster bereits Inhalte enthält. // Nur sicherstellen, dass das Fenster aktiv ist. if (rootFrame == null) { // Frame erstellen, der als Navigationskontext fungiert und zum Parameter der ersten Seite navigieren rootFrame = new Frame(); // TODO: diesen Wert auf eine Cachegröße ändern, die für Ihre Anwendung geeignet ist rootFrame.CacheSize = 1; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { // TODO: Zustand von zuvor angehaltener Anwendung laden } // Den Frame im aktuellen Fenster platzieren Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { #if WINDOWS_PHONE_APP // Entfernt die Drehkreuznavigation für den Start. 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; #endif // Wenn der Navigationsstapel nicht wiederhergestellt wird, zur ersten Seite navigieren // und die neue Seite konfigurieren, indem die erforderlichen Informationen als Navigationsparameter // übergeben werden #if WINDOWS_APP rootFrame.Navigate(typeof(TestPage), e.Arguments); return; #endif if (!rootFrame.Navigate(typeof(MainPage), e.Arguments)) { throw new Exception("Failed to create initial page"); } } // Sicherstellen, dass das aktuelle Fenster aktiv ist Window.Current.Activate(); }