// 更新所有的 SecondaryTile 通知 private async void btnUpdateSecondaryTile_Click(object sender, RoutedEventArgs e) { IReadOnlyList <SecondaryTile> secondaryTileList = await SecondaryTile.FindAllAsync(); foreach (var secondaryTile in secondaryTileList) { // 用于描述 tile 通知的 xml 字符串 string tileXml = $@" <tile> <visual> <binding template='TileSmall'> <text>Small(小){DateTime.Now.ToString("HH:mm:ss")}</text> </binding> <binding template='TileMedium'> <text>Medium(中){DateTime.Now.ToString("HH:mm:ss")}</text> </binding> <binding template='TileWide'> <text>Wide(宽){DateTime.Now.ToString("HH:mm:ss")}</text> </binding> <binding template='TileLarge'> <text>Large(大){DateTime.Now.ToString("HH:mm:ss")}</text> </binding> </visual> </tile>"; // 将 xml 字符串转换为 Windows.Data.Xml.Dom.XmlDocument 对象 XmlDocument tileDoc = new XmlDocument(); tileDoc.LoadXml(tileXml); // 获取此 tile 的 xml // lblMsg.Text = tileDoc.GetXml(); // 实例化 TileNotification 对象 TileNotification tileNotification = new TileNotification(tileDoc); DateTimeOffset expirationTime = DateTimeOffset.UtcNow.AddSeconds(30); tileNotification.ExpirationTime = expirationTime; // 30 秒后清除这个 tile // 将指定的 TileNotification 对象更新到 secondary tile TileUpdater tileUpdater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(secondaryTile.TileId); tileUpdater.EnableNotificationQueue(true); // 启用 tile 的队列功能(最多可容纳 5 个 tile) tileUpdater.Update(tileNotification); // 更新此 SecondaryTile 对象的相关信息 secondaryTile.Arguments = $"Arguments(TileId: {secondaryTile.TileId}){DateTime.Now.ToString("HH:mm:ss")}"; bool success = await secondaryTile.UpdateAsync(); } }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override void OnLaunched(LaunchActivatedEventArgs e) { TileUpdater tileUpdate = TileUpdateManager.CreateTileUpdaterForApplication(); tileUpdate.EnableNotificationQueue(true); tileUpdate.Clear(); #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { this.DebugSettings.EnableFrameRateCounter = true; } #endif SQLiteService.LoadDatabase(); Frame rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (e.PrelaunchActivated == false) { if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Navigate(typeof(MainPage), e.Arguments); } // Ensure the current window is active Window.Current.Activate(); } }
void UpdateTile(string printerName, string bidiMessage) { TileUpdater tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication(); tileUpdater.Clear(); XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWideText09); XmlNodeList tileTextAttributes = tileXml.GetElementsByTagName("text"); tileTextAttributes[0].InnerText = printerName; tileTextAttributes[1].InnerText = bidiMessage; TileNotification tileNotification = new TileNotification(tileXml); tileNotification.Tag = "tag01"; tileUpdater.Update(tileNotification); }
public static void CreateSchedule(int cinemaid = -1) { TileUpdater updater = TileUpdateManager.CreateTileUpdaterForApplication(); foreach (var item in updater.GetScheduledTileNotifications()) { if (DateTime.Now > item.ExpirationTime) { updater.RemoveFromSchedule(item); } } IReadOnlyList <ScheduledTileNotification> scheduledTileNotifications = updater.GetScheduledTileNotifications(); DateTime time = DateTime.Now; DateTime time2 = time.AddHours(2.0); DateTime time3 = new DateTime(time.Year, time.Month, time.Day, time.Hour, time.Minute, 0).AddMinutes(1.0); if (scheduledTileNotifications.Count > 0) { DateTime dtTemp = scheduledTileNotifications[scheduledTileNotifications.Count - 1].DeliveryTime.DateTime.AddMinutes(1); if (dtTemp > time3) { time3 = dtTemp; } } string format = "<tile><visual><binding template=\"TileSquareImage\"><image id=\"1\" src=\"{0}\"/></binding></visual></tile>"; for (DateTime time4 = time3; time4 < time2; time4 = time4.AddMinutes(1.0)) { try { List <Uri> uris = App.GetRandomImages(cinemaid); string str2 = string.Format(format, uris[0], uris[1], uris[2], uris[3], uris[4]); XmlDocument document = new XmlDocument(); document.LoadXml(str2); ScheduledTileNotification notification2 = new ScheduledTileNotification(document, new DateTimeOffset(time4)); notification2.ExpirationTime = (new DateTimeOffset?((DateTimeOffset)time4.AddMinutes(1.0))); ScheduledTileNotification notification = notification2; updater.AddToSchedule(notification); } catch (Exception) { } } }
public static void CreateSecondTileNotifications(string tileId, string imageUri, string text, string subText) { TileUpdater notifier = TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileId); if (notifier.Setting == NotificationSetting.Enabled) { notifier.EnableNotificationQueue(true); var SquareTemplate = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquarePeekImageAndText03); SquareTemplate.GetElementsByTagName("image")[0].Attributes[1].NodeValue = imageUri; SquareTemplate.GetElementsByTagName("text")[0].AppendChild(SquareTemplate.CreateTextNode(text)); SquareTemplate.GetElementsByTagName("text")[1].AppendChild(SquareTemplate.CreateTextNode(subText)); var tileNotification = new TileNotification(SquareTemplate); notifier.Update(tileNotification); } }
private void Button_Click_1(object sender, RoutedEventArgs e) { //Tile test ... var tileContent = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquareBlock); tileLines = tileContent.SelectNodes("tile/visual/binding/text"); tileLines[0].InnerText = inputBox.Text.Substring(0, 2); notification = new TileNotification(tileContent); updater = TileUpdateManager.CreateTileUpdaterForApplication(); //updater.EnableNotificationQueue(true); MakeRequests(inputBox.Text); xivelyOutput.Text = "Requested " + inputBox.Text + " from Xively at " + "" + DateTime.Now.ToString("hh:mm:ss"); }
private void load() { string titleString = File.ReadAllText("title.xml"); Windows.Data.Xml.Dom.XmlDocument doc = new Windows.Data.Xml.Dom.XmlDocument(); doc.LoadXml(titleString); Windows.Data.Xml.Dom.XmlNodeList titles = doc.GetElementsByTagName("text"); TileUpdateManager.CreateTileUpdaterForApplication().Clear(); TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true); for (int i = 0; i < ViewModel.AllItems.Count; i++) { titles[0].InnerText = titles[2].InnerText = titles[4].InnerText = ViewModel.AllItems[i].title; titles[1].InnerText = titles[3].InnerText = titles[5].InnerText = ViewModel.AllItems[i].description; var tileNotification = new TileNotification(doc); TileUpdater updater = TileUpdateManager.CreateTileUpdaterForApplication(); updater.Update(tileNotification); } }
protected override Task Execute(CancellationToken cancellationToken) { return(Task.Run(async delegate { TileUpdater updater = TileUpdateManager.CreateTileUpdaterForApplication(); cancellationToken.ThrowIfCancellationRequested(); TileHelper.ClearScheduledNotifications(updater); cancellationToken.ThrowIfCancellationRequested(); var desiredTileNotifications = await GenerateDesiredTileNotifications(cancellationToken); cancellationToken.ThrowIfCancellationRequested(); if (desiredTileNotifications.Count == 0) { // Only call clear if we're not updating with anything else. // Because there's a good chance the tile is actually already up-to-date, and the notification that we // place there is just going to be a duplicate of the existing. If you called clear, then the UI would clear // the tile and then animate to display the new (same) content. Skipping the call to clear, the UI notices that the // new notification is the same and doesn't display it, leading to a better experience. updater.Clear(); } else { foreach (var desired in desiredTileNotifications) { cancellationToken.ThrowIfCancellationRequested(); // If it's set to be displayed in the past, or now (or super soon), we'll update immediately, since scheduling something // for a time that has already passed throws an exception if (desired.DeliveryTime < DateTimeOffset.Now.AddSeconds(5)) { updater.Update(new TileNotification(desired.Content)); } else { updater.AddToSchedule(new ScheduledTileNotification(desired.Content, desired.DeliveryTime)); } } } })); }
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); }
public void ClearTileStatus(string Id) { XParameter TileParam = XReg.Parameter(Id); if (TileParam == null) { return; } string TileId = TileParam.GetValue("tileId"); try { TileUpdater Updater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(TileId); Updater.Clear(); Updater.EnableNotificationQueue(false); } catch (Exception) { } }
/// <summary> /// Updates the tile. /// </summary> /// <param name="media"> /// The media. /// </param> public static void UpdateTile() { TileUpdater theTile = TileUpdateManager.CreateTileUpdaterForApplication(); theTile.EnableNotificationQueue(true); // Generate the tile notification content and update the tile TileContent content = GenerateTileContent(DV.MediaDV.GetRandomFromCollection(null).DeRef); theTile.Update(new TileNotification(content.GetXml())); content = GenerateTileContent(DV.MediaDV.GetRandomFromCollection(null).DeRef); theTile.Update(new TileNotification(content.GetXml())); content = GenerateTileContent(DV.MediaDV.GetRandomFromCollection(null).DeRef); theTile.Update(new TileNotification(content.GetXml())); // TileUpdateManager.CreateTileUpdaterForSecondaryTile(tile.TileId).Update(new TileNotification(content.GetXml())); }
/// <summary> /// Update the main tile with next visits. /// </summary> /// <param name="visits">Visits collection.</param> public async void UpdateMainTile(IList <Visit> visits) { if (visits.Any()) { tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication(); tileUpdater.Clear(); tileUpdater.EnableNotificationQueue(true); var i = 0; foreach (var visit in visits) { var visitItem = new VisitItem(visit, 0); await CreateTile(visitItem, string.Format("mainTile_{0}.jpg", i.ToString())); i++; } } }
// BeginCutPaste private void Button_Tapped(object sender, TappedRoutedEventArgs e) { if (!String.IsNullOrEmpty(this.notificationTextBox.Text)) { string xml = "<tile><visual version=\"2\">" + "<binding template=\"TileSquare150x150Text04\" " + "fallback=\"TileSquareText04\" branding=\"None\">" + "<text id=\"1\">" + this.notificationTextBox.Text + "</text></binding>" + "</visual></tile>"; XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); TileNotification tileNotification = new TileNotification(doc); TileUpdater tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication(); tileUpdater.Update(tileNotification); } }
private void TileUpdate(String text) { StringBuilder sb = new StringBuilder("<tile>"); sb.Append("<visual version=\"2\">"); sb.Append("<binding template=\"TileSquare150x150Text04\" fallback=\"TileSquareText04\">"); sb.Append("<image id=\"1\" src=\"ms-appx:///Assets/Logo.scale-240.png\"/>"); sb.Append("<text id='1'>" + text + "</text>"); sb.Append("</binding>"); sb.Append("</visual>"); sb.Append("</tile>"); XmlDocument xmldoc = new XmlDocument(); xmldoc.LoadXml(sb.ToString()); TileNotification tileNotification = new TileNotification(xmldoc); TileUpdater tileUpdator = TileUpdateManager.CreateTileUpdaterForApplication(); tileUpdator.Update(tileNotification); }
protected override void OnLaunched(LaunchActivatedEventArgs e) { tileUpdate = GetTileUpdater(); tileUpdate.EnableNotificationQueue(true); tileUpdate.Clear(); Frame rootFrame = Window.Current.Content as Frame; Windows.UI.Core.SystemNavigationManager.GetForCurrentView().BackRequested += BackRequested; // 不要在窗口已包含内容时重复应用程序初始化, // 只需确保窗口处于活动状态 if (rootFrame == null) { // 创建要充当导航上下文的框架,并导航到第一页 rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: 从之前挂起的应用程序加载状态 } // 将框架放在当前窗口中 Window.Current.Content = rootFrame; } if (e.PrelaunchActivated == false) { if (rootFrame.Content == null) { // 当导航堆栈尚未还原时,导航到第一页, // 并通过将所需信息作为导航参数传入来配置 // 参数 rootFrame.Navigate(typeof(LoginPage), e.Arguments); } // 确保当前窗口处于活动状态 Window.Current.Activate(); rootFrame.Navigated += OnNavigated; } }
private void zmienlivetitle(object sender, RoutedEventArgs e) { var template = TileContentFactory.CreateTileSquare150x150PeekImageAndText01(); template.TextBody1.Text = "Wow ale super"; template.TextBody2.Text = "na"; template.TextBody3.Text = "150x150"; template.Image.Src = "ms-appx:///Assets/aaa.scale-400.png"; var wideTemlate = TileContentFactory.CreateTileWide310x150PeekImageAndText01(); wideTemlate.TextBodyWrap.Text = "WoW WoW 310x150"; wideTemlate.Image.Src = "ms-appx:///Assets/aaa.scale-400.png"; wideTemlate.Square150x150Content = template; TileNotification wideNotification = wideTemlate.CreateNotification(); TileUpdater updater = TileUpdateManager.CreateTileUpdaterForApplication(); updater.Update(wideNotification); }
/// <summary> /// Método que configura a URL das live tiles do aplicativo. /// </summary> public static void CreateTile() { var uris = new List <Uri>(); for (int i = 0; i < 5; i++) { uris.Add(new Uri("http://" + backendUrl + "notifications/tiles/tile.php" + finalUrl + "&tile=" + i)); } TileUpdater LiveTileUpdater = TileUpdateManager.CreateTileUpdaterForApplication(); LiveTileUpdater.Clear(); LiveTileUpdater.EnableNotificationQueue(true); LiveTileUpdater.StartPeriodicUpdateBatch(uris, PeriodicUpdateRecurrence.Daily); BadgeUpdater BadgeUpdater = BadgeUpdateManager.CreateBadgeUpdaterForApplication(); BadgeUpdater.Clear(); BadgeUpdater.StartPeriodicUpdate(new Uri("http://" + backendUrl + "notifications/tiles/badge.php" + finalUrl), PeriodicUpdateRecurrence.Daily); }
public void tile() { Windows.Data.Xml.Dom.XmlDocument xdoc = new Windows.Data.Xml.Dom.XmlDocument(); xdoc.LoadXml(File.ReadAllText("tile.xml")); Windows.Data.Xml.Dom.XmlNodeList tilelist = xdoc.GetElementsByTagName("text"); tilelist[0].InnerText = title.Text; tilelist[2].InnerText = title.Text; tilelist[4].InnerText = title.Text; tilelist[1].InnerText = describe.Text; tilelist[3].InnerText = describe.Text; tilelist[5].InnerText = describe.Text; tilelist[6].InnerText = title.Text; tilelist[7].InnerText = describe.Text; TileNotification notification = new TileNotification(xdoc); TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true); TileUpdater updater = TileUpdateManager.CreateTileUpdaterForApplication(); updater.Update(notification); }
/// <summary> /// Opdaterer applikationstile med nyheder til finansstyring. /// </summary> /// <param name="nyheder">Nyheder til finansstyring.</param> private static void UpdateTile(IEnumerable <INyhedModel> nyheder) { if (nyheder == null) { throw new ArgumentNullException(nameof(nyheder)); } TileUpdater tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication(); tileUpdater.EnableNotificationQueue(true); tileUpdater.Clear(); foreach (IGrouping <DateTime, INyhedModel> nyhedsgruppe in nyheder.Where(m => string.IsNullOrEmpty(m.Nyhedsinformation) == false).OrderByDescending(m => m.Nyhedsudgivelsestidspunkt.Date).Take(5).GroupBy(m => m.Nyhedsudgivelsestidspunkt.Date)) { foreach (INyhedModel nyhed in nyhedsgruppe.OrderByDescending(m => m.Nyhedsaktualitet)) { tileUpdater.Update(UpdateTile(nyhed, TileTemplateType.TileSquare150x150Text04)); tileUpdater.Update(UpdateTile(nyhed, TileTemplateType.TileWide310x150BlockAndText02)); } } }
void UpdateTile(IEnumerable <FlickrPhotoResult> results) { TileUpdater tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication(); tileUpdater.EnableNotificationQueue(true); foreach (FlickrPhotoResult result in results) { XmlDocument xmlTileContent = TileUpdateManager.GetTemplateContent( TileTemplateType.TileWide310x150ImageAndText01); TemplateUtility.CompleteTemplate( xmlTileContent, new string[] { result.Title }, new string[] { result.ImageUrl }); TileNotification notification = new TileNotification(xmlTileContent); tileUpdater.Update(notification); } }
public void UpdateSecondaryTile(string tileID, string backtitle, string backcontent) { if (string.IsNullOrEmpty(tileID) || string.IsNullOrEmpty(backcontent)) { return; } if (!SecondaryTile.Exists(tileID)) { return; } var tileContent = TileContentFactory.CreateTileSquare150x150PeekImageAndText02(); tileContent.TextHeading.Text = backtitle; tileContent.TextBodyWrap.Text = backcontent; tileContent.Image.Src = "ms-appx:///Assets/Tile150x150.png"; var tileNotification = tileContent.CreateNotification(); TileUpdater updater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileID); updater.EnableNotificationQueue(false); updater.Update(tileNotification); }
public static void UpdateTile() { TileUpdater updater = TileUpdateManager.CreateTileUpdaterForApplication(); updater.EnableNotificationQueue(true); updater.Clear(); SetBadgeCountOnTile(MainPage.ViewModel1.AllItems.Count); int count = 0; foreach (var item in MainPage.ViewModel1.AllItems) { count++; XmlDocument xmlDoc = CreateTiles(item); TileNotification notification = new TileNotification(xmlDoc); updater.Update(notification); if (count == 5) { break; } } }
// 更新 application tile 的数据 private void btnUpdateTile_Click(object sender, RoutedEventArgs e) { // 用于描述 tile 通知的 xml 字符串 string tileXml = $@" <tile> <visual> <binding template='TileSmall'> <text>Small(小){DateTime.Now.ToString("HH:mm:ss")}</text> </binding> <binding template='TileMedium'> <text>Medium(中){DateTime.Now.ToString("HH:mm:ss")}</text> </binding> <binding template='TileWide'> <text>Wide(宽){DateTime.Now.ToString("HH:mm:ss")}</text> </binding> <binding template='TileLarge'> <text>Large(大){DateTime.Now.ToString("HH:mm:ss")}</text> </binding> </visual> </tile>"; // 将 xml 字符串转换为 Windows.Data.Xml.Dom.XmlDocument 对象 XmlDocument tileDoc = new XmlDocument(); tileDoc.LoadXml(tileXml); // 获取此 tile 的 xml // lblMsg.Text = tileDoc.GetXml(); // 实例化 TileNotification 对象 TileNotification tileNotification = new TileNotification(tileDoc); DateTimeOffset expirationTime = DateTimeOffset.UtcNow.AddSeconds(30); tileNotification.ExpirationTime = expirationTime; // 30 秒后清除这个 tile // 将指定的 TileNotification 对象更新到 application tile TileUpdater tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication(); tileUpdater.EnableNotificationQueue(true); // 启用 tile 的队列功能(最多可容纳 5 个 tile) tileUpdater.Update(tileNotification); }
private static void UpdateScheduledNotifications(TileUpdater updater, Countdown countdown, DateTime now) { var start = now.Date + countdown.Date.TimeOfDay; if (start < now) { start = start.AddDays(1); } var scheduledNotifications = updater.GetScheduledTileNotifications(); if (scheduledNotifications.Count > 0) { var latest = scheduledNotifications.Max(x => x.DeliveryTime.DateTime); if (latest > start) { start = latest; } } var name = countdown.Name; var imageUri = countdown.GetImageFileUri(); var diff = (start.Date - now.Date).TotalDays; if (diff < MaxScheduledNotifications) { var end = start.AddDays(MaxScheduledNotifications - diff); for (var plan = start; plan <= end; plan = plan.AddDays(1)) { var daysRemaining = countdown.GetDaysRemaining(plan); var content = CreateTileContent(name, imageUri, daysRemaining); var notification = new ScheduledTileNotification(content, plan); updater.AddToSchedule(notification); } } }
public async void registerBackgroundTask() { try { var result = await BackgroundExecutionManager.RequestAccessAsync(); if (result == BackgroundAccessStatus.AllowedMayUseActiveRealTimeConnectivity || result == BackgroundAccessStatus.AllowedWithAlwaysOnRealTimeConnectivity) { foreach (var task in BackgroundTaskRegistration.AllTasks) { if (task.Value.Name == TASK_NAME) { task.Value.Unregister(true); } } BackgroundTaskBuilder builder = new BackgroundTaskBuilder(); builder.Name = TASK_NAME; builder.TaskEntryPoint = TASK_ENTRY; builder.SetTrigger(new TimeTrigger(15, false)); var registration = builder.Register(); } for (int i = 0; i < 5; i++) { Uri u = new Uri("ms-appx:///tile/TileTemplate" + new Random().Next(1, 3).ToString() + ".xml"); StorageFile xmlFile = await StorageFile.GetFileFromApplicationUriAsync(u); XmlDocument doc = await XmlDocument.LoadFromFileAsync(xmlFile); TileNotification notifi = new TileNotification(doc); TileUpdater udt = TileUpdateManager.CreateTileUpdaterForApplication(); udt.Update(notifi); } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.Message); } }
private static void Schedule(TileUpdater updater, XmlDocument content, DateTime deliveryTime, DateTime?expirationTime) { if (deliveryTime == null || deliveryTime < DateTime.Now.AddSeconds(30)) { var tileNotif = new TileNotification(content); if (expirationTime != null) { tileNotif.ExpirationTime = expirationTime; } updater.Update(tileNotif); } else { var scheduledNotif = new ScheduledTileNotification(content, deliveryTime); if (expirationTime != null) { scheduledNotif.ExpirationTime = expirationTime; } updater.AddToSchedule(scheduledNotif); } }
// 添加指定的 ScheduledTileNotification 到指定的 secondary tile 的计划列表中 private void btnAddScheduledTile_Click(object sender, RoutedEventArgs e) { string tileXml = $@" <tile> <visual> <binding template='TileSmall'> <text>Small(小){DateTime.Now.ToString("HH:mm:ss")}</text> </binding> <binding template='TileMedium'> <text>Medium(中){DateTime.Now.ToString("HH:mm:ss")}</text> </binding> <binding template='TileWide'> <text>Wide(宽){DateTime.Now.ToString("HH:mm:ss")}</text> </binding> <binding template='TileLarge'> <text>Large(大){DateTime.Now.ToString("HH:mm:ss")}</text> </binding> </visual> </tile>"; XmlDocument tileDoc = new XmlDocument(); tileDoc.LoadXml(tileXml); // 实例化 ScheduledTileNotification 对象(15 秒后显示此 Tile 通知) DateTime dt = DateTime.Now.AddSeconds(15); ScheduledTileNotification tileNotification = new ScheduledTileNotification(tileDoc, dt); tileNotification.Id = new Random().Next(100000, 1000000).ToString();; tileNotification.Tag = $"在 {dt.ToString("HH:mm:ss")} 时显示此 tile 通知"; // 将指定的 ScheduledTileNotification 对象添加进指定的 secondary tile 的计划列表 TileUpdater tileUpdater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(TILEID); tileUpdater.AddToSchedule(tileNotification); tileUpdater.EnableNotificationQueue(true); // 启用 tile 的队列功能(最多可容纳 5 个 tile) ShowScheduledTiles(); }
// 删除指定 secondary tile 的指定 ScheduledTileNotification 对象 private void btnRemoveScheduledTile_Click(object sender, RoutedEventArgs e) { string notificationId = (string)(sender as FrameworkElement).Tag; // 获取指定 secondary tile 的全部 ScheduledTileNotification 对象列表 TileUpdater tileUpdater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(TILEID); IReadOnlyList <ScheduledTileNotification> notifications = tileUpdater.GetScheduledTileNotifications(); int notificationCount = notifications.Count; for (int i = 0; i < notificationCount; i++) { if (notifications[i].Id == notificationId) { // 从计划列表中移除指定的 ScheduledTileNotification 对象 tileUpdater.RemoveFromSchedule(notifications[i]); break; } } ShowScheduledTiles(); }
public MainPage() { this.InitializeComponent(); var tileContent = TileContentFactory.CreateTileSquare150x150Text01(); tileContent.TextHeading.Text = "Hello!"; tileContent.TextBody1.Text = "One"; tileContent.TextBody2.Text = "Two"; tileContent.TextBody3.Text = "Three"; XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(tileContent.ToString()); TileUpdater tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication(); tileUpdater.Update( new TileNotification(xmlDocument) { }); }
public App() { InitializeComponent(); SplashFactory = e => new Splash(e); // ensure unobserved task exceptions (unawaited async methods returning Task or Task<T>) are handled TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException; // ensure general app exceptions are handled Application.Current.UnhandledException += App_UnhandledException; // Init HockeySDK if (!string.IsNullOrEmpty(ApplicationKeys.HockeyAppToken)) { HockeyClient.Current.Configure(ApplicationKeys.HockeyAppToken); } // Set this in the instance constructor to prevent the creation of an unnecessary static constructor. _displayRequest = new DisplayRequest(); // Initialize the Live Tile Updater. LiveTileUpdater = TileUpdateManager.CreateTileUpdaterForApplication(); }