コード例 #1
0
        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;
            }
        }
コード例 #2
0
 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);
        }
コード例 #5
0
        /// <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;
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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());
        }
コード例 #8
0
ファイル: Service.cs プロジェクト: liquidboy/X
        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);

        }
コード例 #9
0
        /// <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));
        }
コード例 #10
0
        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);
        }
コード例 #12
0
ファイル: Tiles.cs プロジェクト: yazici/unityplugins
        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);
        }
コード例 #13
0
 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)
     {
     }
 }
コード例 #14
0
        /// <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);
        }
コード例 #15
0
        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);
        }
コード例 #16
0
        /// <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);
        }
コード例 #17
0
        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);
        }
コード例 #18
0
        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);
        }
コード例 #19
0
        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);
        }
コード例 #20
0
        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();
        }
コード例 #21
0
        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);
        }
コード例 #22
0
        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();
        }
コード例 #23
0
 void GenerateTileImage(TileTemplateType templateType, float width, float height)
 {
     tiles.Add(templateType, GenerateAndSaveTileImage(device, width, height).Result);
 }
コード例 #24
0
 protected static XmlDocument GetTemplate(TileTemplateType templateType)
 {
     return(TileUpdateManager.GetTemplateContent(templateType));
 }
コード例 #25
0
ファイル: Tiles.cs プロジェクト: JeffreyKimani/unityplugins
 public static string GetTemplateContent(TileTemplateType tileTemplateType)
 {
     var tileXml = TileUpdateManager.GetTemplateContent((Windows.UI.Notifications.TileTemplateType)tileTemplateType);
     return tileXml.GetXml();
 }
コード例 #26
0
 public NotificationBuilder BuildWideTile(TileTemplateType tileTemplateType, IEnumerable <string> text, IEnumerable <string> images)
 {
     BuildTile(true, tileTemplateType, text, images);
     return(this);
 }
コード例 #27
0
ファイル: Tiles.cs プロジェクト: yazici/unityplugins
        public static string GetTemplateContent(TileTemplateType tileTemplateType)
        {
            var tileXml = TileUpdateManager.GetTemplateContent((Windows.UI.Notifications.TileTemplateType)tileTemplateType);

            return(tileXml.GetXml());
        }
コード例 #28
0
ファイル: Tiles.cs プロジェクト: JeffreyKimani/unityplugins
 public static string GetTemplateContent(TileTemplateType tileTemplateType)
 {
     return String.Empty;
 }
コード例 #29
0
 void GenerateTileImage(TileTemplateType templateType, float width, float height)
 {
     tiles.Add(templateType, GenerateAndSaveTileImage(device, width, height).Result);
 }
コード例 #30
0
ファイル: Tiles.cs プロジェクト: JeffreyKimani/unityplugins
 public static void UpdateTile(TileTemplateType tileTemplateType, string[] text, string[] images, DateTimeOffset? expirationTime)
 {
 }
コード例 #31
0
ファイル: Tiles.cs プロジェクト: JeffreyKimani/unityplugins
 public static void UpdateTile(TileTemplateType tileTemplateType, string[] text, string[] images)
 {
     UpdateTile(tileTemplateType, text, images, null);
 }
コード例 #32
0
ファイル: Tiles.cs プロジェクト: JeffreyKimani/unityplugins
        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;
 }
コード例 #34
0
        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());
        }
コード例 #35
0
 /// <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));
 }
コード例 #36
0
        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;
        }
コード例 #37
0
ファイル: Tiles.cs プロジェクト: JeffreyKimani/unityplugins
 public static void UpdateTile(TileTemplateType tileTemplateType, string[] text, string[] images)
 {
 }
コード例 #38
0
        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;
        }
コード例 #39
0
        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());
        }
コード例 #40
0
        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;
            }
        }
コード例 #41
0
ファイル: Tiles.cs プロジェクト: JeffreyKimani/unityplugins
 public static void UpdateTile(TileTemplateType tileTemplateType, string[] text)
 {
     UpdateTile(tileTemplateType, text, null, null);
 }
コード例 #42
0
ファイル: Tiles.cs プロジェクト: yazici/unityplugins
 public static void UpdateTile(TileTemplateType tileTemplateType, string[] text)
 {
     UpdateTile(tileTemplateType, text, null, null);
 }
コード例 #43
0
        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);
        }
コード例 #44
0
 public NotificationBuilder BuildWideTile(TileTemplateType tileTemplateType, IEnumerable<string> text, IEnumerable<string> images)
 {
     BuildTile(true, tileTemplateType, text, images);
     return this;
 }
コード例 #45
0
 INotificationBuilderSquareTileSet INotificationBuilderWideTileSet.BuildSquareTile(TileTemplateType tileTemplateType, IEnumerable<string> text, IEnumerable<string> images)
 {
     return BuildSquareTile(tileTemplateType, text, images);
 }
コード例 #46
0
ファイル: Tiles.cs プロジェクト: yazici/unityplugins
 public static void UpdateTile(TileTemplateType tileTemplateType, string[] text, string[] images)
 {
     UpdateTile(tileTemplateType, text, images, null);
 }