/// <summary> /// This is the click handler for the 'Sending tile notification' button. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SendTileNotification_Click(object sender, RoutedEventArgs e) { Button button = sender as Button; if (button != null) { if (SecondaryTile.Exists(MainPage.dynamicTileId)) { // Note: This sample contains an additional reference, NotificationsExtensions, which you can use in your apps ITileWide310x150Text04 tileContent = TileContentFactory.CreateTileWide310x150Text04(); tileContent.TextBodyWrap.Text = "Sent to a secondary tile from NotificationsExtensions!"; ITileSquare150x150Text04 squareContent = TileContentFactory.CreateTileSquare150x150Text04(); squareContent.TextBodyWrap.Text = "Sent to a secondary tile from NotificationExtensions!"; tileContent.Square150x150Content = squareContent; // Send the notification to the secondary tile by creating a secondary tile updater TileUpdateManager.CreateTileUpdaterForSecondaryTile(MainPage.dynamicTileId).Update(tileContent.CreateNotification()); rootPage.NotifyUser("Tile notification sent to " + MainPage.dynamicTileId, NotifyType.StatusMessage); } else { ToggleButtons(false); rootPage.NotifyUser(MainPage.dynamicTileId + " not pinned.", NotifyType.ErrorMessage); } } }
void ScheduleTile(String updateString, DateTime dueTime, int idNumber) { // Set up the wide tile text ITileWide310x150Text09 tileContent = TileContentFactory.CreateTileWide310x150Text09(); tileContent.TextHeading.Text = updateString; tileContent.TextBodyWrap.Text = "Received: " + dueTime.ToLocalTime(); // Set up square tile text ITileSquare150x150Text04 squareContent = TileContentFactory.CreateTileSquare150x150Text04(); squareContent.TextBodyWrap.Text = updateString; tileContent.Square150x150Content = squareContent; // Create the notification object ScheduledTileNotification futureTile = new ScheduledTileNotification(tileContent.GetXml(), dueTime); futureTile.Id = "Tile" + idNumber; // Add to schedule // You can update a secondary tile in the same manner using CreateTileUpdaterForSecondaryTile(tileId) // See "Tiles" sample for more details TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(futureTile); rootPage.NotifyUser("Scheduled a tile with ID: " + futureTile.Id, NotifyType.StatusMessage); }
private void UpdateTileWithText_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 UpdateTileWithTextWithStringManipulation_Click for an example. // Users can resize any app tile to the small (Square70x70 on Windows 8.1, Square71x71 on Windows Phone 8.1) and medium (Square150x150) tile sizes. // These are both tile sizes an app must minimally support. // An app can additionally support the wide (Wide310x150) tile size as well as the large (Square310x310) tile size. // Note that in order to support a large (Square310x310) tile size, an app must also support the wide (Wide310x150) tile size (but not vice versa). // This sample application supports all four tile sizes: small, medium, wide and large. // This means that the user may have resized their tile to any of these four sizes for their custom Start screen layout. // Because an app has no way of knowing what size the user resized their app tile to, an app should include template bindings // for each supported tile sizes in their notifications. Only Windows Phone 8.1 supports small tile notifications, // and there are no text templates available for this size. // We assemble one notification with three template bindings by including the content for each smaller // tile in the next size up. Square310x310 includes Wide310x150, which includes Square150x150. // If we leave off the content for a tile size which the application supports, the user will not see the // notification if the tile is set to that size. // Create a notification for the Square310x310 tile using one of the available templates for the size. ITileSquare310x310Text09 tileContent = TileContentFactory.CreateTileSquare310x310Text09(); tileContent.TextHeadingWrap.Text = "Hello World! My very own tile notification"; // Create a notification for the Wide310x150 tile using one of the available templates for the size. ITileWide310x150Text03 wide310x150Content = TileContentFactory.CreateTileWide310x150Text03(); wide310x150Content.TextHeadingWrap.Text = "Hello World! My very own tile notification"; // Create a notification for the Square150x150 tile using one of the available templates for the size. ITileSquare150x150Text04 square150x150Content = TileContentFactory.CreateTileSquare150x150Text04(); square150x150Content.TextBodyWrap.Text = "Hello World! My very own tile notification"; // Attach the Square150x150 template to the Wide310x150 template. wide310x150Content.Square150x150Content = square150x150Content; // Attach the Wide310x150 template to the Square310x310 template. tileContent.Wide310x150Content = wide310x150Content; // Send the notification to the application? tile. TileUpdateManager.CreateTileUpdaterForApplication().Update(tileContent.CreateNotification()); OutputTextBlock.Text = MainPage.PrettyPrint(tileContent.GetContent()); rootPage.NotifyUser("Tile notification with text sent", NotifyType.StatusMessage); }
void UpdateTileExpiring_Click(object sender, RoutedEventArgs e) { int seconds; if (!Int32.TryParse(Time.Text, out seconds)) { seconds = 10; } Windows.Globalization.Calendar cal = new Windows.Globalization.Calendar(); cal.SetToNow(); cal.AddSeconds(seconds); var longTime = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("longtime"); DateTimeOffset expiryTime = cal.GetDateTime(); string expiryTimeString = longTime.Format(expiryTime); // Create a notification for the Square310x310 tile using one of the available templates for the size. ITileSquare310x310Text09 tileSquare310x310Content = TileContentFactory.CreateTileSquare310x310Text09(); tileSquare310x310Content.TextHeadingWrap.Text = "This notification will expire at " + expiryTimeString; // Create a notification for the Wide310x150 tile using one of the available templates for the size. ITileWide310x150Text04 wide310x150TileContent = TileContentFactory.CreateTileWide310x150Text04(); wide310x150TileContent.TextBodyWrap.Text = "This notification will expire at " + expiryTimeString; // Create a notification for the Square150x150 tile using one of the available templates for the size. ITileSquare150x150Text04 square150x150TileContent = TileContentFactory.CreateTileSquare150x150Text04(); square150x150TileContent.TextBodyWrap.Text = "This notification will expire at " + expiryTimeString; // Attach the Square150x150 template to the Wide310x150 template. wide310x150TileContent.Square150x150Content = square150x150TileContent; // Attach the Wide310x150 template to the Square310x310 template. tileSquare310x310Content.Wide310x150Content = wide310x150TileContent; TileNotification tileNotification = tileSquare310x310Content.CreateNotification(); // Set the expiration time and update the tile. tileNotification.ExpirationTime = expiryTime; TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification); rootPage.NotifyUser("Tile notification sent. It will expire at " + expiryTime, NotifyType.StatusMessage); }
private void UpdateTile() { TileUpdateManager.CreateTileUpdaterForApplication().Clear(); TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true); ITileSquare310x310Image tileContent = TileContentFactory.CreateTileSquare310x310Image(); tileContent.AddImageQuery = true; tileContent.Image.Src = ImageUrl; tileContent.Image.Alt = "Web Image"; ITileWide310x150ImageAndText01 wide310x150Content = TileContentFactory.CreateTileWide310x150ImageAndText01(); wide310x150Content.TextCaptionWrap.Text = "Last Book:ISBN-" + MainPage.isbn; wide310x150Content.Image.Src = ImageUrl; wide310x150Content.Image.Alt = "Web image"; ITileSquare150x150Image square150x150Content = TileContentFactory.CreateTileSquare150x150Image(); square150x150Content.Image.Src = ImageUrl; square150x150Content.Image.Alt = "Web image"; wide310x150Content.Square150x150Content = square150x150Content; tileContent.Wide310x150Content = wide310x150Content; TileNotification tileNotification = tileContent.CreateNotification(); string tag = "Image"; tileNotification.Tag = tag; TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification); ITileSquare310x310Text09 square310x310TileContent = TileContentFactory.CreateTileSquare310x310Text09(); square310x310TileContent.TextHeadingWrap.Text = Title.Text + Environment.NewLine + "ISBN-" + MainPage.isbn; ITileWide310x150Text03 wide310x150TileContent = TileContentFactory.CreateTileWide310x150Text03(); wide310x150TileContent.TextHeadingWrap.Text = Title.Text + Environment.NewLine + "ISBN-" + MainPage.isbn; ITileSquare150x150Text04 square150x150TileContent = TileContentFactory.CreateTileSquare150x150Text04(); square150x150TileContent.TextBodyWrap.Text = Title.Text + Environment.NewLine + "ISBN-" + MainPage.isbn; wide310x150TileContent.Square150x150Content = square150x150TileContent; square310x310TileContent.Wide310x150Content = wide310x150TileContent; tileNotification = square310x310TileContent.CreateNotification(); tag = "Title"; tileNotification.Tag = tag; TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification); }
void SendTextResourceTileNotification_Click(object sender, RoutedEventArgs e) { ITileSquare310x310Text09 square310x310TileContent = TileContentFactory.CreateTileSquare310x310Text09(); // Check out /en-US/resources.resw to understand where this string will come from. square310x310TileContent.TextHeadingWrap.Text = "ms-resource:greeting"; ITileWide310x150Text03 wide310x150TileContent = TileContentFactory.CreateTileWide310x150Text03(); wide310x150TileContent.TextHeadingWrap.Text = "ms-resource:greeting"; ITileSquare150x150Text04 square150x150TileContent = TileContentFactory.CreateTileSquare150x150Text04(); square150x150TileContent.TextBodyWrap.Text = "ms-resource:greeting"; wide310x150TileContent.Square150x150Content = square150x150TileContent; square310x310TileContent.Wide310x150Content = wide310x150TileContent; TileUpdateManager.CreateTileUpdaterForApplication().Update(square310x310TileContent.CreateNotification()); OutputTextBlock.Text = MainPage.PrettyPrint(square310x310TileContent.GetContent()); }
void UpdateTile_Click(object sender, RoutedEventArgs e) { // Create a notification for the Square310x310 tile using one of the available templates for the size. ITileSquare310x310Text09 square310x310TileContent = TileContentFactory.CreateTileSquare310x310Text09(); square310x310TileContent.TextHeadingWrap.Text = TextContent.Text; // Create a notification for the Wide310x150 tile using one of the available templates for the size. ITileWide310x150Text03 wide310x150TileContent = TileContentFactory.CreateTileWide310x150Text03(); wide310x150TileContent.TextHeadingWrap.Text = TextContent.Text; // Create a notification for the Square150x150 tile using one of the available templates for the size. ITileSquare150x150Text04 square150x150TileContent = TileContentFactory.CreateTileSquare150x150Text04(); square150x150TileContent.TextBodyWrap.Text = TextContent.Text; // Attach the Square150x150 template to the Wide310x150 template. wide310x150TileContent.Square150x150Content = square150x150TileContent; // Attach the Wide310x150 template to the Square310x310 template. square310x310TileContent.Wide310x150Content = wide310x150TileContent; TileNotification tileNotification = square310x310TileContent.CreateNotification(); string tag = "TestTag01"; if (!Id.Text.Equals(String.Empty)) { tag = Id.Text; } // Set the tag on the notification. tileNotification.Tag = tag; TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification); OutputTextBlock.Text = "Tile notification sent. It is tagged with '" + tag + "'.\n" + MainPage.PrettyPrint(square310x310TileContent.GetContent()); }
void ScheduleTile(String updateString, DateTime dueTime, int idNumber) { // Set up the wide tile text ITileWide310x150Text09 tileContent = TileContentFactory.CreateTileWide310x150Text09(); tileContent.TextHeading.Text = updateString; tileContent.TextBodyWrap.Text = "Received: " + dueTime.ToLocalTime(); // Set up square tile text ITileSquare150x150Text04 squareContent = TileContentFactory.CreateTileSquare150x150Text04(); squareContent.TextBodyWrap.Text = updateString; tileContent.Square150x150Content = squareContent; // Create the notification object ScheduledTileNotification futureTile = new ScheduledTileNotification(tileContent.GetXml(), dueTime); futureTile.Id = "Tile" + idNumber; TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(futureTile); // rootPage.NotifyUser("Scheduled a tile with ID: " + futureTile.Id, NotifyType.StatusMessage); }
void SendNotifications_Click(object sender, RoutedEventArgs e) { // Create a notification for the first set of stories with bindings for all 3 tile sizes ITileSquare310x310Text09 square310x310TileContent1 = TileContentFactory.CreateTileSquare310x310Text09(); square310x310TileContent1.TextHeadingWrap.Text = "Main Story"; ITileWide310x150Text03 wide310x150TileContent1 = TileContentFactory.CreateTileWide310x150Text03(); wide310x150TileContent1.TextHeadingWrap.Text = "Main Story"; ITileSquare150x150Text04 square150x150TileContent1 = TileContentFactory.CreateTileSquare150x150Text04(); square150x150TileContent1.TextBodyWrap.Text = "Main Story"; wide310x150TileContent1.Square150x150Content = square150x150TileContent1; square310x310TileContent1.Wide310x150Content = wide310x150TileContent1; // Set the contentId on the Square310x310 tile square310x310TileContent1.ContentId = "Main_1"; // Tag the notification and send it to the tile TileNotification tileNotification = square310x310TileContent1.CreateNotification(); tileNotification.Tag = "1"; TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification); // Create the first notification for the second set of stories with binding for all 3 tiles sizes ITileSquare310x310TextList03 square310x310TileContent2 = TileContentFactory.CreateTileSquare310x310TextList03(); square310x310TileContent2.TextHeading1.Text = "Additional Story 1"; square310x310TileContent2.TextHeading2.Text = "Additional Story 2"; square310x310TileContent2.TextHeading3.Text = "Additional Story 3"; ITileWide310x150Text03 wide310x150TileContent2 = TileContentFactory.CreateTileWide310x150Text03(); wide310x150TileContent2.TextHeadingWrap.Text = "Additional Story 1"; ITileSquare150x150Text04 square150x150TileContent2 = TileContentFactory.CreateTileSquare150x150Text04(); square150x150TileContent2.TextBodyWrap.Text = "Additional Story 1"; wide310x150TileContent2.Square150x150Content = square150x150TileContent2; square310x310TileContent2.Wide310x150Content = wide310x150TileContent2; // Set the contentId on the Square310x310 tile square310x310TileContent2.ContentId = "Additional_1"; // Tag the notification and send it to the tile tileNotification = square310x310TileContent2.CreateNotification(); tileNotification.Tag = "2"; TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification); // Create the second notification for the second set of stories with binding for all 3 tiles sizes // Notice that we only replace the Wide310x150 and Square150x150 binding elements, // and keep the Square310x310 content the same - this will cause the Square310x310 to be ignored for this notification, // since the contentId for this size is the same as in the first notification of the second set of stories. ITileWide310x150Text03 wide310x150TileContent3 = TileContentFactory.CreateTileWide310x150Text03(); wide310x150TileContent3.TextHeadingWrap.Text = "Additional Story 2"; ITileSquare150x150Text04 square150x150TileContent3 = TileContentFactory.CreateTileSquare150x150Text04(); square150x150TileContent3.TextBodyWrap.Text = "Additional Story 2"; wide310x150TileContent3.Square150x150Content = square150x150TileContent3; square310x310TileContent2.Wide310x150Content = wide310x150TileContent3; // Tag the notification and send it to the tile tileNotification = square310x310TileContent2.CreateNotification(); tileNotification.Tag = "3"; TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification); // Create the third notification for the second set of stories with binding for all 3 tiles sizes // Notice that we only replace the Wide310x150 and Square150x150 binding elements, // and keep the Square310x310 content the same again - this will cause the Square310x310 to be ignored for this notification, // since the contentId for this size is the same as in the first notification of the second set of stories. ITileWide310x150Text03 wide310x150TileContent4 = TileContentFactory.CreateTileWide310x150Text03(); wide310x150TileContent4.TextHeadingWrap.Text = "Additional Story 3"; ITileSquare150x150Text04 square150x150TileContent4 = TileContentFactory.CreateTileSquare150x150Text04(); square150x150TileContent4.TextBodyWrap.Text = "Additional Story 3"; wide310x150TileContent4.Square150x150Content = square150x150TileContent4; square310x310TileContent2.Wide310x150Content = wide310x150TileContent4; // Tag the notification and send it to the tile tileNotification = square310x310TileContent2.CreateNotification(); tileNotification.Tag = "4"; TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification); rootPage.NotifyUser("Four notifications sent.", NotifyType.StatusMessage); }