//----------------------------------------------------------------------------------------------- void ScheduleToast(String updateString, DateTime dueTime, int idNumber) { // Scheduled toasts use the same toast templates as all other kinds of toasts. IToastText02 toastContent = ToastContentFactory.CreateToastText02(); toastContent.TextHeading.Text = updateString; if (drug.instruction == "No Instrucction") { toastContent.TextBodyWrap.Text = drug.name; } else { toastContent.TextBodyWrap.Text = drug.name+" : "+drug.instruction; } ScheduledToastNotification toast; toast = new ScheduledToastNotification(toastContent.GetXml(), dueTime); toast.Id = "Toast" + idNumber; ToastNotificationManager.CreateToastNotifier().AddToSchedule(toast); // NotifyUser("Scheduled a toast with ID: " + toast.Id, NotifyType.StatusMessage); myNotification m = new myNotification(); m.myShedule = toast; m.alarmId = maxid+1; a.shs.Add(toast.Id); ObservableCollection<myNotification> notifs = IsolatedStorageHelper.GetObject<ObservableCollection<myNotification>>("notifications"); notifs.Add(m); IsolatedStorageHelper.SaveObject<ObservableCollection<myNotification>>("notifications", notifs); }
//nouvel void ScheduleToastWithStringManipulation(string updateString, DateTime dueTime, int idNumber) { string drugnameandinformation; if (drug.instruction == "No Instrucction") { drugnameandinformation = drug.name; } else { drugnameandinformation = drug.name + " : " + drug.instruction; } // Scheduled toasts use the same toast templates as all other kinds of toasts. string toastXmlString = "<toast>" + "<visual version='2'>" + "<binding template='ToastText02'>" + "<text id='1'>" + updateString + "</text>" + "<text id='2'>" + drugnameandinformation + "</text>" + "</binding>" + "</visual>" + "</toast>"; Windows.Data.Xml.Dom.XmlDocument toastDOM = new Windows.Data.Xml.Dom.XmlDocument(); try { toastDOM.LoadXml(toastXmlString); ScheduledToastNotification toast; // toast = new ScheduledToastNotification(toastDOM, dueTime, TimeSpan.FromSeconds(60), 5); // You can specify an ID so that you can manage toasts later. // Make sure the ID is 15 characters or less. // toast.Id = "Repeat" + idNumber; toast = new ScheduledToastNotification(toastDOM, dueTime); toast.Id = "Toast" + idNumber; ToastNotificationManager.CreateToastNotifier().AddToSchedule(toast); // NotifyUser("Scheduled a toast with ID: " + toast.Id, NotifyType.StatusMessage); myNotification m = new myNotification(); m.myShedule = toast; m.alarmId = maxid + 1; a.shs.Add(toast.Id); ObservableCollection<myNotification> notifs = IsolatedStorageHelper.GetObject<ObservableCollection<myNotification>>("notifications"); notifs.Add(m); IsolatedStorageHelper.SaveObject<ObservableCollection<myNotification>>("notifications", notifs); // a.notifications.Add(toast); } catch (Exception) { // NotifyUser("Error loading the xml, check for invalid characters in the input", NotifyType.ErrorMessage); } }