/// <summary> /// Determines how best to support navigation back to the previous application state. /// </summary> public static void Activate(SearchActivatedEventArgs args) { var previousContent = Window.Current.Content; var frame = previousContent as Frame; if (frame != null) { // If the app is already running and uses top-level frame navigation we can just // navigate to the search results frame.Navigate(typeof(SearchResultsPage), args.QueryText); } else { // Otherwise bypass navigation and provide the tools needed to emulate the back stack var page = new SearchResultsPage { _previousContent = previousContent }; page.LoadState(args.QueryText, null); Window.Current.Content = page; } // Either way, active the window Window.Current.Activate(); App.Instance.Share = null; }
/// <summary> /// Invoked when the application is activated to display search results. /// </summary> /// <param name="args">Details about the activation request.</param> protected override void OnSearchActivated(SearchActivatedEventArgs args) { if (Extended) { SearchResultsPage.Activate(args); } else { ExtendedSplash(args.SplashScreen, args); } RegisterSettings(); }
private async void ExtendedSplashScreen_Loaded(object sender, RoutedEventArgs e) { ProgressText.Text = ApplicationData.Current.LocalSettings.Values.ContainsKey("Initialized") && (bool)ApplicationData.Current.LocalSettings.Values["Initialized"] ? "Loading blogs..." : "Initializing for first use: this may take several minutes..."; await App.Instance.DataSource.LoadGroups(); foreach (var group in App.Instance.DataSource.GroupList) { Progress.IsActive = true; ProgressText.Text = "Loading " + group.Title; await App.Instance.DataSource.LoadAllItems(group); } ApplicationData.Current.LocalSettings.Values["Initialized"] = true; // Create a Frame to act as the navigation context and associate it with // a SuspensionManager key var rootFrame = new Frame(); SuspensionManager.RegisterFrame(rootFrame, "AppFrame"); var list = App.Instance.DataSource.GroupList; var totalNew = list.Sum(g => g.NewItemCount); if (totalNew > 99) { totalNew = 99; } if (totalNew > 0) { var badgeContent = new BadgeNumericNotificationContent((uint)totalNew); BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeContent.CreateNotification()); } else { BadgeUpdateManager.CreateBadgeUpdaterForApplication().Clear(); } // load most recent 5 items then order from oldest to newest var query = from i in (from g in list from i in g.Items orderby i.PostDate descending select i).Take(5) orderby i.PostDate select i; var x = 0; TileUpdateManager.CreateTileUpdaterForApplication().Clear(); TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true); foreach (var item in query) { var squareTile = new TileSquarePeekImageAndText04(); squareTile.TextBodyWrap.Text = item.Title; squareTile.Image.Alt = item.Title; squareTile.Image.Src = item.DefaultImageUri.ToString(); var wideTile = new TileWideSmallImageAndText03 { SquareContent = squareTile }; wideTile.Image.Alt = item.Title; wideTile.Image.Src = item.DefaultImageUri.ToString(); wideTile.TextBodyWrap.Text = item.Title; var notification = wideTile.CreateNotification(); notification.Tag = string.Format("Item {0}", x++); TileUpdateManager.CreateTileUpdaterForApplication().Update(notification); } Windows.ApplicationModel.Search.SearchPane.GetForCurrentView().SuggestionsRequested += SplashPage_SuggestionsRequested; App.Instance.Extended = true; if (_searchArgs != null) { SearchResultsPage.Activate(_searchArgs); return; } if (_activationArgs != null) { if (_activationArgs.Arguments.StartsWith("Group")) { var group = _activationArgs.Arguments.Split('='); rootFrame.Navigate(typeof(GroupDetailPage), group[1]); } else if (_activationArgs.Arguments.StartsWith("Item")) { var item = _activationArgs.Arguments.Split('='); rootFrame.Navigate(typeof(ItemDetailPage), item[1]); } else if (_activationArgs.PreviousExecutionState == ApplicationExecutionState.Terminated) { // Restore the saved session state only when appropriate await SuspensionManager.RestoreAsync(); } } 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(GroupedItemsPage), "AllGroups")) { 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(); }