private void UpgradeTile(Uri navigationUri) { if (_stopUpgrading) { return; } bool wasUpgraded = false; if (navigationUri == HomepageUri) { // The primary app tile. Easy. AppTileSettings.Instance.Tiles[navigationUri] = (new TileInformation { NavigationUri = navigationUri, Title = "4th & Mayor", BackgroundImage = new Uri("/4thBackground_173.png", UriKind.Relative) }) .TileSettingsInstance; AppTileSettings.Instance.Save(); } else if (navigationUri == CheckinPageUri) { var entry = standardShortcuts.Where(s => s.NavigationUri == navigationUri).SingleOrDefault(); if (entry != null) { AppTileSettings.Instance.Tiles[navigationUri] = entry.TileSettingsInstance; AppTileSettings.Instance.Save(); wasUpgraded = true; } } else { var a = navigationUri.ToString(); const string VenueStarts = "/Views/Venue.xaml?"; // PLACE. if (a.StartsWith(VenueStarts)) { string query = a.Replace(VenueStarts, string.Empty); if (query != null) { var queryString = new Dictionary <string, string>(); PhoneHyperlinkButton.ParseQueryStringToDictionary(query, queryString); UpgradePlace(navigationUri, queryString); } } } // A little recursive. if (wasUpgraded) { System.Diagnostics.Debug.WriteLine("An upgrade completed."); FindTiles(); } }
private void OnButtonClick(object sender, RoutedEventArgs e) { var abb = sender as ButtonBase; if (abb != null) { var dc = abb.DataContext; var tag = abb.Tag as string; var ti = dc as TileInformation; var ts = ti.TileSettingsInstance; if (ti != null) { switch (tag) { case "pin": if (ti.TileSettingsInstance.NavigationUri.ToString() == LeaderboardUri.ToString()) { MessageBox.Show("If you've enabled push notifications, the leaderboard will come alive in the next hour."); // TODO: Re-send all active URIs to the server. } AppTileManager.Instance.UpdateOrPin(ti.TileSettingsInstance); break; case "unpin": AppTileManager.Instance.Unpin(ti.TileSettingsInstance); FindTiles(); break; case "changeTitle": string title = ts.Title; Uri image = ts.FrontPhoto; NavigationService.Navigate(new Uri( string.Format( CultureInfo.InvariantCulture, "/JeffWilcox.FourthAndMayor.PushNotifications;component/RenameTile.xaml?title={0}&uri={1}&tileUri={2}", Uri.EscapeDataString(title ?? string.Empty), image == null ? string.Empty : Uri.EscapeDataString(image.ToString()), Uri.EscapeDataString(ts.NavigationUri.ToString()) ), UriKind.Relative)); break; case "changePicture": string mytitle = ts.Title; var qs = new Dictionary <string, string>(); PhoneHyperlinkButton.ParseUriToQueryStringDictionary(ts.NavigationUri, qs); string venueId; if (qs.TryGetValue("id", out venueId)) { NavigationService.Navigate(new Uri( string.Format( CultureInfo.InvariantCulture, "/JeffWilcox.FourthAndMayor.PushNotifications;component/VenuePhotoPicker.xaml?venueId={3}&title={0}&uri={1}", Uri.EscapeDataString(string.IsNullOrEmpty(mytitle) ? "place photo" : mytitle), Uri.EscapeDataString(ts.NavigationUri.ToString()), null, // image == null ? string.Empty : Uri.EscapeDataString(image.ToString()), venueId ), UriKind.Relative)); } break; default: break; } } } }