public static void ToastMessage(string title, string message, string launchArgument = null) { if (title == null) { throw new ArgumentNullException(nameof(title)); } if (message == null) { throw new ArgumentNullException(nameof(message)); } try { var xmlDoc = NotificationContentBuilder.CreateSimpleToastNotification(title, message, launchArgument); if (xmlDoc != null) { ToastNotification notification = new ToastNotification(xmlDoc); ToastNotifier toastNotifier = ToastNotificationManager.CreateToastNotifier(); toastNotifier.Show(notification); } } catch (Exception ex) { // we might have an exception if the message is too long TrackingManagerHelper.Exception(ex, string.Format("ToastMessage exception: {0}", ex.Message)); } }
private void AddReminder(ITask task) { if (!task.Alarm.HasValue || task.Alarm.Value <= DateTime.Now) { LogService.Log("AlarmManager", "Cannot add reminder because alarm date is already past"); return; } var notification = NotificationContentBuilder.CreateTaskToastNotification(task); if (notification != null) { ScheduledToastNotification toast = new ScheduledToastNotification(notification, task.Alarm.Value) { Id = task.Id.ToString() }; var toastNotifier = this.CreateToastNotifier(); if (toastNotifier != null) { // check if a schedule notification does not already exist for this task var scheduledToastNotifications = toastNotifier.GetScheduledToastNotifications(); var existingNotification = scheduledToastNotifications.FirstOrDefault(n => n.Id == toast.Id); if (existingNotification != null) { toastNotifier.RemoveFromSchedule(existingNotification); } toastNotifier.AddToSchedule(toast); } } LogService.Log("AlarmManager", string.Format("Reminder of task {0} added for {1}", task.Title, task.Alarm.Value)); }
private void SetTileContent(ITask task, TileUpdater tileUpdater) { var tileNotification = NotificationContentBuilder.CreateTileNotificationForTask(task); if (tileNotification != null) { tileUpdater.Update(new TileNotification(tileNotification)); } }
private void SetTileContent(string title, IList <ITask> tasks, TileUpdater tileUpdater, IAbstractFolder folder = null) { var tileNotification = NotificationContentBuilder.CreateTileNotification(title, tasks, folder); if (tileNotification != null) { tileUpdater.Update(new TileNotification(tileNotification)); } }
protected override void BuildContent() { base.BuildContent(); foreach (var paragraph in _paragraphs) { NotificationContentBuilder.AddText(paragraph); PlainTextContentBuilder.AppendLine(paragraph); } }
public void CreateTileNotification_Html() { string content = "<html><div>Hello</div></html>"; var tileNotificationDoc = NotificationContentBuilder.CreateTileNotification(content, new List <ITask> { new Task { Title = content, Note = content } }, null); Assert.IsFalse(tileNotificationDoc.InnerText.Contains("html")); Assert.IsFalse(tileNotificationDoc.InnerText.Contains("div")); Assert.IsTrue(tileNotificationDoc.InnerText.Contains("Hello")); }
private static void CreateTileNotification(string content, int?maxSize = null) { var tileNotificationDoc = NotificationContentBuilder.CreateTileNotification(content, new List <ITask> { new Task { Title = content, Note = content } }, null); Assert.IsNotNull(tileNotificationDoc); CheckMaxSize(tileNotificationDoc, maxSize); var taskNotificationDoc = NotificationContentBuilder.CreateTaskToastNotification(new Task { Title = content, Note = content }); Assert.IsNotNull(taskNotificationDoc); CheckMaxSize(taskNotificationDoc, maxSize); var simpleDoc = NotificationContentBuilder.CreateSimpleToastNotification(content, content); Assert.IsNotNull(simpleDoc); CheckMaxSize(simpleDoc, maxSize); }
protected override void BuildContent() { base.BuildContent(); NotificationContentBuilder.AddLink(_linkHref, _linkText); PlainTextContentBuilder.AppendLine(_linkText).AppendLine(_linkHref); }
protected override void BuildContent() => NotificationContentBuilder.AddTitle(Subject);