嗨,我需要每分钟更新一次磁贴的图像,但我找不到任何解决方案。我已经看过这个,但我无法让它工作。
瓦片中的图像从网络加载两次,但之后不再加载;如何每分钟更新磁贴中的图像?
例如:在这里,我的磁贴和数字是网络服务器上的图像,我需要每分钟用任何新图像刷新这个图像。
public static void CreateSchedule()
{
var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();
var plannedUpdated = tileUpdater.GetScheduledTileNotifications();
DateTime now = DateTime.Now;
DateTime planTill = now.AddHours(4);
string src1 = "http://mysite/squareLogo128.png";
DateTime updateTime = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, 0).AddMinutes(1);
if (plannedUpdated.Count > 0)
updateTime = plannedUpdated.Select(x => x.DeliveryTime.DateTime).Union(new [] { updateTime }).Max();
string xml = "<tile>"
+ "<visual>"
+ "<binding template='TileWideImageAndText01'>"
+ "<text id='1'>This tile notification uses web images</text>"
+ "<image id='1' src='" + src1 + "' alt='Web image'/>"
+ "</binding>"
+ "<binding template='TileSquareImage'>"
+ "<image id='1' src='" + src1 + "' alt='Web image'/>"
+ "</binding>"
+ "</visual>"
+ "</tile>";
XmlDocument documentNow = new XmlDocument();
documentNow.LoadXml(xml);
tileUpdater.Update(new TileNotification(documentNow) { ExpirationTime = now.AddMinutes(1) });
for (var startPlanning = updateTime; startPlanning < planTill; startPlanning = startPlanning.AddMinutes(1))
{
Debug.WriteLine(startPlanning);
Debug.WriteLine(planTill);
try
{
string src2 = "http://mysite/squareLogo128.png";
string xml2 = "<tile>"
+ "<visual>"
+ "<binding template='TileWideImageAndText01'>"
+ "<text id='1'>This tile notification uses web images</text>"
+ "<image id='1' src='" + src2 + "' alt='Web image'/>"
+ "</binding>"
+ "<binding template='TileSquareImage'>"
+ "<image id='1' src='" + src2 + "' alt='Web image'/>"
+ "</binding>"
+ "</visual>"
+ "</tile>";
XmlDocument document = new XmlDocument();
document.LoadXml(xml2);
ScheduledTileNotification scheduledNotification = new ScheduledTileNotification(document, new DateTimeOffset(startPlanning)) { ExpirationTime = startPlanning.AddMinutes(1) };
tileUpdater.AddToSchedule(scheduledNotification);
}
catch (Exception e)
{
}
}
}