private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            var date = MyDatePicker.Date;
            var time = MyHourPicker.Time;

            DateTime dateTime = new DateTime(date.Year, date.Month, date.Day, time.Hours, time.Minutes, time.Seconds);

            string title   = Title.Text;
            string content = Content.Text;


            ToastTemplateType toastType = ToastTemplateType.ToastText02;
            XmlDocument       toastXml  = ToastNotificationManager.GetTemplateContent(toastType);

            XmlNodeList toastTextElement = toastXml.GetElementsByTagName("text");

            toastTextElement[0].AppendChild(toastXml.CreateTextNode(title));
            toastTextElement[1].AppendChild(toastXml.CreateTextNode(content));

            IXmlNode toastNode = toastXml.SelectSingleNode("/toast");

            ((XmlElement)toastNode).SetAttribute("duration", "long");

            ScheduledToastNotification sheduledToast = new ScheduledToastNotification(toastXml, dateTime);

            sheduledToast.Id = IdService.GetNewId();


            ToastNotifier notifier =
                ToastNotificationManager.CreateToastNotifier();

            notifier.AddToSchedule(sheduledToast);

            NotificationItem notItem = new NotificationItem();

            notItem.Id           = sheduledToast.Id;
            notItem.Title        = title;
            notItem.Content      = content;
            notItem.DeliveryTime = dateTime;

            MainPage.NotificationList.Add(notItem);

            Frame.GoBack();

            //ShowMessage("Dodano powiadowmienie.");
        }
Example #2
0
        private void AddSheduleNotification()
        {
            string title   = Title.Text;
            string content = Content.Text;

            int seconds = PrepareTimeSpan();

            ToastTemplateType toastType = ToastTemplateType.ToastText02;
            XmlDocument       toastXml  = ToastNotificationManager.GetTemplateContent(toastType);

            XmlNodeList toastTextElement = toastXml.GetElementsByTagName("text");

            toastTextElement[0].AppendChild(toastXml.CreateTextNode(title));
            toastTextElement[1].AppendChild(toastXml.CreateTextNode(content));

            IXmlNode toastNode = toastXml.SelectSingleNode("/toast");

            ((XmlElement)toastNode).SetAttribute("duration", "long");

            ScheduledToastNotification sheduledToast = new ScheduledToastNotification(toastXml, DateTimeOffset.Now.AddSeconds(seconds));

            sheduledToast.Id = IdService.GetNewId();

            ToastNotifier notifier =
                ToastNotificationManager.CreateToastNotifier();

            notifier.AddToSchedule(sheduledToast);

            NotificationItem notItem = new NotificationItem();

            notItem.Title        = title;
            notItem.Content      = content;
            notItem.SecondsToEnd = seconds;
            notItem.Id           = sheduledToast.Id;

            MainPage.NotificationList.Add(notItem);

            Frame.GoBack();

            //ShowMessage("Dodano powiadowmienie.");
        }