private void BuildTile(bool isWide, TileTemplateType tileTemplateType, IEnumerable <string> text, IEnumerable <string> images) { Guard.False(isWide ? _WideTileSet : _SquareTileSet); Guard.NotNull(text, images); var templateName = tileTemplateType.ToString().ToUpperInvariant(); var containsString = isWide ? "WIDE" : "SQUARE"; //Wide tiles have "Wide" in their name while normal tiles have "Square" in their name. //Making sure that the proper templates are used. Guard.True(templateName.Contains(containsString)); var tileXml = TileUpdateManager.GetTemplateContent(tileTemplateType); Guard.NotNull(tileXml); UpdateTileText(tileXml, text); UpdateTileImages(tileXml, images); SetOrMergeTile(tileXml); if (isWide) { _WideTileSet = true; } else { _SquareTileSet = true; } }
private void UpdateTile(Item item) { TileTemplateType template = (TileTemplateType)Enum.Parse(typeof(TileTemplateType), item.Style); XmlDocument tile = TileUpdateManager.GetTemplateContent(template); XmlNodeList text = tile.GetElementsByTagName("text"); if (text.Length > 0) { for (int i = 0; i < text.Length; i++) { text[i].AppendChild(tile.CreateTextNode(item.Value)); } } XmlNodeList image = tile.GetElementsByTagName("image"); if (image.Length > 0) { for (int i = 0; i < image.Length; i++) { image[i].Attributes.GetNamedItem("src").NodeValue = "Assets/Square44x44Logo.scale-200.png"; } } TileNotification notification = new TileNotification(tile); string output = tile.GetXml(); TileUpdateManager.CreateTileUpdaterForApplication().Update(notification); }
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.AddedItems.Count > 0) { string templateName = e.AddedItems[0].ToString(); selectedTemplate = (TileTemplateType)Enum.Parse(typeof(TileTemplateType), templateName); var template = TileUpdateManager.GetTemplateContent(selectedTemplate); templateNameTextBox.Text = templateName; string xmlContent = template.GetXml(); var xDocument = XDocument.Parse(xmlContent); xmlTemplateNameTextBox.Text = xDocument.ToString(); var textNodes = xDocument.Descendants(XName.Get("text")); var imageNodes = xDocument.Descendants(XName.Get("image")); foreach (var item in textNodes) { item.Value = string.Format("text {0}", item.Attribute(XName.Get("id"))); } foreach (var item in imageNodes) { item.Attribute(XName.Get("src")).Value = @"Assets\picture.png"; } xmlResultNameTextBox.Text = xDocument.ToString(); } }
private TileNotificationBuilder Replicate(TileTemplateType newType) { var newBuilder = new TileNotificationBuilder(this.Texts, newType); newBuilder.ImageUris = new List <string>(this.ImageUris); return(newBuilder); }
/// <summary> /// Initializes a new instance of the <see cref="BaseTile"/> class. /// </summary> /// <param name="templateType"> /// The template Type. /// </param> public BaseTile(TileTemplateType templateType) : base(TileUpdateManager.GetTemplateContent(templateType), GetTemplateName(templateType)) { this.Type = templateType; var size = TemplateMap.Keys.FirstOrDefault(s => this.TemplateType.Contains(s)); this.TileType = !string.IsNullOrWhiteSpace(size) ? TemplateMap[size] : TileTypes.Unknown; }
private XmlDocument GetTileXmlDocument(TileTemplateType tileTemplate, string title, string content) { var tileTemplateXmlDocument = TileUpdateManager.GetTemplateContent(tileTemplate); var tileTextAttributes = tileTemplateXmlDocument.GetElementsByTagName(TileUpdateBackgroundTask.TextTagName); tileTextAttributes[0].AppendChild(tileTemplateXmlDocument.CreateTextNode(title)); tileTextAttributes[1].AppendChild(tileTemplateXmlDocument.CreateTextNode(content)); return(tileTemplateXmlDocument); }
private static string GetTemplateName(TileTemplateType templateType) { var binding = TileUpdateManager.GetTemplateContent(templateType).GetElementsByTagName("binding")[0]; var template = binding.Attributes.GetNamedItem("template"); if (template == null) { return(templateType.ToString()); } return(template.NodeValue.ToString()); }
private static void _updatePrimaryTile(string text, string imgSrc, string imgAlt, TileTemplateType templateType) { TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true); XmlDocument tileXml = TileUpdateManager.GetTemplateContent(templateType); //TileWide310x150ImageAndText01 //version XmlNodeList tileVersionAttributes = tileXml.GetElementsByTagName("visual"); ((XmlElement)tileVersionAttributes[0]).SetAttribute("version", "2"); //tileXml.FirstChild.FirstChild.Attributes[0].NodeValue = "2"; ////branding //XmlNodeList tileBindingAttributes = tileXml.GetElementsByTagName("binding"); //((XmlElement)tileBindingAttributes[0]).SetAttribute("branding", "logo"); //text XmlNodeList tileTextAttributes = tileXml.GetElementsByTagName("text"); if(tileTextAttributes.Count > 0) tileTextAttributes[0].InnerText = text; //tileTextAttributes[1].InnerText = "xxxxx"; //image XmlNodeList tileImageAttributes = tileXml.GetElementsByTagName("image"); ////image from apps package //((XmlElement)tileImageAttributes[0]).SetAttribute("src", "ms-appx:///assets/redWide.png"); //((XmlElement)tileImageAttributes[0]).SetAttribute("alt", "red graphic"); ////image from apps local storage //((XmlElement)tileImageAttributes[0]).SetAttribute("src", "ms-appdata:///local/redWide.png"); //((XmlElement)tileImageAttributes[0]).SetAttribute("alt", "red graphic"); ((XmlElement)tileImageAttributes[0]).SetAttribute("src", imgSrc); ((XmlElement)tileImageAttributes[0]).SetAttribute("alt", imgAlt); ////image from the web //((XmlElement)tileImageAttributes[0]).SetAttribute("src", "http://www.contoso.com/redWide.png"); //((XmlElement)tileImageAttributes[0]).SetAttribute("alt", "red graphic"); //create notifcation //TileNotification tileNotification = new TileNotification(tileXml); ScheduledTileNotification stn = new ScheduledTileNotification(tileXml, DateTimeOffset.Now.AddSeconds(8)); //notification expires in //tileNotification.ExpirationTime = DateTimeOffset.UtcNow.AddMinutes(10); //forced clear notification for app //Windows.UI.Notifications.TileUpdateManager.CreateTileUpdaterForApplication().Clear(); //send notification to app tile //TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification); TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(stn); }
/// <summary> /// Opdaterer applikationstile med en given nyhed på en given templatetype. /// </summary> /// <param name="nyhed">Nyhed, som applikationstile skal opdateres med.</param> /// <param name="type">Templatetypen, som skal præsentere nyheden.</param> /// <returns>Notifikation, som applikationstile skal benytte.</returns> private static TileNotification UpdateTile(INyhedModel nyhed, TileTemplateType type) { if (nyhed == null) { throw new ArgumentNullException(nameof(nyhed)); } XmlDocument tileXml = TileUpdateManager.GetTemplateContent(type); tileXml.GetElementsByTagName("text").First().InnerText = nyhed.Nyhedsinformation; return(new TileNotification(tileXml)); }
static XmlDocument GenerateTileXml(string imageFileName, TileTemplateType template) { var tileXml = TileUpdateManager.GetTemplateContent(template); var images = tileXml.GetElementsByTagName("image"); var src = tileXml.CreateAttribute("src"); src.Value = "ms-appdata:///local/" + imageFileName; images[0].Attributes.SetNamedItem(src); return(tileXml); }
public TileNotification UpdateAndReplicate(TileTemplateType replicaType) { // update this one... var result = Update(); // then copy... var replica = this.Replicate(replicaType); replica.Update(); // return... return(result); }
public static void UpdateTile(TileTemplateType tileTemplateType, string[] text, string[] images, DateTimeOffset?expirationTime) { // look for the templates on https://msdn.microsoft.com/en-us/library/windows/apps/Hh761491.aspx // all the nodes for supplying text are called "text". Conversely, everything with an image has a // tag called "image". This simplistic function simply searches all the XML nodes with "text" and replaces // them with the supplied text. Same for the images. var tileXml = TileUpdateManager.GetTemplateContent((Windows.UI.Notifications.TileTemplateType)tileTemplateType); if (text != null) { var textNodes = tileXml.GetElementsByTagName("text"); if (textNodes.Length != text.Length) { throw new ArgumentException("more text fields than supported by the template"); } for (int i = 0; i < textNodes.Length; i++) { textNodes[i].InnerText = text[i]; } } // for a text only template, images will not be supplied. if (images != null) { var imageNodes = tileXml.GetElementsByTagName("image"); if (images.Length != imageNodes.Length) { throw new ArgumentException("more images supplied than images"); } for (int j = 0; j < imageNodes.Length; j++) { imageNodes[j].Attributes.GetNamedItem("src").NodeValue = images[j]; } } var notification = new TileNotification(tileXml); if (expirationTime != null) { if (expirationTime > DateTimeOffset.Now) { notification.ExpirationTime = expirationTime; } } TileUpdateManager.CreateTileUpdaterForApplication().Update(notification); }
private void NotifyTile(string notificationText, string image) { try { TileTemplateType tileTemplate = TileTemplateType.TileSquare150x150PeekImageAndText04; XmlDocument tileXml = TileUpdateManager.GetTemplateContent(tileTemplate); XmlNodeList tileTextElements = tileXml.GetElementsByTagName("text"); tileTextElements[0].AppendChild(tileXml.CreateTextNode(notificationText)); XmlNodeList tileImageAttributes = tileXml.GetElementsByTagName("image"); ((XmlElement)tileImageAttributes[0]).SetAttribute("src", image); TileNotification tile = new TileNotification(tileXml); TileUpdateManager.CreateTileUpdaterForApplication().Update(tile); } catch (Exception) { } }
/// <summary> /// Displays a Windows 8 Live Tile notification. /// </summary> /// <param name="tileTemplateType">TileTemplateType. See hxxp://msdn.microsoft.com/en-us/library/windows/apps/hh761491.aspx</param> /// <param name="seconds">Number of seconds to display tile notification</param> /// <param name="customizeMethod">Method to set the XML text or image properties for the tile notification. The method receives an XmlDocument as a parameter, to modify the contents.</param> private static void SetLiveTile(TileTemplateType tileTemplateType, int seconds, Action<XmlDocument> customizeMethod) { // Get tile template. var tileTemplate = tileTemplateType; var tileXml = TileUpdateManager.GetTemplateContent(tileTemplate); // Create notification. var notification = new TileNotification(tileXml); notification.ExpirationTime = DateTime.Now + TimeSpan.FromSeconds(seconds); // Set notification options. customizeMethod(tileXml); // Update Live Tile. var upd = TileUpdateManager.CreateTileUpdaterForApplication(); upd.Update(notification); }
public static void UpdateTile() { TileTemplateType tileTemplate = TileTemplateType.TileWide310x150ImageAndText01; XmlDocument tileXml = TileUpdateManager.GetTemplateContent(tileTemplate); XmlNodeList tileImageAttributes = tileXml.GetElementsByTagName("image"); ((XmlElement)tileImageAttributes[0]).SetAttribute("src", "ms-appx:///Assets/breakfast400.jpg"); ((XmlElement)tileImageAttributes[0]).SetAttribute("alt", "Breakfast"); var textElements = tileXml.GetElementsByTagName("text"); ((XmlElement)textElements[0]).InnerText = "MENU card"; TileNotification notification = new TileNotification(tileXml); notification.ExpirationTime = DateTimeOffset.Now.AddMinutes(60); TileUpdater tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication(); tileUpdater.Update(notification); }
/// <summary> /// Displays a Windows 8 Live Tile notification. /// </summary> /// <param name="tileTemplateType">TileTemplateType. See hxxp://msdn.microsoft.com/en-us/library/windows/apps/hh761491.aspx</param> /// <param name="seconds">Number of seconds to display tile notification</param> /// <param name="customizeMethod">Method to set the XML text or image properties for the tile notification. The method receives an XmlDocument as a parameter, to modify the contents.</param> private static void SetLiveTile(TileTemplateType tileTemplateType, int seconds, Action <XmlDocument> customizeMethod) { // Get tile template. var tileTemplate = tileTemplateType; var tileXml = TileUpdateManager.GetTemplateContent(tileTemplate); // Create notification. var notification = new TileNotification(tileXml); notification.ExpirationTime = DateTime.Now + TimeSpan.FromSeconds(seconds); // Set notification options. customizeMethod(tileXml); // Update Live Tile. var upd = TileUpdateManager.CreateTileUpdaterForApplication(); upd.Update(notification); }
public static void UpdateBigTileWithMusicInfo() { const TileTemplateType template = TileTemplateType.TileWide310x150PeekImage05; var tileXml = TileUpdateManager.GetTemplateContent(template); var tileTextAttributes = tileXml.GetElementsByTagName("text"); #if WINDOWS_APP tileTextAttributes[0].InnerText = "Now playing"; #endif if (Locator.MusicPlayerVM.CurrentTrack != null) { #if WINDOWS_APP tileTextAttributes[1].InnerText = Locator.MusicPlayerVM.CurrentTrack.Name + " - " + Locator.MusicPlayerVM.CurrentTrack.ArtistName; #else tileTextAttributes[0].InnerText = Locator.MusicPlayerVM.CurrentTrack.Name ?? ""; tileTextAttributes[1].InnerText = Locator.MusicPlayerVM.CurrentTrack.AlbumName; tileTextAttributes[1].InnerText = Locator.MusicPlayerVM.CurrentTrack.ArtistName; #endif var tileImgAttribues = tileXml.GetElementsByTagName("image"); #if WINDOWS_APP if (Locator.MusicPlayerVM.CurrentArtist != null) { tileImgAttribues[0].Attributes[1].NodeValue = Locator.MusicPlayerVM.CurrentArtist.Picture; } if (Locator.MusicPlayerVM.CurrentAlbum != null) { tileImgAttribues[1].Attributes[1].NodeValue = Locator.MusicPlayerVM.CurrentAlbum.AlbumCoverUri; } #else if (Locator.MusicPlayerVM.CurrentAlbum != null) { tileImgAttribues[0].Attributes[1].NodeValue = Locator.MusicPlayerVM.CurrentAlbum.AlbumCoverUri; } #endif } var tileNotification = new TileNotification(tileXml); TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification); }
public static void UpdateBigTileWithMusicInfo() { const TileTemplateType template = TileTemplateType.TileWidePeekImage05; var tileXml = TileUpdateManager.GetTemplateContent(template); var tileTextAttributes = tileXml.GetElementsByTagName("text"); tileTextAttributes[0].InnerText = "Now playing"; if (Locator.MusicPlayerVM.Artist != null) { tileTextAttributes[1].InnerText = Locator.MusicPlayerVM.Artist.CurrentAlbumItem.CurrentTrack.Name + " - " + Locator.MusicPlayerVM.Artist.CurrentAlbumItem.Artist; var tileImgAttribues = tileXml.GetElementsByTagName("image"); tileImgAttribues[0].Attributes[1].NodeValue = Locator.MusicPlayerVM.Artist.Picture; tileImgAttribues[1].Attributes[1].NodeValue = Locator.MusicPlayerVM.Artist.CurrentAlbumItem.Picture; } var tileNotification = new TileNotification(tileXml); TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification); }
public static void UpdateBigTileWithVideoInfo() { const TileTemplateType template = TileTemplateType.TileWide310x150PeekImage05; var tileXml = TileUpdateManager.GetTemplateContent(template); var tileTextAttributes = tileXml.GetElementsByTagName("text"); #if WINDOWS_APP tileTextAttributes[0].InnerText = "Now playing"; #endif if (Locator.VideoVm.CurrentVideo != null) { tileTextAttributes[0].InnerText = Locator.VideoVm.CurrentVideo.Name; var tileImgAttribues = tileXml.GetElementsByTagName("image"); if (Locator.VideoVm.CurrentVideo != null) { tileImgAttribues[0].Attributes[1].NodeValue = Strings.VideoPicFolderPath + Locator.VideoVm.CurrentVideo.Id + ".jpg"; } } var tileNotification = new TileNotification(tileXml); TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification); }
public static void UpdateMediumTileWithVideoInfo() { LogHelper.Log("PLAYVIDEO: Updating Live Tile"); const TileTemplateType template = TileTemplateType.TileSquare150x150PeekImageAndText02; var tileXml = TileUpdateManager.GetTemplateContent(template); var tileTextAttributes = tileXml.GetElementsByTagName("text"); tileTextAttributes[0].InnerText = "playing"; if (Locator.VideoVm.CurrentVideo != null) { tileTextAttributes[1].InnerText = Locator.VideoVm.CurrentVideo.Name; var tileImgAttribues = tileXml.GetElementsByTagName("image"); if (Locator.VideoVm.CurrentVideo != null) { tileImgAttribues[0].Attributes[1].NodeValue = Strings.VideoPicFolderPath + Locator.VideoVm.CurrentVideo.Id + ".jpg"; } } var tileNotification = new TileNotification(tileXml); TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification); UpdateBigTileWithVideoInfo(); }
private async void ProcessPlaylist(Object sender, object e) { Debug.WriteLine("Timer"); PlaylistListBox.Items.Clear(); playList = await cloudtools.GetPlayList(); List <Playlist> OrderplayList = playList.OrderBy(o => o.State).ToList(); foreach (Playlist pl in OrderplayList) { String str = pl.SongName + "\n " + pl.ArtistName + "\n " + pl.AlbumName; PlaylistListBox.Items.Add(str); } if (PlaylistListBox.Items.Count > 0) { PlaylistListBox.SelectedIndex = 3; } TileTemplateType tileTemplate = TileTemplateType.TileSquare150x150Text03; XmlDocument tileXml = TileUpdateManager.GetTemplateContent(tileTemplate); XmlNodeList tileTextAttributes = tileXml.GetElementsByTagName("text"); tileTextAttributes[0].InnerText = "Current Song: \n" + PlaylistListBox.Items[3]; Int16 dueTimeInSeconds = 10; DateTime dueTime = DateTime.Now.AddSeconds(dueTimeInSeconds); ScheduledTileNotification scheduledTile = new ScheduledTileNotification(tileXml, dueTime); TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(scheduledTile); TileNotification tileNot = new TileNotification(tileXml); //tileNot.ExpirationTime = DateTimeOffset.UtcNow.AddSeconds(5); TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNot); }
public static void UpdateMediumTileWithMusicInfo() { const TileTemplateType template = TileTemplateType.TileSquare150x150PeekImageAndText02; var tileXml = TileUpdateManager.GetTemplateContent(template); var tileTextAttributes = tileXml.GetElementsByTagName("text"); tileTextAttributes[0].InnerText = "playing"; if (Locator.MusicPlayerVM.CurrentTrack != null) { tileTextAttributes[1].InnerText = Locator.MusicPlayerVM.CurrentTrack.Name + " - " + Locator.MusicPlayerVM.CurrentTrack.ArtistName; var tileImgAttribues = tileXml.GetElementsByTagName("image"); if (Locator.MusicPlayerVM.CurrentAlbum != null) { tileImgAttribues[0].Attributes[1].NodeValue = Locator.MusicPlayerVM.CurrentAlbum.AlbumCoverUri; } } var tileNotification = new TileNotification(tileXml); TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification); UpdateBigTileWithMusicInfo(); }
void GenerateTileImage(TileTemplateType templateType, float width, float height) { tiles.Add(templateType, GenerateAndSaveTileImage(device, width, height).Result); }
protected static XmlDocument GetTemplate(TileTemplateType templateType) { return(TileUpdateManager.GetTemplateContent(templateType)); }
public static string GetTemplateContent(TileTemplateType tileTemplateType) { var tileXml = TileUpdateManager.GetTemplateContent((Windows.UI.Notifications.TileTemplateType)tileTemplateType); return tileXml.GetXml(); }
public NotificationBuilder BuildWideTile(TileTemplateType tileTemplateType, IEnumerable <string> text, IEnumerable <string> images) { BuildTile(true, tileTemplateType, text, images); return(this); }
public static string GetTemplateContent(TileTemplateType tileTemplateType) { var tileXml = TileUpdateManager.GetTemplateContent((Windows.UI.Notifications.TileTemplateType)tileTemplateType); return(tileXml.GetXml()); }
public static string GetTemplateContent(TileTemplateType tileTemplateType) { return String.Empty; }
public static void UpdateTile(TileTemplateType tileTemplateType, string[] text, string[] images, DateTimeOffset? expirationTime) { }
public static void UpdateTile(TileTemplateType tileTemplateType, string[] text, string[] images) { UpdateTile(tileTemplateType, text, images, null); }
public static void UpdateTile(TileTemplateType tileTemplateType, string[] text, string[] images, DateTimeOffset? expirationTime) { // look for the templates on https://msdn.microsoft.com/en-us/library/windows/apps/Hh761491.aspx // all the nodes for supplying text are called "text". Conversely, everything with an image has a // tag called "image". This simplistic function simply searches all the XML nodes with "text" and replaces // them with the supplied text. Same for the images. var tileXml = TileUpdateManager.GetTemplateContent((Windows.UI.Notifications.TileTemplateType)tileTemplateType); if (text != null) { var textNodes = tileXml.GetElementsByTagName("text"); if (textNodes.Length != text.Length) { throw new ArgumentException("more text fields than supported by the template"); } for (int i = 0; i < textNodes.Length; i++) { textNodes[i].InnerText = text[i]; } } // for a text only template, images will not be supplied. if (images != null) { var imageNodes = tileXml.GetElementsByTagName("image"); if (images.Length != imageNodes.Length) { throw new ArgumentException("more images supplied than images"); } for (int j = 0; j < imageNodes.Length; j++) { imageNodes[j].Attributes.GetNamedItem("src").NodeValue = images[j]; } } var notification = new TileNotification(tileXml); if(expirationTime != null) { if(expirationTime > DateTimeOffset.Now) { notification.ExpirationTime = expirationTime; } } TileUpdateManager.CreateTileUpdaterForApplication().Update(notification); }
public TileNotificationBuilder(IEnumerable <string> texts, TileTemplateType type) : base(texts) { this.ImageUris = new List <string>(); this.Type = type; }
void UpdateTile(TileTemplateType templateType, string branding) { // This example uses the GetTemplateContent method to get the notification as xml instead of using NotificationExtensions. XmlDocument tileXml = TileUpdateManager.GetTemplateContent(templateType); XmlNodeList textElements = tileXml.GetElementsByTagName("text"); for (int i = 0; i < textElements.Length; i++) { string tileText = String.Empty; StackPanel panel = TextInputs.Children[i] as StackPanel; if (panel != null) { TextBox box = panel.Children[1] as TextBox; if (box != null) { tileText = box.Text; if (String.IsNullOrEmpty(tileText)) { tileText = "Text field " + i; } } } textElements.Item((uint)i).AppendChild(tileXml.CreateTextNode(tileText)); } XmlNodeList imageElements = tileXml.GetElementsByTagName("image"); for (int i = 0; i < imageElements.Length; i++) { XmlElement imageElement = (XmlElement)imageElements.Item((uint)i); string imageSource = String.Empty; StackPanel panel = ImageInputs.Children[i] as StackPanel; if (panel != null) { TextBox box = panel.Children[1] as TextBox; if (box != null) { imageSource = box.Text; if (String.IsNullOrEmpty(imageSource)) { imageSource = "ms-appx:///images/redWide310x150.png"; } } } imageElement.SetAttribute("src", imageSource); } // Set the branding on the notification as specified in the input. // The logo and display name are declared in the manifest. // Branding defaults to logo if omitted. XmlElement bindingElement = (XmlElement)tileXml.GetElementsByTagName("binding").Item(0); bindingElement.SetAttribute("branding", branding); // Set the language of the notification. Though this is optional, it is recommended to specify the language. string lang = Lang.Text; // this needs to be a BCP47 tag if (!String.IsNullOrEmpty(lang)) { // Specify the language of the text in the notification. // This ensures the correct font is used to render the text. XmlElement visualElement = (XmlElement)tileXml.GetElementsByTagName("visual").Item(0); visualElement.SetAttribute("lang", lang); } TileNotification tile = new TileNotification(tileXml); TileUpdateManager.CreateTileUpdaterForApplication().Update(tile); OutputTextBlock.Text = MainPage.PrettyPrint(tileXml.GetXml()); }
/// <summary> /// Initializes static members of the <see cref="TileHelper"/> class. /// </summary> /// <param name="tileTemplateType"> /// The tile Template Type. /// </param> /// <returns> /// The <see cref="BaseTile"/>. /// </returns> public static BaseTile GetTile(this TileTemplateType tileTemplateType) { return(new BaseTile(tileTemplateType)); }
static XmlDocument GenerateTileXml(string imageFileName, TileTemplateType template) { var tileXml = TileUpdateManager.GetTemplateContent(template); var images = tileXml.GetElementsByTagName("image"); var src = tileXml.CreateAttribute("src"); src.Value = "ms-appdata:///local/" + imageFileName; images[0].Attributes.SetNamedItem(src); return tileXml; }
public static void UpdateTile(TileTemplateType tileTemplateType, string[] text, string[] images) { }
public TileBindingTemplateBuilder(TileTemplateType tileTemplateteType, [System.Runtime.InteropServices.WindowsRuntime.ReadOnlyArray()] string[] notifications, string imageSource) { var tileXmlDocument = TileUpdateManager.GetTemplateContent(tileTemplateteType); var bindingXmlElements = tileXmlDocument.GetElementsByTagName("binding"); if (bindingXmlElements == null || bindingXmlElements.Count != 1) { throw new Exception("Invalid binding template"); } var bindingXmlElement = (XmlElement)bindingXmlElements[0]; this.SetImage(bindingXmlElement, imageSource); this.SetText(bindingXmlElement, notifications); System.Diagnostics.Debug.WriteLine(bindingXmlElement.GetXml()); this._bindingXmlElement = bindingXmlElement; }
private void BuildTile(bool isWide, TileTemplateType tileTemplateType, IEnumerable<string> text, IEnumerable<string> images) { Guard.False(isWide ? _WideTileSet : _SquareTileSet); Guard.NotNull(text, images); var templateName = tileTemplateType.ToString().ToUpperInvariant(); var containsString = isWide ? "WIDE" : "SQUARE"; //Wide tiles have "Wide" in their name while normal tiles have "Square" in their name. //Making sure that the proper templates are used. Guard.True(templateName.Contains(containsString)); var tileXml = TileUpdateManager.GetTemplateContent(tileTemplateType); Guard.NotNull(tileXml); UpdateTileText(tileXml, text); UpdateTileImages(tileXml, images); SetOrMergeTile(tileXml); if (isWide) { _WideTileSet = true; } else { _SquareTileSet = true; } }
public static void UpdateTile(TileTemplateType tileTemplateType, string[] text) { UpdateTile(tileTemplateType, text, null, null); }
private static void _updatePrimaryTile(string text, string imgSrc, string imgAlt, TileTemplateType templateType) { TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true); XmlDocument tileXml = TileUpdateManager.GetTemplateContent(templateType); //TileWide310x150ImageAndText01 //version XmlNodeList tileVersionAttributes = tileXml.GetElementsByTagName("visual"); ((XmlElement)tileVersionAttributes[0]).SetAttribute("version", "2"); //tileXml.FirstChild.FirstChild.Attributes[0].NodeValue = "2"; ////branding //XmlNodeList tileBindingAttributes = tileXml.GetElementsByTagName("binding"); //((XmlElement)tileBindingAttributes[0]).SetAttribute("branding", "logo"); //text XmlNodeList tileTextAttributes = tileXml.GetElementsByTagName("text"); if (tileTextAttributes.Count > 0) { tileTextAttributes[0].InnerText = text; } //tileTextAttributes[1].InnerText = "xxxxx"; //image XmlNodeList tileImageAttributes = tileXml.GetElementsByTagName("image"); ////image from apps package //((XmlElement)tileImageAttributes[0]).SetAttribute("src", "ms-appx:///assets/redWide.png"); //((XmlElement)tileImageAttributes[0]).SetAttribute("alt", "red graphic"); ////image from apps local storage //((XmlElement)tileImageAttributes[0]).SetAttribute("src", "ms-appdata:///local/redWide.png"); //((XmlElement)tileImageAttributes[0]).SetAttribute("alt", "red graphic"); ((XmlElement)tileImageAttributes[0]).SetAttribute("src", imgSrc); ((XmlElement)tileImageAttributes[0]).SetAttribute("alt", imgAlt); ////image from the web //((XmlElement)tileImageAttributes[0]).SetAttribute("src", "http://www.contoso.com/redWide.png"); //((XmlElement)tileImageAttributes[0]).SetAttribute("alt", "red graphic"); //create notifcation //TileNotification tileNotification = new TileNotification(tileXml); ScheduledTileNotification stn = new ScheduledTileNotification(tileXml, DateTimeOffset.Now.AddSeconds(8)); //notification expires in //tileNotification.ExpirationTime = DateTimeOffset.UtcNow.AddMinutes(10); //forced clear notification for app //Windows.UI.Notifications.TileUpdateManager.CreateTileUpdaterForApplication().Clear(); //send notification to app tile //TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification); TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(stn); }
public NotificationBuilder BuildWideTile(TileTemplateType tileTemplateType, IEnumerable<string> text, IEnumerable<string> images) { BuildTile(true, tileTemplateType, text, images); return this; }
INotificationBuilderSquareTileSet INotificationBuilderWideTileSet.BuildSquareTile(TileTemplateType tileTemplateType, IEnumerable<string> text, IEnumerable<string> images) { return BuildSquareTile(tileTemplateType, text, images); }