Nextrek
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
using ClassLibrary1;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.ApplicationModel.Background;
using Windows.Data.Xml.Dom;
using Windows.UI.Notifications;
namespace TileBackground
{
public sealed class TileBackgroundUpdater : IBackgroundTask
{
private TileUpdater tileUpdater;
public async void Run(IBackgroundTaskInstance taskInstance) {
BackgroundTaskDeferral deferral = taskInstance.GetDeferral();
tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();
tileUpdater.EnableNotificationQueue(true);
await DataLoader.loadJson();
int j=0;
int i = 0;
if (DataLoader.getSelectedChannels()[i].programs2Date.ContainsKey(DateTime.Now.Date))
{
while (j < 5)//5 tile al massimo. ognuno con 3 programmi
{
List<Program> plist = new List<Program>();
int k = 0;
while (k < 3)
{
DataLoader.getSelectedChannels()[i].highlightNowProgram();
plist.Add(DataLoader.getSelectedChannels()[i].nowProgram);
k++;
i++;
}
notifyLiveTile(plist);
j++;
}
}
deferral.Complete();
}
private void notifyLiveTile(List<Program> programs)
{
XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWideText07);
XmlDocument squareTileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquareText02);
XmlNodeList tileTextAttributes = tileXml.GetElementsByTagName("text");
XmlNodeList squareTileTextAttributes = squareTileXml.GetElementsByTagName("text");
tileTextAttributes[0].InnerText = "Ora in onda";
squareTileTextAttributes[0].InnerText = "In onda";
squareTileTextAttributes[1].InnerText = programs[0].parent.name.ToUpper() + " " + programs[0].title;
int i=1;
while(i<7){
tileTextAttributes[i].InnerText = programs[i / 2].parent.name;
tileTextAttributes[i+1].InnerText = programs[i / 2].title;
i += 2;
}
IXmlNode squareNode = tileXml.ImportNode(squareTileXml.GetElementsByTagName("binding")[0],true);
tileXml.GetElementsByTagName("visual")[0].AppendChild(squareNode);
TileNotification tileNotification = new TileNotification(tileXml);
tileNotification.ExpirationTime = DateTimeOffset.UtcNow.AddSeconds(600);
tileUpdater.Update(tileNotification);
}
}
}
|
Revision |
Author |
Commited |
Message |
21
|
JMBauan
|
Wed 26 Jun, 2013 10:48:36 +0000 |
|