public static void CreateTileNotification(Task taskInstance)
        {
            var tile = AdaptiveTile.CreateTile();
            var binding = TileBinding.Create(TemplateType.TileWide);
            binding.Branding = Branding.None;
            var subgroup = new SubGroup();

            if (!string.IsNullOrWhiteSpace(taskInstance.title)) {
                var header = new Text(taskInstance.title) { Style = TextStyle.Body };
                subgroup.AddText(header);
            }

            if (taskInstance.deadline != null) {
                var dateTime = new Text(taskInstance.deadline.ToString()) { Style = TextStyle.Body, IsNumeralStyle = true };
                subgroup.AddText(dateTime);
            }

            if (taskInstance.classTarget != null) {
                var classRoom = new Text(taskInstance.classTarget.ToString()) { Style = TextStyle.Caption, IsSubtleStyle = true };
                subgroup.AddText(classRoom);
            }

            if (taskInstance.description != null) {
                var description = new Text(taskInstance.description);
                subgroup.AddText(description);
            }

            binding.Add(subgroup);

            tile.Tiles.Add(binding);
            TileNotification tn = tile.GetNotification();

            tn.ExpirationTime = new DateTimeOffset(taskInstance.deadline);
            TileUpdateManager.CreateTileUpdaterForApplication().Update(tn);
        }
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     if (e.Parameter != null) {
         taskInstance = (Task)e.Parameter;
         textBoxTaskTitle.Text = taskInstance.title;
         datePickerDeadline.Date = taskInstance.deadline.Date;
         timePickerDeadline.Time = taskInstance.deadline.TimeOfDay;
         comboBoxClass.SelectedIndex = Data.classes.FindIndex(x => x == taskInstance.classTarget);
         sliderNotify.Value = taskInstance.notifyInDays;
         textBoxDescription.Text = taskInstance.description;
         buttonDelete.Visibility = Visibility.Visible;
     }
 }
示例#3
0
 public static void ArchiveTask(Task task) {
     int index = tasks.FindIndex(x => x.uid == task.uid);
     dataStore.archivedTasks.Add(tasks[index]);
     tasks.RemoveAt(index);
     dataStore.Save();
 }
示例#4
0
 public static void AddTask(Task task) {
     tasks.Add(task);
     dataStore.Save();
 }
示例#5
0
 string WriteiCalEvent(string iCal, Task tInstance, DateTime now, DateTime semestrEnd) {
     string Event = WNLiCal("BEGIN:VEVENT");
     if (tInstance.classTarget != null) {
         Event += WNLiCal("SUMMARY:" + tInstance.title + "(" + tInstance.classTarget.shortName + ")");
         Event += WNLiCal("DESCRIPTION:" + tInstance.classTarget.ToString() + @"\n" + tInstance.description);
     }
     else {
         Event += WNLiCal("SUMMARY:" + tInstance.title);
         Event += WNLiCal("DESCRIPTION:" + tInstance.description);
     }
     Event += WNLiCal("DTSTART:" + ToICalDateFormat(tInstance.deadline));
     Event += WNLiCal("DTEND:" + ToICalDateFormat(tInstance.deadline));
     if (tInstance.notifyInDays > 0) {
         Event += WNLiCal("BEGIN:VALARM");
         Event += WNLiCal("ACTION:DISPLAY");
         Event += WNLiCal("DESCRIPTION:This is an event reminder");
         Event += WNLiCal("TRIGGER:-P" + tInstance.notifyInDays + "D");
         Event += WNLiCal("END:VALARM");
     }
     Event += WNLiCal("END:VEVENT");
     return Event;
 }
示例#6
0
 public static void DeleteTask(Task task) {
     dataStore.tasks.Remove(task);
     dataStore.Save();
 }
        private void Ok_Click(object sender, RoutedEventArgs e)
        {
            if (Validate()) {
                DateTimeOffset dto = datePickerDeadline.Date;
                TimeSpan ts = timePickerDeadline.Time;
                DateTime dateTime = new DateTime(dto.Year, dto.Month, dto.Day, ts.Hours, ts.Minutes, ts.Seconds);

                if (taskInstance != null) {
                    taskInstance = Data.tasks.Find(x => x.uid == taskInstance.uid);
                    taskInstance.title = textBoxTaskTitle.Text;
                    taskInstance.description = textBoxDescription.Text;
                    taskInstance.deadline = dateTime;
                    taskInstance.notifyInDays = (int)sliderNotify.Value;
                    taskInstance.classTarget = (Class)comboBoxClass.SelectedItem;
                    Data.Save();
                }
                else {
                    taskInstance = new Task(
                        textBoxTaskTitle.Text,
                        textBoxDescription.Text,
                        dateTime,
                        (int)sliderNotify.Value,
                        (Class)comboBoxClass.SelectedItem);
                    Data.AddTask(taskInstance);
                }

                NotificationManager.RemoveScheduledNotification(taskInstance);
                if (sliderNotify.Value != 0)
                    NotificationManager.CreateTileNotification(taskInstance);

                BackgroundTasks.LiveTileBackgroundUpdater.PrepareLiveTile();

                Frame.GoBack();
            }
        }
        public static void ScheduleToastNotification(Task taskInstance)
        {
            DateTime notificationTime = taskInstance.deadline.AddDays(-taskInstance.notifyInDays);
            if (notificationTime <= DateTime.Now) return;
            XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
            XmlNodeList toastTextAttributes = toastXml.GetElementsByTagName("text");
            toastTextAttributes[0].InnerText = taskInstance.title;
            toastTextAttributes[1].InnerText = taskInstance.description;
            IXmlNode toastNode = toastXml.SelectSingleNode("/toast");
            ((XmlElement)toastNode).SetAttribute("duration", "long");
            ((XmlElement)toastNode).SetAttribute("launch", JsonConvert.SerializeObject(new LaunchData(taskInstance.GetType(), taskInstance.uid)));

            ScheduledToastNotification scheduledToast = new ScheduledToastNotification(toastXml, notificationTime);
            scheduledToast.Id = taskInstance.uid.Substring(0, 12);

            ToastNotificationManager.CreateToastNotifier().AddToSchedule(scheduledToast);
        }
        public static void RemoveScheduledNotification(Task taskInstance)
        {
            var notifier = ToastNotificationManager.CreateToastNotifier();
            var scheduled = notifier.GetScheduledToastNotifications();

            for (int i = 0; i < scheduled.Count; i++) {
                if (scheduled[i].Id == taskInstance.uid.Substring(0, 12)) {
                    notifier.RemoveFromSchedule(scheduled[i]);
                    break;
                }
            }
        }
示例#10
0
 public DisplayClass(Task taskInstance)
 {
     this.taskInstance = taskInstance;
 }