/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used when the application is launched to open a specific file, to display /// search results, and so forth. /// </summary> /// <param name="args">Details about the launch request and process.</param> protected override async void OnLaunched(LaunchActivatedEventArgs args) { if (Window.Current.Content == null) { Frame rootFrame = await InitializeFrameAsync(args); Shell = CreateShell(rootFrame); if (Shell != null) { Window.Current.Content = Shell; } else { Window.Current.Content = rootFrame; } } // If the app is launched via the app's primary tile, the args.TileId property // will have the same value as the AppUserModelId, which is set in the Package.appxmanifest. // See http://go.microsoft.com/fwlink/?LinkID=288842 string tileId = AppManifestHelper.GetApplicationId(); if (Window.Current.Content != null && (!_isRestoringFromTermination || (args != null && args.TileId != tileId))) { await OnLaunchApplicationAsync(args); } // Ensure the current window is active Window.Current.Activate(); }
/// <summary> /// Show a settings flyout using the Callisto toolkit (http://callistotoolkit.com/) /// </summary> /// <param name="title">Name of flyout</param> /// <param name="content">UserControl containing the content to be displayed in the flyout</param> /// <param name="width">Flyout width (narrow or wide)</param> private async void ShowFlyout(string title, Windows.UI.Xaml.Controls.UserControl content, SettingsFlyout.SettingsFlyoutWidth width = SettingsFlyout.SettingsFlyoutWidth.Narrow) { // grab app theme color from resources (optional) SolidColorBrush color = null; if (App.Current.Resources.Keys.Contains("AppThemeBrush")) { color = App.Current.Resources["AppThemeBrush"] as SolidColorBrush; } // create the flyout var flyout = new SettingsFlyout(); if (color != null) { flyout.HeaderBrush = color; } flyout.HeaderText = title; flyout.FlyoutWidth = width; // access the small logo from the manifest flyout.SmallLogoImageSource = new BitmapImage((await AppManifestHelper.GetManifestVisualElementsAsync()).SmallLogoUri); // assign content and show flyout.Content = content; flyout.IsOpen = true; }
/* * protected async override void OnLaunched(LaunchActivatedEventArgs args) * { * try * { * * var rootFrame = await InitializeFrameAsync(args); * * string tileId = AppManifestHelper.GetApplicationId(); * * if (rootFrame != null) * { * await OnLaunchApplicationAsync(args); * } * * // Ensure the current window is active * //Window.Current.Activate(); * * //base.OnLaunched(args); * } * catch (Exception ex) * { * string message = ex.Message; * } * } */ protected async override void OnActivated(IActivatedEventArgs args) { try { var rootFrame = await InitializeFrameAsync(args); string tileId = AppManifestHelper.GetApplicationId(); if (rootFrame != null) { ProtocolActivatedEventArgs activatedargs = (ProtocolActivatedEventArgs)args; if (args.PreviousExecutionState != ApplicationExecutionState.Running) { await this.LoadAppResources(); } NavigationService.Navigate("Main", null); } //base.OnActivated(args); } catch (Exception ex) { string message = ex.Message; } }
private async void Configure() { _visualElement = await AppManifestHelper.GetManifestVisualElementsAsync(); _headerBrush = new SolidColorBrush(_visualElement.BackgroundColor); _smallLogoImageSource = new BitmapImage(_visualElement.SmallLogoUri); SettingsPane.GetForCurrentView().CommandsRequested += Current.CommandsRequested; }
private async void Configure() { appSettings = SettingsPane.GetForCurrentView(); _visualElement = await AppManifestHelper.GetManifestVisualElementsAsync(); _smallLogoImageSource = new BitmapImage(_visualElement.SmallLogoUri); appSettings.CommandsRequested -= Current.CommandsRequested; appSettings.CommandsRequested += Current.CommandsRequested; //SettingsPane.GetForCurrentView().CommandsRequested += Current.CommandsRequested; }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used when the application is launched to open a specific file, to display /// search results, and so forth. /// </summary> /// <param name="args">Details about the launch request and process.</param> protected async override void OnLaunched(LaunchActivatedEventArgs args) { AppSettings.Current.AddCommand <SettingsContent>("第一项", new SolidColorBrush(Colors.Red), new SolidColorBrush(Colors.Gray), new SolidColorBrush(Colors.Blue), SettingsFlyout.SettingsFlyoutWidth.Wide); AppSettings.Current.AddCommand <SettingsContent>("第二项", SettingsFlyout.SettingsFlyoutWidth.Wide); AppSettings.Current.AddCommand <SettingsContent>("第五项", new SolidColorBrush(Colors.Green), SettingsFlyout.SettingsFlyoutWidth.Wide); //AppSettings.Current.ResetConfigureSettings(); //测试放在一起一个时机 SystemSettingHelper.Instance.Init(); VisualElements = await AppManifestHelper.GetManifestVisualElementsAsync(); // Do not repeat app initialization when already running, just ensure that // the window is active if (args.PreviousExecutionState == ApplicationExecutionState.Running) { Window.Current.Activate(); return; } if (args.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } //添加注册后台任务,更新主屏Tile var localsettings = ApplicationData.Current.LocalSettings; var tile = new NotificationTileUpdateTaskRegistration(); tile.CreateTileUpdateTasks(localsettings.CreateContainer(NotificationTileConstants.TaskSettingsContainer, ApplicationDataCreateDisposition.Always)); // Create a Frame to act navigation context and navigate to the first page var rootFrame = new Frame(); if (!rootFrame.Navigate(typeof(BlankPage))) { throw new Exception("Failed to create initial page"); } // Place the frame in the current Window and ensure that it is active Window.Current.Content = rootFrame; Window.Current.Activate(); }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used when the application is launched to open a specific file, to display /// search results, and so forth. /// </summary> /// <param name="args">Details about the launch request and process.</param> protected override async void OnLaunched(LaunchActivatedEventArgs args) { // get the name of the app from the mainfest DisplayName = (await AppManifestHelper.GetManifestVisualElementsAsync()).DisplayName; // provide types used in page state to the SuspensionManager SuspensionManager.KnownTypes.Add(typeof(BoundingBox)); SuspensionManager.KnownTypes.Add(typeof(LatLong)); SuspensionManager.KnownTypes.Add(typeof(MainPage.MainPageState)); 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(); SuspensionManager.RegisterFrame(rootFrame, "appFrame"); if (args.PreviousExecutionState == ApplicationExecutionState.Terminated) { await SuspensionManager.RestoreAsync(); } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter if (!rootFrame.Navigate(typeof(MainPage), args.Arguments)) { throw new Exception("Failed to create initial page"); } } // Ensure the current window is active Window.Current.Activate(); }
/// <summary> /// Invoked when the application is activated to display search results. /// </summary> /// <param name="args">Details about the activation request.</param> protected async override void OnSearchActivated(Windows.ApplicationModel.Activation.SearchActivatedEventArgs args) { // get the name of the app from the mainfest DisplayName = (await AppManifestHelper.GetManifestVisualElementsAsync()).DisplayName; // If the Window isn't already using Frame navigation, insert our own Frame var previousContent = Window.Current.Content; var frame = previousContent as Frame; // If the app does not contain a top-level frame, it is possible that this // is the initial launch of the app. Typically this method and OnLaunched // in App.xaml.cs can call a common method. if (frame == null) { // Create a Frame to act as the navigation context and associate it with // a SuspensionManager key frame = new Frame(); SuspensionManager.RegisterFrame(frame, "AppFrame"); if (args.PreviousExecutionState == ApplicationExecutionState.Terminated) { // Restore the saved session state only when appropriate try { await SuspensionManager.RestoreAsync(); } catch (SuspensionManagerException) { //Something went wrong restoring state. //Assume there is no state and continue } } } frame.Navigate(typeof(LocationSearchResultsPage), args.QueryText); Window.Current.Content = frame; // Ensure the current window is active Window.Current.Activate(); }