Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using NotificationsExtensions.TileContent;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net.Http;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Xml.Linq;
- using Windows.ApplicationModel.Background;
- using Windows.UI.Notifications;
- namespace CineBlog.Background
- {
- public sealed class LiveTileTask : IBackgroundTask
- {
- public async void Run(IBackgroundTaskInstance taskInstance)
- {
- var deferral = taskInstance.GetDeferral();
- var client = new HttpClient();
- var request = new HttpRequestMessage(HttpMethod.Get, "http://www.cineblog01.eu/feed/");
- var response = await client.SendAsync(request);
- var content = await response.Content.ReadAsStringAsync();
- var document = XDocument.Parse(content);
- var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();
- tileUpdater.EnableNotificationQueue(true);
- var index = 0;
- foreach (var item in document.Descendants("item"))
- {
- var title = item.Descendants("title").FirstOrDefault().Value;
- var description = item.Descendants("description").FirstOrDefault().Value;
- var thumbnail = Regex.Match(description, "<img.+?src=[\"'](.+?)[\"'].*?>").Groups[1].Value;
- var tileLargeContent = TileContentFactory.CreateTileSquare310x310ImageAndTextOverlay01();
- tileLargeContent.Image.Src = thumbnail;
- tileLargeContent.TextHeadingWrap.Text = title;
- var tileWideContent = TileContentFactory.CreateTileWide310x150PeekImage03();
- tileWideContent.Image.Src = thumbnail;
- tileWideContent.TextHeadingWrap.Text = title;
- //var tileMediumContent = TileContentFactory.CreateTileSquare150x150PeekImageAndText04();
- //tileMediumContent.Image.Src = thumbnail;
- //tileMediumContent.TextBodyWrap.Text = title;
- var tileMediumContent = TileContentFactory.CreateTileSquare150x150PeekImageAndText02();
- tileMediumContent.Image.Src = thumbnail;
- tileMediumContent.TextHeading.Text = title;
- tileWideContent.Square150x150Content = tileMediumContent;
- tileLargeContent.Wide310x150Content = tileWideContent;
- var liveTile = tileLargeContent.CreateNotification();
- liveTile.Tag = "tile" + index;
- tileUpdater.Update(liveTile);
- index++;
- }
- deferral.Complete();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement