private async void CreateBadgeTile_Click(object sender, RoutedEventArgs e) { if (!SecondaryTile.Exists(BADGE_TILE_ID)) { SecondaryTile secondTile = new SecondaryTile( BADGE_TILE_ID, "LockScreen CS - Badge only", "BADGE_ARGS", new Uri("ms-appx:///images/squareTile-sdk.png"), TileSize.Square150x150 ); secondTile.LockScreenBadgeLogo = new Uri("ms-appx:///images/badgelogo-sdk.png"); bool isPinned = await secondTile.RequestCreateForSelectionAsync(GetElementRect((FrameworkElement) sender), Placement.Above); if (isPinned) { BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent(2); BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile(BADGE_TILE_ID).Update(badgeContent.CreateNotification()); rootPage.NotifyUser("Secondary tile created and badge updated. Go to PC settings to add it to the lock screen.", NotifyType.StatusMessage); } else { rootPage.NotifyUser("Tile not created.", NotifyType.ErrorMessage); } } else { rootPage.NotifyUser("Badge secondary tile already exists.", NotifyType.ErrorMessage); } }
private static void ShowTile(List<SocialDataGroup> data) { TileUpdateManager.CreateTileUpdaterForApplication().Clear(); BadgeUpdateManager.CreateBadgeUpdaterForApplication().Clear(); var longtitle = ""; var shorttitle = ""; var count = 0; var titles = ""; foreach (var dg in data) { count += dg.UnreadCount; titles += dg.Title + ", " ; } titles = titles.Remove(titles.Length - 3, 2); longtitle = count + " unread from "+ titles; shorttitle = count+ " unread"; // create a tile notification var tileContent = TileContentFactory.CreateTileWideText03(); tileContent.TextHeadingWrap.Text = longtitle; var squareContent = TileContentFactory.CreateTileSquareText04(); squareContent.TextBodyWrap.Text = shorttitle; tileContent.SquareContent = squareContent; // send the notification to the app's application tile TileUpdateManager.CreateTileUpdaterForApplication().Update(tileContent.CreateNotification()); var bcontent = new BadgeNumericNotificationContent((uint)count); BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(bcontent.CreateNotification()); }
public static void UpdateBadgeNumber(string id, uint number) { if(IsPinned(id)) { BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent(number); BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile(id).Update(badgeContent.CreateNotification()); } }
private void showBadgeWithNumber(object sender, RoutedEventArgs e) { BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent(11); BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeContent.CreateNotification()); }
/// <summary> /// 更新磁贴数字 /// </summary> /// <param name="number"></param> public static void UpdateSecondaryBadgeWithNumber(string tileId, int number) { BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent((uint)number); // Send the notification to the application’s tile. BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile(tileId).Update(badgeContent.CreateNotification()); }
/// <summary> /// This is the click handler for the 'Other' button. You would replace this with your own handler /// if you have a button or buttons on this page. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SendBadgeNotification_Click(object sender, RoutedEventArgs e) { Button button = sender as Button; if (button != null) { if (SecondaryTile.Exists(MainPage.dynamicTileId)) { BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent(6); // Send the notification to the secondary tile BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile(MainPage.dynamicTileId).Update(badgeContent.CreateNotification()); rootPage.NotifyUser("Badge notification sent to " + MainPage.dynamicTileId, NotifyType.StatusMessage); } else { ToggleButtons(false); rootPage.NotifyUser(MainPage.dynamicTileId + " not pinned.", NotifyType.ErrorMessage); } } }
void AtualizaBadge(int number) { BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent((uint)number); BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeContent.CreateNotification()); }
/// <summary> /// 更新磁贴数字 /// </summary> /// <param name="number"></param> public static void UpdateBadgeWithNumber(int number) { BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent((uint)number); // Send the notification to the application’s tile. BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeContent.CreateNotification()); }
private void SendBadge_Click(object sender, RoutedEventArgs e) { BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent(6); BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeContent.CreateNotification()); rootPage.NotifyUser("Badge notification sent", NotifyType.StatusMessage); }
/// <summary> /// 更新未读头条文章的徽章badge /// </summary> /// <param name="t"></param> private static void UpdateBadge(LatestStories t) { //将当天未读TOP文章更新到 badge int un_readed = 0; t.Top_Stories.ToList().ForEach(s => { if (!DataShareManager.Current.ReadedList.Contains(s.ID)) un_readed++; }); var updater = BadgeUpdateManager.CreateBadgeUpdaterForApplication(); if (un_readed != 0) { var badgexml = new BadgeNumericNotificationContent((uint)un_readed); var n = badgexml.CreateNotification(); n.ExpirationTime = DateTime.Now.AddDays(7); updater.Update(n); } else { updater.Clear(); } }
void UpdateBadgeWithNumber(int number) { // Note: This sample contains an additional project, NotificationsExtensions. // NotificationsExtensions exposes an object model for creating notifications, but you can also modify the xml // of the notification directly. See the additional function UpdateBadgeWithNumberWithStringManipulation to see how to do it // by modifying strings directly. BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent((uint)number); // Send the notification to the application’s tile. BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeContent.CreateNotification()); OutputTextBlock.Text = badgeContent.GetContent(); }
/// <summary> /// 拉取最新文章 /// </summary> /// <returns></returns> public async static Task PullLatestStories() { APIService api = new APIService(); var t = await api.GetLatestStories(); //将当天未读文章更新到 badge int un_readed = 0; t.Stories.ToList().ForEach(s => { if (!DataShareManager.Current.ReadedList.Contains(s.ID)) un_readed++; }); var updater = BadgeUpdateManager.CreateBadgeUpdaterForApplication(); if (un_readed != 0) { var badgexml = new BadgeNumericNotificationContent((uint)un_readed); var n = badgexml.CreateNotification(); n.ExpirationTime = DateTime.Now.AddDays(7); updater.Update(n); } else { updater.Clear(); } }
/// <summary> /// バッジの追加 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void addBadgeButton_Click(object sender, RoutedEventArgs e) { BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent(6); BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeContent.CreateNotification()); }