void UpdateTileWithImage_Click(object sender, RoutedEventArgs e) { // Note: This sample contains an additional project, NotificationsExtensions. // NotificationsExtensions exposes an object model for creating notifications, but you can also // modify the strings directly. See UpdateTileWithImageWithStringManipulation_Click for an example // Create notification content based on a visual template. ITileWideImageAndText01 tileContent = TileContentFactory.CreateTileWideImageAndText01(); tileContent.TextCaptionWrap.Text = "This tile notification uses ms-appx images"; tileContent.Image.Src = "ms-appx:///images/redWide.png"; tileContent.Image.Alt = "Red image"; // Users can resize tiles to square or wide. // Apps can choose to include only square assets (meaning the app's tile can never be wide), or // include both wide and square assets (the user can resize the tile to square or wide). // Apps should not include only wide assets. // Apps that support being wide should include square tile notifications since users // determine the size of the tile. // create the square template and attach it to the wide template ITileSquareImage squareContent = TileContentFactory.CreateTileSquareImage(); squareContent.Image.Src = "ms-appx:///images/graySquare.png"; squareContent.Image.Alt = "Gray image"; tileContent.SquareContent = squareContent; // Send the notification to the app's application tile. TileUpdateManager.CreateTileUpdaterForApplication().Update(tileContent.CreateNotification()); OutputTextBlock.Text = MainPage.PrettyPrint(tileContent.GetContent()); }
void SendTileNotificationWithQueryStrings_Click(object sender, RoutedEventArgs e) { ITileWideImageAndText01 tileContent = TileContentFactory.CreateTileWideImageAndText01(); tileContent.TextCaptionWrap.Text = "This tile notification uses query strings for the image src."; tileContent.Image.Src = ImageUrl.Text; tileContent.Image.Alt = "Web image"; // enable AddImageQuery on the notification tileContent.AddImageQuery = true; ITileSquareImage squareContent = TileContentFactory.CreateTileSquareImage(); squareContent.Image.Src = ImageUrl.Text; squareContent.Image.Alt = "Web image"; // include the square template. tileContent.SquareContent = squareContent; // send the notification to the app's application tile TileUpdateManager.CreateTileUpdaterForApplication().Update(tileContent.CreateNotification()); OutputTextBlock.Text = MainPage.PrettyPrint(tileContent.GetContent()); }
/// <summary> /// /// </summary> /// <param name="notificationTileList"></param> public static void UpdateTileWithImages(List <NotificationTile> notificationTileList) { if (notificationTileList != null && notificationTileList.Count > 0) { TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true); TileUpdateManager.CreateTileUpdaterForApplication().Clear(); for (int i = 0; i < notificationTileList.Count; i++) { if (i < 5) { ITileWideImageAndText01 tileContent = TileContentFactory.CreateTileWideImageAndText01(); tileContent.Image.Src = notificationTileList[i].ImageUri; tileContent.Image.Alt = notificationTileList[i].ImageAltName; if (notificationTileList[i].TextBodyWrap.Length > 80) { tileContent.TextCaptionWrap.Text = notificationTileList[i].TextBodyWrap.Substring(0, 80); } else { tileContent.TextCaptionWrap.Text = notificationTileList[i].TextBodyWrap; } ITileSquarePeekImageAndText02 squareImageAndTextContent = TileContentFactory.CreateTileSquarePeekImageAndText02(); squareImageAndTextContent.Image.Src = notificationTileList[i].ImageUri; squareImageAndTextContent.Image.Alt = notificationTileList[i].ImageAltName; if (notificationTileList[i].TextHeading.Length > 30) { squareImageAndTextContent.TextHeading.Text = notificationTileList[i].TextHeading.Substring(0, 30); } else { squareImageAndTextContent.TextHeading.Text = notificationTileList[i].TextHeading; } if (notificationTileList[i].TextBodyWrap.Length > 80) { squareImageAndTextContent.TextBodyWrap.Text = notificationTileList[i].TextBodyWrap.Substring(0, 80); } else { squareImageAndTextContent.TextBodyWrap.Text = notificationTileList[i].TextBodyWrap; } tileContent.SquareContent = squareImageAndTextContent; TileUpdateManager.CreateTileUpdaterForApplication().Update(tileContent.CreateNotification()); } } } }
void UpdateTileWithWebImage() { ITileWideImageAndText01 tileContent = TileContentFactory.CreateTileWideImageAndText01(); tileContent.TextCaptionWrap.Text = "高清:撑杆跳伊辛巴耶娃4米70无缘奥运三连冠"; tileContent.Image.Src = "http://img1.gtimg.com/4/460/46005/4600509_980x1200_292.jpg"; tileContent.Image.Alt = "Web image"; ITileSquareImage squareContent = TileContentFactory.CreateTileSquareImage(); squareContent.Image.Src = "http://img1.gtimg.com/4/460/46005/4600509_980x1200_292.jpg"; squareContent.Image.Alt = "Web image"; tileContent.SquareContent = squareContent; TileUpdateManager.CreateTileUpdaterForApplication().Update(tileContent.CreateNotification()); }
/// <summary> /// /// </summary> /// <param name="notificationTile"></param> public static void UpdateTileWithImage(NotificationTile notificationTile) { if (notificationTile != null) { TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(false); TileUpdateManager.CreateTileUpdaterForApplication().Clear(); ITileWideImageAndText01 tileContent = TileContentFactory.CreateTileWideImageAndText01(); tileContent.Image.Src = notificationTile.ImageUri; tileContent.Image.Alt = notificationTile.ImageAltName; if (notificationTile.TextBodyWrap.Length > 80) { tileContent.TextCaptionWrap.Text = notificationTile.TextBodyWrap.Substring(0, 80); } else { tileContent.TextCaptionWrap.Text = notificationTile.TextBodyWrap; } ITileSquarePeekImageAndText02 squareImageAndTextContent = TileContentFactory.CreateTileSquarePeekImageAndText02(); squareImageAndTextContent.Image.Src = notificationTile.ImageUri; squareImageAndTextContent.Image.Alt = notificationTile.ImageAltName; if (notificationTile.TextHeading.Length > 30) { squareImageAndTextContent.TextHeading.Text = notificationTile.TextHeading.Substring(0, 30); } else { squareImageAndTextContent.TextHeading.Text = notificationTile.TextHeading; } if (notificationTile.TextBodyWrap.Length > 80) { squareImageAndTextContent.TextBodyWrap.Text = notificationTile.TextBodyWrap.Substring(0, 80); } else { squareImageAndTextContent.TextBodyWrap.Text = notificationTile.TextBodyWrap; } tileContent.SquareContent = squareImageAndTextContent; TileUpdateManager.CreateTileUpdaterForApplication().Update(tileContent.CreateNotification()); } }
void UpdateTileWithWebImage_Click(object sender, RoutedEventArgs e) { // Note: This sample contains an additional project, NotificationsExtensions. // NotificationsExtensions exposes an object model for creating notifications, but you can also // modify the strings directly. See UpdateTileWithWebImageWithStringManipulation_Click for an example // Create notification content based on a visual template. ITileWideImageAndText01 tileContent = TileContentFactory.CreateTileWideImageAndText01(); tileContent.TextCaptionWrap.Text = "This tile notification uses web images."; // !Important! // The Internet (Client) capability must be checked in the manifest in the Capabilities tab // to display web images in tiles (either the http:// or https:// protocols) tileContent.Image.Src = ImageUrl.Text; tileContent.Image.Alt = "Web image"; // Users can resize tiles to square or wide. // Apps can choose to include only square assets (meaning the app's tile can never be wide), or // include both wide and square assets (the user can resize the tile to square or wide). // Apps cannot include only wide assets. // Apps that support being wide should include square tile notifications since users // determine the size of the tile. // Create square notification content based on a visual template. ITileSquareImage squareContent = TileContentFactory.CreateTileSquareImage(); squareContent.Image.Src = ImageUrl.Text; squareContent.Image.Alt = "Web image"; // include the square template. tileContent.SquareContent = squareContent; // send the notification to the app's application tile TileUpdateManager.CreateTileUpdaterForApplication().Update(tileContent.CreateNotification()); OutputTextBlock.Text = MainPage.PrettyPrint(tileContent.GetContent()); }
public static void ShowliveTile(bool IsLiveTile1, string name) { string wideTilesrc = "ms-appx:///Assets/BigLiveTile1.jpg"; string smallTilesrc = "ms-appx:///Assets/SmallLiveTile1.jpg"; if (!IsLiveTile1) { wideTilesrc = "ms-appx:///Assets/BigLiveTile2.jpg"; smallTilesrc = "ms-appx:///Assets/SmallLiveTile2.jpg"; } // Note: This sample contains an additional project, NotificationsExtensions. // NotificationsExtensions exposes an object model for creating notifications, but you can also // modify the strings directly. See UpdateTileWithImageWithStringManipulation_Click for an example // Create notification content based on a visual template. ITileWideImageAndText01 tileContent = TileContentFactory.CreateTileWideImageAndText01(); tileContent.TextCaptionWrap.Text = name; tileContent.Image.Src = wideTilesrc; tileContent.Image.Alt = "Live tile"; // Users can resize tiles to square or wide. // Apps can choose to include only square assets (meaning the app's tile can never be wide), or // include both wide and square assets (the user can resize the tile to square or wide). // Apps should not include only wide assets. // Apps that support being wide should include square tile notifications since users // determine the size of the tile. // create the square template and attach it to the wide template ITileSquareImage squareContent = TileContentFactory.CreateTileSquareImage(); squareContent.Image.Src = smallTilesrc; squareContent.Image.Alt = "Live tile"; tileContent.SquareContent = squareContent; // Send the notification to the app's application tile. TileUpdateManager.CreateTileUpdaterForApplication().Update(tileContent.CreateNotification()); }
private static void UpdateSecondaryTileWithImage(string tileId, NotificationTile notificationTile, NotificationSecondaryTileType tileType) { if (!string.IsNullOrEmpty(tileId) && !string.IsNullOrWhiteSpace(tileId) && notificationTile != null) { TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileId).EnableNotificationQueue(false); TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileId).Clear(); ITileSquarePeekImageAndText02 squareImageAndTextContent = TileContentFactory.CreateTileSquarePeekImageAndText02(); squareImageAndTextContent.Image.Src = notificationTile.ImageUri; squareImageAndTextContent.Image.Alt = notificationTile.ImageAltName; squareImageAndTextContent.TextHeading.Text = notificationTile.TextHeading; squareImageAndTextContent.TextBodyWrap.Text = notificationTile.TextBodyWrap; if (tileType == NotificationSecondaryTileType.CustomTile) { ITileWideImageAndText01 tileContent = TileContentFactory.CreateTileWideImageAndText01(); tileContent.Image.Src = notificationTile.ImageUri; tileContent.Image.Alt = notificationTile.ImageAltName; tileContent.TextCaptionWrap.Text = notificationTile.TextBodyWrap; tileContent.SquareContent = squareImageAndTextContent; TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileId).Update(tileContent.CreateNotification()); } else { ITileWidePeekImage05 tileContent = TileContentFactory.CreateTileWidePeekImage05(); tileContent.ImageMain.Src = tileContent.ImageSecondary.Src = notificationTile.ImageUri; tileContent.ImageMain.Alt = tileContent.ImageSecondary.Alt = notificationTile.ImageAltName; tileContent.TextHeading.Text = notificationTile.TextHeading; tileContent.TextBodyWrap.Text = notificationTile.TextBodyWrap; tileContent.SquareContent = squareImageAndTextContent; TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileId).Update(tileContent.CreateNotification()); } } }