public static void ShowInstantMessageNotification(string fromName, string fromUserId, string imageUri, string message)
        {
            var toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastImageAndText02);

            // Set Text
            var toastTextElements = toastXml.GetElementsByTagName("text");
            toastTextElements[0].AppendChild(toastXml.CreateTextNode(fromName));
            toastTextElements[1].AppendChild(toastXml.CreateTextNode(message));

            // Set image
            var toastImageAttribute = toastXml.GetElementsByTagName("image").Select(s => ((XmlElement) s)).First();
            toastImageAttribute.SetAttribute("src", imageUri);
            toastImageAttribute.SetAttribute("alt", "logo");

            // toast duration
            var toastNode = toastXml.SelectSingleNode("/toast");
            var xmlElement = (XmlElement) toastNode;
            xmlElement?.SetAttribute("duration", "short");

            ToastNotificationLaunchArguments args = new ToastNotificationLaunchArguments(NotificationType.InstantMessage);
            args.arguments.Add(ArgumentType.FromId, fromUserId);

            xmlElement?.SetAttribute("launch", args.ToXmlString());

            ShowNotification(toastXml);
        }
        public static void ShowInstantMessageNotification(string fromName, string fromUserId, string imageUri, string message)
        {
            var toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastImageAndText02);

            // Set Text
            var toastTextElements = toastXml.GetElementsByTagName("text");

            toastTextElements[0].AppendChild(toastXml.CreateTextNode(fromName));
            toastTextElements[1].AppendChild(toastXml.CreateTextNode(message));

            // Set image
            var toastImageAttribute = toastXml.GetElementsByTagName("image").Select(s => ((XmlElement)s)).First();

            toastImageAttribute.SetAttribute("src", imageUri);
            toastImageAttribute.SetAttribute("alt", "logo");

            // toast duration
            var toastNode  = toastXml.SelectSingleNode("/toast");
            var xmlElement = (XmlElement)toastNode;

            xmlElement?.SetAttribute("duration", "short");

            ToastNotificationLaunchArguments args = new ToastNotificationLaunchArguments(NotificationType.InstantMessage);

            args.arguments.Add(ArgumentType.FromId, fromUserId);

            xmlElement?.SetAttribute("launch", args.ToXmlString());

            ShowNotification(toastXml);
        }
Beispiel #3
0
        public static ToastNotificationLaunchArguments FromXmlString(string xmlString)
        {
            ToastNotificationLaunchArguments result = null;

            try
            {
                result = XmlDataContractSerializationHelper.FromXml <ToastNotificationLaunchArguments>(xmlString);
            }
            catch (Exception)
            {
                result = null;
            }
            return(result);
        }
Beispiel #4
0
 private void ProcessLaunchArgument(ToastNotificationLaunchArguments launchArg)
 {
     if (launchArg != null)
     {
         switch (launchArg.type)
         {
             case NotificationType.InstantMessage:
                 Container.Resolve<MainViewModel>().ContactsViewModel.SelectConversation(
                     (string)launchArg.arguments[ArgumentType.FromId]);
                 break;
         }
     }
 }