예제 #1
0
        private void DeleteNotification()
        {
            if (NotificationListView.SelectedItem == null)
            {
                ShowMessage("Brak wybranego elementu.");
            }
            else
            {
                NotificationItem notItem = NotificationListView.SelectedItem as NotificationItem;
                String           id      = notItem.Id;

                ToastNotifier notifier =
                    ToastNotificationManager.CreateToastNotifier();

                List <ScheduledToastNotification> initialList = new List <ScheduledToastNotification>();
                initialList = notifier.GetScheduledToastNotifications().ToList();

                foreach (ScheduledToastNotification item in initialList)
                {
                    if (item.Id == id)
                    {
                        notifier.RemoveFromSchedule(item);
                        break;
                    }
                }

                NotificationList.Remove(notItem);
            }
        }
        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.");
        }
예제 #3
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.");
        }
예제 #4
0
        private List <NotificationItem> ParseInitialListToNotificationItemList(List <ScheduledToastNotification> list)
        {
            List <NotificationItem> notItemList = new List <NotificationItem>();

            foreach (ScheduledToastNotification item in list)
            {
                NotificationItem notItem = new NotificationItem();
                XmlDocument      docXml  = item.Content;

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

                notItem.Id      = item.Id;
                notItem.Title   = toastTextElement[0].FirstChild.InnerText;
                notItem.Content = toastTextElement[1].FirstChild.InnerText;

                notItem.DeliveryTime = item.DeliveryTime.DateTime;

                notItemList.Add(notItem);
            }

            return(notItemList);
        }