예제 #1
0
        public static void UpdateLiveTile()
        {
            try
            {
                var tile          = new TileBinding();
                var photosContent = new TileBindingContentPhotos();

                var list = new HighlightImageService(null, null).GetImages(1, 5);
                foreach (var e in list)
                {
                    photosContent.Images.Add(new TileImageSource(e.Urls.Tile));
                }

                tile.Content = photosContent;

                var tileContent = new TileContent
                {
                    Visual = new TileVisual()
                };
                tileContent.Visual.Branding   = TileBranding.NameAndLogo;
                tileContent.Visual.TileMedium = tile;
                tileContent.Visual.TileWide   = tile;
                tileContent.Visual.TileLarge  = tile;

                TileUpdateManager.CreateTileUpdaterForApplication().Update(new TileNotification(tileContent.GetXml()));
            }
            catch (Exception e)
            {
                _ = Logger.LogAsync(e);
            }
        }
예제 #2
0
        public static async Task UpdateLiveTileAsync()
        {
            try
            {
                var tile          = new TileBinding();
                var photosContent = new TileBindingContentPhotos();

                var url = UnsplashImageFactory.CreateTodayHighlightImage().Urls.Full;

                photosContent.Images.Add(new TileImageSource(url));

                tile.Content = photosContent;

                var tileContent = new TileContent
                {
                    Visual = new TileVisual()
                };
                tileContent.Visual.Branding   = TileBranding.NameAndLogo;
                tileContent.Visual.TileMedium = tile;
                tileContent.Visual.TileWide   = tile;
                tileContent.Visual.TileLarge  = tile;

                await ClearAllTileFile();

                TileUpdateManager.CreateTileUpdaterForApplication().Clear();
                TileUpdateManager.CreateTileUpdaterForApplication().Update(
                    new TileNotification(tileContent.GetXml()));
            }
            catch (Exception e)
            {
                var task = Logger.LogAsync(e);
            }
        }
예제 #3
0
        /// <summary>
        /// Generates a <see cref="TileBindingContentPhotos"/> for a given list of image URLs.
        /// </summary>
        /// <param name="urls">
        ///     A <see cref="List{string}"/> containing the URLs to use for the tile images. May be app-relative or internet URLs.
        /// </param>
        /// <param name="maxCount">The maximum number of images to use for this particular binding size.</param>
        /// <returns></returns>
        private static TileBinding GetPhotosBinding(List <string> urls, int maxCount = 12)
        {
            var content = new TileBindingContentPhotos();

            foreach (var url in urls.Take(maxCount))
            {
                content.Images.Add(new TileImageSource(url));
            }

            return(new TileBinding()
            {
                Content = content
            });
        }
예제 #4
0
 private static TileBinding GenerateImageTileBinding(params string[] urls)
 {
     if (urls != null && urls.Length > 0)
     {
         var tile    = new TileBinding();
         var content = new TileBindingContentPhotos();
         if (urls != null && urls.Length > 0)
         {
             urls.ForEach(x =>
             {
                 content.Images.Add(new TileBasicImage()
                 {
                     Source = x
                 });
             });
         }
         tile.Content = content;
         return(tile);
     }
     return(null);
 }
예제 #5
0
        public static async Task UpdateImagesTileAsync(IEnumerable <string> imagesFilePath)
        {
            try
            {
                var tile          = new TileBinding();
                var photosContent = new TileBindingContentPhotos();

                var maxCount = imagesFilePath.Count() >= 9 ? 9 : imagesFilePath.Count();
                for (int i = 0; i < maxCount; i++)
                {
                    var path = imagesFilePath.ElementAt(i);
                    if (string.IsNullOrEmpty(path))
                    {
                        continue;
                    }
                    photosContent.Images.Add(new TileImageSource(path));
                }
                tile.Content = photosContent;

                Debug.WriteLine("Photos size is " + photosContent.Images.Count);

                var tileContent = new TileContent();
                tileContent.Visual            = new TileVisual();
                tileContent.Visual.Branding   = TileBranding.NameAndLogo;
                tileContent.Visual.TileMedium = tile;
                tileContent.Visual.TileWide   = tile;
                tileContent.Visual.TileLarge  = tile;

                await ClearAllTileFile();

                TileUpdateManager.CreateTileUpdaterForApplication().Clear();
                TileUpdateManager.CreateTileUpdaterForApplication().Update(
                    new TileNotification(tileContent.GetXml()));
            }
            catch (Exception e)
            {
                var task = ExceptionHelper.WriteRecordAsync(e, nameof(LiveTileUpdater), nameof(UpdateImagesTileAsync));
            }
        }
예제 #6
0
        private TileContent GetTileContent(IEnumerable <string> images)
        {
            var tileImages = images
                             .Select(ToThumbnail)
                             .Select(i => new TileBasicImage()
            {
                Source = i
            })
                             .Take(9);

            var photosContent = new TileBindingContentPhotos();

            foreach (var tileBasicImage in tileImages)
            {
                photosContent.Images.Add(tileBasicImage);
            }

            TileContent content = new TileContent()
            {
                Visual = new TileVisual()
                {
                    TileMedium = new TileBinding()
                    {
                        Content = photosContent
                    },
                    TileWide = new TileBinding {
                        Content = photosContent
                    },
                    TileLarge = new TileBinding {
                        Content = photosContent
                    }
                }
            };

            return(content);
        }
예제 #7
0
파일: Tile.cs 프로젝트: zxw567/Aurora.Music
        public static void UpdateImage(string id, IList <string> images, string title, string desc)
        {
            var photosBinding = new TileBindingContentPhotos();

            foreach (var item in images)
            {
                photosBinding.Images.Add(new TileBasicImage()
                {
                    Source = item
                });
            }
            var imageTile = new TileContent()
            {
                Visual = new TileVisual()
                {
                    Branding    = TileBranding.NameAndLogo,
                    DisplayName = Consts.Localizer.GetString("AppNameText"),
                    TileMedium  = new TileBinding()
                    {
                        Content = photosBinding
                    },
                    TileLarge = new TileBinding()
                    {
                        Content = photosBinding
                    },
                    TileWide = new TileBinding()
                    {
                        Content = photosBinding
                    }
                }
            };



            var tileContent = new TileContent()
            {
                Visual = new TileVisual()
                {
                    DisplayName = Consts.Localizer.GetString("AppNameText"),
                    TileMedium  = new TileBinding()
                    {
                        Content = new TileBindingContentAdaptive()
                        {
                            TextStacking = TileTextStacking.Center,
                            Children     =
                            {
                                new AdaptiveText()
                                {
                                    Text         = title,
                                    HintStyle    = AdaptiveTextStyle.Caption,
                                    HintWrap     = true,
                                    HintMaxLines = 2,
                                    HintAlign    = AdaptiveTextAlign.Center
                                },
                                new AdaptiveText()
                                {
                                    Text      = desc,
                                    HintStyle = AdaptiveTextStyle.CaptionSubtle,
                                    HintWrap  = true,
                                    HintAlign = AdaptiveTextAlign.Center
                                }
                            }
                        }
                    },
                    TileWide = new TileBinding()
                    {
                        Content = new TileBindingContentAdaptive()
                        {
                            TextStacking = TileTextStacking.Center,
                            Children     =
                            {
                                new AdaptiveGroup()
                                {
                                    Children =
                                    {
                                        new AdaptiveSubgroup()
                                        {
                                            HintWeight = 1,
                                            Children   =
                                            {
                                                new AdaptiveImage()
                                                {
                                                    Source = images[0]
                                                }
                                            }
                                        },
                                        new AdaptiveSubgroup()
                                        {
                                            HintWeight       = 2,
                                            HintTextStacking = AdaptiveSubgroupTextStacking.Center,
                                            Children         =
                                            {
                                                new AdaptiveText()
                                                {
                                                    Text         = title,
                                                    HintStyle    = AdaptiveTextStyle.Base,
                                                    HintWrap     = true,
                                                    HintMaxLines = 2
                                                },
                                                new AdaptiveText()
                                                {
                                                    Text      = desc,
                                                    HintStyle = AdaptiveTextStyle.CaptionSubtle,
                                                    HintWrap  = true
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    TileLarge = new TileBinding()
                    {
                        Content = new TileBindingContentAdaptive()
                        {
                            TextStacking = TileTextStacking.Center,
                            Children     =
                            {
                                new AdaptiveGroup()
                                {
                                    Children =
                                    {
                                        new AdaptiveSubgroup()
                                        {
                                            HintWeight = 1
                                        },
                                        new AdaptiveSubgroup()
                                        {
                                            HintWeight = 2,
                                            Children   =
                                            {
                                                new AdaptiveImage()
                                                {
                                                    Source = images[0]
                                                }
                                            }
                                        },
                                        new AdaptiveSubgroup()
                                        {
                                            HintWeight = 1
                                        }
                                    }
                                },
                                new AdaptiveText()
                                {
                                    Text         = title,
                                    HintStyle    = AdaptiveTextStyle.Base,
                                    HintMaxLines = 2,
                                    HintWrap     = true,
                                    HintAlign    = AdaptiveTextAlign.Center
                                },
                                new AdaptiveText()
                                {
                                    Text      = desc,
                                    HintStyle = AdaptiveTextStyle.CaptionSubtle,
                                    HintWrap  = true,
                                    HintAlign = AdaptiveTextAlign.Center
                                }
                            }
                        }
                    }
                }
            };

            if (SecondaryTile.Exists(id))
            {
                // Get its updater
                var updater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(id);

                // Clear all old tile
                var old = updater.GetScheduledTileNotifications();
                foreach (var o in old)
                {
                    updater.RemoveFromSchedule(o);
                }

                updater.EnableNotificationQueue(true);

                var noti = new ScheduledTileNotification(imageTile.GetXml(), DateTime.Now.AddSeconds(5));
                // And send the notification
                updater.AddToSchedule(noti);


                noti = new ScheduledTileNotification(tileContent.GetXml(), DateTime.Now.AddSeconds(5));
                // And send the notification
                updater.AddToSchedule(noti);
            }
        }