/// <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; if (AppUtils.IsXbox) { ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow); ApplicationViewScaling.TrySetDisableLayoutScaling(true); } else { ApplicationViewTitleBar formattableTitleBar = ApplicationView.GetForCurrentView().TitleBar; formattableTitleBar.ButtonBackgroundColor = Color.FromArgb(255, 32, 32, 32); formattableTitleBar.ButtonForegroundColor = Color.FromArgb(255, 160, 160, 160); formattableTitleBar.ButtonInactiveBackgroundColor = Colors.Transparent; formattableTitleBar.BackgroundColor = Color.FromArgb(255, 32, 32, 32); } 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) { IUnityContainer container = Globals.Instance.Container; ISettingsService settingsService = container.Resolve <ISettingsService>(); Globals.Instance.LoadSettings(settingsService); Type toNavigate; if (string.IsNullOrEmpty(Globals.Instance.AccessToken)) { toNavigate = typeof(LoginView); } else { toNavigate = typeof(MainWindowView); } rootFrame.Navigate(toNavigate, e.Arguments); } // 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() { InitializeComponent(); Suspending += OnSuspending; // Opt out of mouse mode RequiresPointerMode = ApplicationRequiresPointerMode.WhenRequested; // Opt out of effective pixel scaling ApplicationViewScaling.TrySetDisableLayoutScaling(true); }
/// <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; if (AppUtils.IsXbox) { ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow); ApplicationViewScaling.TrySetDisableLayoutScaling(true); } else { ApplicationViewTitleBar formattableTitleBar = ApplicationView.GetForCurrentView().TitleBar; formattableTitleBar.ButtonBackgroundColor = Color.FromArgb(255, 32, 32, 32); formattableTitleBar.ButtonForegroundColor = Color.FromArgb(255, 160, 160, 160); formattableTitleBar.ButtonInactiveBackgroundColor = Colors.Transparent; formattableTitleBar.BackgroundColor = Color.FromArgb(255, 32, 32, 32); } 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 if (Core.Central.Settings.HasJellyfinServer) { rootFrame.Navigate(typeof(MainPage), e.Arguments); } else { rootFrame.Navigate(typeof(Views.OnBoarding), e.Arguments); } } // Ensure the current window is active Window.Current.Activate(); } }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used 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; 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(); } //https://docs.microsoft.com/zh-cn/windows/uwp/xbox-apps/tailoring-for-xbox //Full Screen Mode var view = ApplicationView.GetForCurrentView(); view.TryEnterFullScreenMode(); //Reveal focus gives users a better understanding of where focus is and where focus is going. this.FocusVisualKind = FocusVisualKind.Reveal; //Disable Xbox 200% scale var result = ApplicationViewScaling.TrySetDisableLayoutScaling(true); //Remove Xbox TV safe areas ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow); }
/// <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() { // Allow the application to take advantage of all the pixels. ApplicationViewScaling.TrySetDisableLayoutScaling(true); _appUpdater = new AppUpdater(); this.InitializeComponent(); this.Suspending += OnSuspending; // Xbox One best practices. // <see cref="https://docs.microsoft.com/en-us/windows/uwp/xbox-apps/tailoring-for-xbox"/> this.RequiresPointerMode = ApplicationRequiresPointerMode.WhenRequested; }
/// <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(); this.Suspending += OnSuspending; ApplicationViewScaling.TrySetDisableLayoutScaling(true); switch (AnalyticsInfo.VersionInfo.DeviceFamily) { case "Windows.Xbox": case "Windows.Desktop": this.RequiresPointerMode = ApplicationRequiresPointerMode.WhenRequested; 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="args">Details about the launch request and process.</param> protected override async void OnLaunched(LaunchActivatedEventArgs args) { // XBOX support if (AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Xbox") { ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow); bool result = ApplicationViewScaling.TrySetDisableLayoutScaling(true); } await InitializeAsync(); InitWindow(skipWindowCreation: args.PrelaunchActivated); // Tasks after activation await StartupAsync(); }
protected override async void OnLaunched(LaunchActivatedEventArgs args) { //var view = ApplicationView.GetForCurrentView(); //view.TryEnterFullScreenMode(); //Disable Xbox 200% scale var result = ApplicationViewScaling.TrySetDisableLayoutScaling(true); //Remove Xbox TV safe areas ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow); if (!args.PrelaunchActivated) { await ActivationService.ActivateAsync(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="args">Details about the launch request and process.</param> protected async override void OnLaunched(LaunchActivatedEventArgs args) { // XBOX support if (AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Xbox") { ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow); bool result = ApplicationViewScaling.TrySetDisableLayoutScaling(true); } await InitializeAsync(); InitWindow(skipWindowCreation: args.PrelaunchActivated); // Tasks after activation await StartupAsync(); await Window.Current.Dispatcher.RunIdleAsync(async (s) => await BackgroundDownloadHelper.AttachToDownloads()); }
private void SettingsForXbox() { //https://docs.microsoft.com/zh-cn/windows/uwp/xbox-apps/tailoring-for-xbox //Full Screen Mode var view = ApplicationView.GetForCurrentView(); view.TryEnterFullScreenMode(); //Reveal focus gives users a better understanding of where focus is and where focus is going. this.FocusVisualKind = FocusVisualKind.Reveal; //Disable Xbox 200% scale var result = ApplicationViewScaling.TrySetDisableLayoutScaling(true); //Remove Xbox TV safe areas ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow); //Use TV colorsafe values this.Resources.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri("ms-appx:///Styles/TvSafeColors.xaml") }); }
private void SetupCinematic() { ApplicationViewScaling.TrySetDisableLayoutScaling(false); ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow); }
public void Initialize(CoreApplicationView applicationView) { applicationView.Activated += (sender, args) => CoreWindow.GetForCurrentThread().Activate(); ApplicationViewScaling.TrySetDisableLayoutScaling(true); }
private void OnLaunchedOrActivated(IActivatedEventArgs e) { try { 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) { SYEngine.Core.Initialize(); // 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; } BackgroundTaskHelper.Register("ToastBackgroundTask", new ToastNotificationActionTrigger()); if (e is LaunchActivatedEventArgs && (e as LaunchActivatedEventArgs).PrelaunchActivated == false) { if (rootFrame.Content == null) { string display = AppTool.GetLocalSetting(Settings.DisplayMode, ""); if (string.IsNullOrEmpty(display)) { rootFrame.Navigate(typeof(WelcomePage), (e as LaunchActivatedEventArgs).Arguments); } else { if (_isTabletMode) { rootFrame.Navigate(typeof(TabletMainPage), (e as LaunchActivatedEventArgs).Arguments); } else { rootFrame.Navigate(typeof(DesktopMainPage), (e as LaunchActivatedEventArgs).Arguments); } } } // Ensure the current window is active } else if (e.Kind == ActivationKind.StartupTask) { if (rootFrame.Content == null) { if (_isTabletMode) { rootFrame.Navigate(typeof(TabletMainPage), null); } else { rootFrame.Navigate(typeof(DesktopMainPage), null); } } } else if (e is ToastNotificationActivatedEventArgs toastActivationArgs) { if (rootFrame.Content == null) { if (_isTabletMode) { rootFrame.Navigate(typeof(TabletMainPage), toastActivationArgs.Argument); } else { rootFrame.Navigate(typeof(DesktopMainPage), toastActivationArgs.Argument); } } else { AppViewModel.AppInitByActivated(toastActivationArgs.Argument); } } else if (e is ProtocolActivatedEventArgs protocalArgs) { string arg = protocalArgs.Uri.Query.Replace("?", ""); if (rootFrame.Content == null) { if (_isTabletMode) { rootFrame.Navigate(typeof(TabletMainPage), arg); } else { rootFrame.Navigate(typeof(DesktopMainPage), arg); } } else { AppViewModel.AppInitByActivated(arg); } } Window.Current.Activate(); UIHelper.SetTitleBarColor(); bool isDisableScale = AppTool.GetBoolSetting(Settings.DisableXboxScale); if (SystemInformation.DeviceFamily == "Windows.Xbox") { var view = ApplicationView.GetForCurrentView(); view.SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow); if (isDisableScale) { ApplicationViewScaling.TrySetDisableLayoutScaling(true); } } } catch (Exception ex) { _logger.Error("启动出错", ex); } }