public async Task UpdateAsync(MessageItem messageItem)
 {
     var target = (from m in _messageItems
                   where m.ID == messageItem.ID
                   select m).FirstOrDefault();
     if (target != null)
     {
         int idx = _messageItems.IndexOf(target);
         _messageItems.Remove(target);
         _messageItems.Insert(idx, messageItem);
     }
     await PersistAsync();
 }
Beispiel #2
0
        private void DeliverToast(MessageItem msgItem)
        {
            // Send the Toast Notification informing the user of a new message
            ToastTemplateType toastTemplate = ToastTemplateType.ToastImageAndText01;
            XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate);

            XmlNodeList toastTextElements = toastXml.GetElementsByTagName("text");
            toastTextElements[0].AppendChild(toastXml.CreateTextNode(msgItem.Title));

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

            ((XmlElement)toastNode).SetAttribute("launch", "{\"type\":\"toast\",\"param1\":\"" + msgItem.ID + "\",\"param2\":\"0\"}");

            ToastNotification toast = new ToastNotification(toastXml);

            // Tag the Toast with the data item ID
            // Note that Toasts sent from servers set the Tag through an HTTP Header
            toast.Tag = msgItem.ID;

            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
 public async Task AddAsync(MessageItem messageItem)
 {
     _messageItems.Add(messageItem);
     await PersistAsync();
 }