private async Task ActivateAsync(bool prelaunched) { // Do not repeat app initialization when the Window already has content if (Window.Current.Content is not Frame rootFrame) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; // Place the frame in the current Window Window.Current.Content = rootFrame; // Configure the services for later use _serviceProvider = ConfigureServices(); } if (prelaunched == false) { CoreApplication.EnablePrelaunch(true); // Navigate to the root page if one isn't loaded already if (rootFrame.Content is null) { rootFrame.Navigate(typeof(Views.MainPage)); } // Ensure the current window is active Window.Current.Activate(); } AppFrame = rootFrame; CustomizeTitleBar(rootFrame.ActualTheme == ElementTheme.Dark); await TryRegisterNotifications(); }
protected override void OnLaunched(LaunchActivatedEventArgs e) { // Do not repeat app initialization when the Window already has content if (!(Window.Current.Content is Frame rootFrame)) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; // Place the frame in the current Window Window.Current.Content = rootFrame; // Configure the services for later use _serviceProvider = ConfigureServices(); } if (!e.PrelaunchActivated) { CoreApplication.EnablePrelaunch(true); // Navigate to the root page if one isn't loaded already if (rootFrame.Content is null) { rootFrame.Navigate(typeof(Views.MainPage), e.Arguments); } // Ensure the current window is active Window.Current.Activate(); } CustomizeTitleBar(rootFrame.ActualTheme == ElementTheme.Dark); }
/// <inheritdoc/> protected override void OnLaunched(LaunchActivatedEventArgs e) { // Ensure the UI is initialized if (Window.Current.Content is null) { Window.Current.Content = new Shell(); TitleBarHelper.StyleTitleBar(); TitleBarHelper.ExpandViewIntoTitleBar(); // Register services Ioc.Default.ConfigureServices( new ServiceCollection() .AddSingleton <IFilesService, FilesService>() .AddSingleton <ISettingsService, SettingsService>() .AddSingleton(RestService.For <IRedditService>("https://www.reddit.com/")) .BuildServiceProvider()); } // Enable the prelaunch if needed, and activate the window if (e.PrelaunchActivated == false) { CoreApplication.EnablePrelaunch(true); Window.Current.Activate(); } }
/// <summary> /// 在应用程序由最终用户正常启动时进行调用。 /// 将在启动应用程序以打开特定文件等情况下使用。 /// </summary> /// <param name="e">有关启动请求和过程的详细信息。</param> protected override void OnLaunched(LaunchActivatedEventArgs e) { CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true; var viewTitleBar = ApplicationView.GetForCurrentView().TitleBar; viewTitleBar.ButtonBackgroundColor = Colors.Transparent; viewTitleBar.ButtonInactiveBackgroundColor = Colors.Transparent; viewTitleBar.ButtonForegroundColor = (Color)Resources["SystemBaseHighColor"]; if (!(Window.Current.Content is Frame) && !(Window.Current.Content is ExtendedSplash)) { if (e.PrelaunchActivated) { _ = new ExtendedSplash(e.SplashScreen, true); } else { if (!ApplicationData.Current.LocalSettings.Values.ContainsKey("EnablePreLaunch")) { CoreApplication.EnablePrelaunch(true); ApplicationData.Current.LocalSettings.Values["EnablePreLaunch"] = true; } ExtendedSplash extendedSplash = new ExtendedSplash(e.SplashScreen); Window.Current.Content = extendedSplash; } } Window.Current.Activate(); }
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> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { // Init settings. localSettings = ApplicationData.Current.LocalSettings; TaskScheduler.UnobservedTaskException += (object sender, UnobservedTaskExceptionEventArgs args) => { // If you see this message while testing the app and if the stack trace is SDK related, we might have a bug in the SDK as we don't want to leak any exception from the SDK. AppCenterLog.Error("AppCenterPuppet", "Unobserved exception observed=" + args.Observed, args.Exception); }; CoreApplication.EnablePrelaunch(true); InitializeComponent(); AppCenter.LogLevel = LogLevel.Verbose; AppCenter.SetLogUrl("https://in-integration.dev.avalanch.es"); // Set data from local storage. var countryCode = localSettings.Values[Constants.KeyCountryCode] as string; if (!string.IsNullOrEmpty(countryCode)) { AppCenter.SetCountryCode(countryCode); } var storageSize = localSettings.Values[Constants.KeyStorageMaxSize] as long?; if (storageSize != null && storageSize > 0) { AppCenter.SetMaxStorageSizeAsync((long)storageSize); } // User callbacks. Crashes.ShouldProcessErrorReport = (report) => { Log($"Determining whether to process error report with an ID: {report.Id}"); return(true); }; Crashes.GetErrorAttachments = GetErrorAttachmentsHandler; // Event handlers. Crashes.SendingErrorReport += (_, args) => Log($"Sending error report for an error ID: {args.Report.Id}"); Crashes.SentErrorReport += (_, args) => Log($"Sent error report for an error ID: {args.Report.Id}"); Crashes.FailedToSendErrorReport += (_, args) => Log($"Failed to send error report for an error ID: {args.Report.Id}"); // Start App Center. AppCenter.Start("2daf2955-b4e4-4206-b38a-fedcdc6f4f84", typeof(Analytics), typeof(Crashes)); // Set userId. var userId = localSettings.Values[Constants.KeyUserId] as string; if (!string.IsNullOrEmpty(userId)) { AppCenter.SetUserId(userId); } Crashes.HasCrashedInLastSessionAsync().ContinueWith(hasCrashed => { Log("Crashes.HasCrashedInLastSession=" + hasCrashed.Result); }); Crashes.GetLastSessionCrashReportAsync().ContinueWith(task => { Log("Crashes.LastSessionCrashReport.StackTrace=" + task.Result?.StackTrace); }); }
protected override void OnLaunched(LaunchActivatedEventArgs e) { // Ensure the UI is initialized if (!(Window.Current.Content is Frame rootFrame)) { rootFrame = new Frame(); rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0]; TitleBarHelper.StyleTitleBar(); TitleBarHelper.ExpandViewIntoTitleBar(); if (e.PreviousExecutionState != ApplicationExecutionState.Running) { bool loadState = (e.PreviousExecutionState == ApplicationExecutionState.Terminated); ExtendedSplash extendedSplash = new ExtendedSplash(e.SplashScreen, loadState); rootFrame.Content = extendedSplash; Window.Current.Content = rootFrame; } } // Enable the prelaunch if needed, and activate the window if (e.PrelaunchActivated == false) { CoreApplication.EnablePrelaunch(true); Window.Current.Activate(); } }
/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { CoreApplication.EnablePrelaunch(true); InitializeComponent(); Suspending += OnSuspending; AppCenter.LogLevel = LogLevel.Verbose; AppCenter.Start("e8354a9a-001a-4728-be65-a6477e57f2e7", typeof(Analytics), typeof(Crashes), typeof(Push)); Push.SetEnabledAsync(true); Push.PushNotificationReceived += PushNotificationReceivedHandler; }
/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { CoreApplication.EnablePrelaunch(true); InitializeComponent(); Suspending += OnSuspending; MobileCenter.LogLevel = LogLevel.Verbose; MobileCenter.SetLogUrl("https://in-integration.dev.avalanch.es"); MobileCenter.Start("42f4a839-c54c-44da-8072-a2f2a61751b2", typeof(Analytics), typeof(Crashes), typeof(Push)); Push.SetEnabledAsync(true); Push.PushNotificationReceived += PushNotificationReceivedHandler; }
/// <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 //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(); rootFrame.NavigationFailed += OnNavigationFailed; 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 (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 rootFrame.Navigate(typeof(MainPage), e.Arguments); // Ensure the current window is active ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size(150, 150)); Window.Current.Activate(); // プレランチを「申請」します CoreApplication.EnablePrelaunch(true); } else { // 現在のウィンドウがアクティブであることを確認します Window.Current.Activate(); } } }
/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { this.InitializeComponent(); CoreApplication.EnablePrelaunch(true); InitializeTheme(); BLogger.InitLogger(); this.Suspending += OnSuspending; this.EnteredBackground += App_EnteredBackground; this.LeavingBackground += App_LeavingBackground; this.UnhandledException += App_UnhandledException; TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException; }
/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { TaskScheduler.UnobservedTaskException += (object sender, UnobservedTaskExceptionEventArgs args) => { // If you see this message while testing the app and if the stack trace is SDK related, we might have a bug in the SDK as we don't want to leak any exception from the SDK. AppCenterLog.Error("AppCenterDemo", "Unobserved exception observed=" + args.Observed, args.Exception); }; CoreApplication.EnablePrelaunch(true); InitializeComponent(); Suspending += OnSuspending; AppCenter.LogLevel = LogLevel.Verbose; AppCenter.Start("e8354a9a-001a-4728-be65-a6477e57f2e7", typeof(Analytics), typeof(Crashes)); }
/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { InitializeComponent(); CoreApplication.EnablePrelaunch(true); InitializeTheme(); BLogger.InitLogger(); BLogger.Logger.Info("Logger initialized. Progressing in app constructor."); Suspending += OnSuspending; EnteredBackground += App_EnteredBackground; LeavingBackground += App_LeavingBackground; UnhandledException += App_UnhandledException; TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException; BLogger.Logger.Info("Events initialized. Progressing in app constructor."); }
/// <summary> /// 単一アプリケーション オブジェクトを初期化します。これは、実行される作成したコードの ///最初の行であるため、main() または WinMain() と論理的に等価です。 /// </summary> public App() { // 事前起動有効化 CoreApplication.EnablePrelaunch(true); // Debug.WriteLine("App.ctor()"); this.InitializeComponent(); this.EnteredBackground += App_EnteredBackground; this.LeavingBackground += App_LeavingBackground; this.Resuming += App_Resuming; this.Suspending += App_Suspending; this.UnhandledException += App_UnhandledException; WindowPresenter = new WindowPresenter(); }
/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { this.InitializeComponent(); CoreApplication.EnablePrelaunch(true); var value = ApplicationData.Current.LocalSettings.Values["SelectedTheme"]; if (value != null) { var theme = Enum.Parse(typeof(ApplicationTheme), value.ToString()); this.RequestedTheme = (ApplicationTheme)theme; Debug.Write("ApplicationTheme: " + RequestedTheme.ToString()); } this.Suspending += OnSuspending; this.EnteredBackground += App_EnteredBackground; this.LeavingBackground += App_LeavingBackground; }
private async void InitializeEverything() { if ((await StorageLibrary.GetLibraryAsync(KnownLibraryId.Music))?.SaveFolder != null) { var logPath = System.IO.Path.Combine((await StorageLibrary.GetLibraryAsync(KnownLibraryId.Music))?.SaveFolder?.Path, ".breadplayerLogs", "BreadPlayer.log"); BLogger.InitLogger(logPath, new Helpers.LogReportSender()); CoreApplication.EnablePrelaunch(true); Suspending += OnSuspending; EnteredBackground += App_EnteredBackground; LeavingBackground += App_LeavingBackground; UnhandledException += App_UnhandledException; TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException; BLogger.I("App started."); BLogger.I("Events initialized."); } }
/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { TaskScheduler.UnobservedTaskException += (object sender, UnobservedTaskExceptionEventArgs args) => { // If you see this message while testing the app and if the stack trace is SDK related, we might have a bug in the SDK as we don't want to leak any exception from the SDK. AppCenterLog.Error("AppCenterPuppet", "Unobserved exception observed=" + args.Observed, args.Exception); }; CoreApplication.EnablePrelaunch(true); InitializeComponent(); Suspending += OnSuspending; AppCenter.LogLevel = LogLevel.Verbose; AppCenter.SetLogUrl("https://in-integration.dev.avalanch.es"); AppCenter.Start("42f4a839-c54c-44da-8072-a2f2a61751b2", typeof(Analytics), typeof(Crashes), typeof(Push)); Push.SetEnabledAsync(true); Push.PushNotificationReceived += PushNotificationReceivedHandler; }
protected override void OnLaunched(LaunchActivatedEventArgs e) { if (Window.Current.Content is null) { Ioc.Default.ConfigureServices(ConfigureServices()); Window.Current.Content = new Shell(); ThemeHelper.Initialize(); } if (e.PrelaunchActivated == false) { CoreApplication.EnablePrelaunch(true); Window.Current.Activate(); } }
/// <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 async void OnLaunched(LaunchActivatedEventArgs e) { Root root = Window.Current.Content as Root; if (root == null) { var CoreView = CoreApplication.GetCurrentView(); var AppView = ApplicationView.GetForCurrentView(); var coreTitleBar = CoreView.TitleBar; coreTitleBar.ExtendViewIntoTitleBar = true; var titleBar = AppView.TitleBar; titleBar.ButtonBackgroundColor = Colors.Transparent; titleBar.ButtonInactiveBackgroundColor = Colors.Transparent; root = new Root(); root.ChangeTheme(Settings.Theme); root.UpdateThemeColors(); (Service.Platform as UWPlatformService).SetRoot(root); /*if (ApiInformation.IsApiContractPresent("Windows.Foundation.UniversalApiContract", 13)) * this.Resources["SymbolThemeFontFamily"] = new FontFamily("Segoe Fluent Icons");*/ ((SolidColorBrush)this.Resources["CustomReaderBackground"]).Color = ColorHelper.ToColor(Settings.ReaderBackground); if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } Window.Current.Content = root; } if (!e.PrelaunchActivated) { CoreApplication.EnablePrelaunch(true); if (root.FrameContent.Content == null) { Service.Platform.GoToPage(Pages.Loading, PagesTransition.None, e.SplashScreen); } Window.Current.Activate(); } else { await InitServices(); } }
/// <summary> /// アプリケーションがエンド ユーザーによって正常に起動されたときに呼び出されます。他のエントリ ポイントは、 /// アプリケーションが特定のファイルを開くために起動されたときなどに使用されます。 /// </summary> /// <param name="e">起動の要求とプロセスの詳細を表示します。</param> protected override void OnLaunched(LaunchActivatedEventArgs e) { Frame rootFrame = Window.Current.Content as Frame; // ウィンドウに既にコンテンツが表示されている場合は、アプリケーションの初期化を繰り返さずに、 // ウィンドウがアクティブであることだけを確認してください if (rootFrame == null) { // ナビゲーション コンテキストとして動作するフレームを作成し、最初のページに移動します rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: 以前中断したアプリケーションから状態を読み込みます } // フレームを現在のウィンドウに配置します Window.Current.Content = rootFrame; } if (e.PrelaunchActivated == false) { if (rootFrame.Content == null) { // ナビゲーション スタックが復元されない場合は、最初のページに移動します。 // このとき、必要な情報をナビゲーション パラメーターとして渡して、新しいページを //構成します rootFrame.Navigate(typeof(MainPage), e.Arguments); // Mobile以外では、最小サイズを設定します bool IsMobile = (AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Mobile"); if (!IsMobile) { ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size(500, 300)); // 最大500まで } // プレランチを「申請」します CoreApplication.EnablePrelaunch(true); } // 現在のウィンドウがアクティブであることを確認します Window.Current.Activate(); } }
/// <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) { 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; 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 (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 rootFrame.Navigate(typeof(MainPage), e.Arguments); } // Ensure the current window is active Window.Current.Activate(); // プレランチを「申請」します if (Windows.Foundation.Metadata.ApiInformation // ← .IsMethodPresent( // ← "Windows.ApplicationModel.Core.CoreApplication", // ← "EnablePrelaunch")) // ← { CoreApplication.EnablePrelaunch(true); // ← } }// ← }
/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { TaskScheduler.UnobservedTaskException += (object sender, UnobservedTaskExceptionEventArgs args) => { // If you see this message while testing the app and if the stack trace is SDK related, we might have a bug in the SDK as we don't want to leak any exception from the SDK. AppCenterLog.Error("AppCenterDemo", "Unobserved exception observed=" + args.Observed, args.Exception); }; CoreApplication.EnablePrelaunch(true); InitializeComponent(); Suspending += OnSuspending; AppCenter.LogLevel = LogLevel.Verbose; object storageSize; if (Windows.Storage.ApplicationData.Current.LocalSettings.Values.TryGetValue("StorageMaxSize", out storageSize)) { AppCenter.SetMaxStorageSizeAsync((long)storageSize); } AppCenter.Start("e8354a9a-001a-4728-be65-a6477e57f2e7", typeof(Analytics), typeof(Crashes)); }
private async Task ActivateAsync(bool prelaunched, IAppSettings?appsettings = null) { // Do not repeat app initialization when the Window already has content if (Window.Current.Content is not Frame rootFrame) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; // Place the frame in the current Window Window.Current.Content = rootFrame; // Configure the services for later use _serviceProvider = ConfigureServices(appsettings); rootFrame.ActualThemeChanged += OnActualThemeChanged; _userSettings = Services.GetRequiredService <IUserSettings>(); _userSettings.SettingSet += OnSettingSet; } if (prelaunched == false) { CoreApplication.EnablePrelaunch(true); // Navigate to the root page if one isn't loaded already if (rootFrame.Content is null) { rootFrame.Navigate(typeof(Views.ShellPage)); } SetMinSize(); Window.Current.Activate(); } AppFrame = rootFrame; SetAppRequestedTheme(); Services.GetRequiredService <INavigator>().RootFrame = rootFrame; CustomizeTitleBar(rootFrame.ActualTheme == ElementTheme.Dark); await TryRegisterNotifications(); await BackgroundDownloadService.Instance.DiscoverActiveDownloadsAsync(); }
/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { TaskScheduler.UnobservedTaskException += (object sender, UnobservedTaskExceptionEventArgs args) => { // If you see this message while testing the app and if the stack trace is SDK related, we might have a bug in the SDK as we don't want to leak any exception from the SDK. AppCenterLog.Error("AppCenterPuppet", "Unobserved exception observed=" + args.Observed, args.Exception); }; CoreApplication.EnablePrelaunch(true); InitializeComponent(); Suspending += OnSuspending; AppCenter.LogLevel = LogLevel.Verbose; AppCenter.SetLogUrl("https://in-integration.dev.avalanch.es"); object storageSize; if (Windows.Storage.ApplicationData.Current.LocalSettings.Values.TryGetValue("StorageMaxSize", out storageSize)) { AppCenter.SetMaxStorageSizeAsync((long)storageSize); } AppCenter.Start("42f4a839-c54c-44da-8072-a2f2a61751b2", typeof(Analytics), typeof(Crashes)); }
protected sealed override async void OnLaunched(LaunchActivatedEventArgs args) { LastActivationArgs = args; CurrentUser = args.User; DeviceInformation.RefreshSubplatform(args); if (args.PreviousExecutionState != ApplicationExecutionState.Running && args.PreviousExecutionState != ApplicationExecutionState.Suspended && args.TileId == "App") { await InitializeRootFrameAsync(args); if (Options.HandlePrelaunch) { CoreApplication.EnablePrelaunch(true); } if (args.PreviousExecutionState != ApplicationExecutionState.Terminated || (args.PreviousExecutionState == ApplicationExecutionState.Terminated && !IsRestored)) { if (Options.HandlePrelaunch && args.PrelaunchActivated) { await OnPrelaunchAsync(args); Window.Current.Activate(); await WaitForPrelaunchVisibilityChangeAsync(); await OnFreshLaunchAsync(args); } else { await AsyncWindowActivate(OnFreshLaunchAsync(args)); } } else { Window.Current.Activate(); } } else { OnActivated(args); } }
/// <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) { SystemInformation.Instance.TrackAppUse(e); // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (Window.Current.Content is not Frame rootFrame) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); rootFrame.CacheSize = 1; 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 (e.PrelaunchActivated == false) { CoreApplication.EnablePrelaunch(true); 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, new SuppressNavigationTransitionInfo()); } // Ensure the current window is active Window.Current.Activate(); } }
/// <summary> /// アプリケーションがエンド ユーザーによって正常に起動されたときに呼び出されます。他のエントリ ポイントは、 /// アプリケーションが特定のファイルを開くために起動されたときなどに使用されます。 /// </summary> /// <param name="e">起動の要求とプロセスの詳細を表示します。</param> protected override void OnLaunched(LaunchActivatedEventArgs e) { Frame rootFrame = Window.Current.Content as Frame; // ウィンドウに既にコンテンツが表示されている場合は、アプリケーションの初期化を繰り返さずに、 // ウィンドウがアクティブであることだけを確認してください if (rootFrame == null) { // ナビゲーション コンテキストとして動作するフレームを作成し、最初のページに移動します rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: 以前中断したアプリケーションから状態を読み込みます } // フレームを現在のウィンドウに配置します Window.Current.Content = rootFrame; } if (e.PrelaunchActivated == false) { if (rootFrame.Content == null) { // ナビゲーション スタックが復元されない場合は、最初のページに移動します。 // このとき、必要な情報をナビゲーション パラメーターとして渡して、新しいページを //構成します rootFrame.Navigate(typeof(MainPage), e.Arguments); // プレランチを「申請」します CoreApplication.EnablePrelaunch(true); } // 現在のウィンドウがアクティブであることを確認します Window.Current.Activate(); } }
public App() { //Set app language //Try getting setting Windows.Storage.ApplicationData.Current.LocalSettings.Values.TryGetValue("AppLanguage", out var language); if (null != language) { Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = string.IsNullOrEmpty(language.ToString()) ? "" : language.ToString(); } CoreApplication.EnablePrelaunch(true); this.FocusVisualKind = FocusVisualKind.Reveal; var loc = new ViewModelLocator(); this.InitializeComponent(); this.UnhandledException += OnUnhandledException; _activationService = new Lazy <ActivationService>(CreateActivationService); Current = this; DirectText.RegisterDependencyProperties(); }
/// <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) { // Ensure the UI is initialized if (Window.Current.Content is null) { // Register services. Ioc.Default.ConfigureServices(ConfigureServices()); InitializeSettings(); Window.Current.Content = new MainPage(); TitleBarHelper.StyleTitleBar(); TitleBarHelper.ExpandViewIntoTitleBar(); } // Enable the prelaunch if needed, and activate the window if (e.PrelaunchActivated == false) { CoreApplication.EnablePrelaunch(true); Window.Current.Activate(); } }
private void TryEnablePrelaunch() { CoreApplication.EnablePrelaunch(true); }