Exemplo n.º 1
0
        private static void AppendImageToNotification(ToastContent toastContent, XmlDocument xml)
        {
            var imageElements = xml.GetElementsByTagName(ImageNode);
            if (!imageElements.Any())
                return;

            ((XmlElement)imageElements[0]).SetAttribute(SrcAttr, toastContent.Image ?? string.Empty);
            ((XmlElement)imageElements[0]).SetAttribute(AltAttr, toastContent.AltText ?? string.Empty);
        }
Exemplo n.º 2
0
        private static ToastNotification BuildToastNotification(ToastContent toastContent)
        {
            var xml = ToastNotificationManager.GetTemplateContent(toastContent.ToastTemplateType);

            AppendLaunchArgumentToNotification(toastContent, xml);
            AppendImageToNotification(toastContent, xml);
            AppendTextElementsToNotification(toastContent, xml);

            return new ToastNotification(xml);
        }
Exemplo n.º 3
0
        private static void AppendTextElementsToNotification(ToastContent toastContent, XmlDocument xml)
        {
            var elements = xml.GetElementsByTagName(TextNode);

            var hasTitleOrContentElement = elements.Count == 1;
            var hasTitleAndContentElement = elements.Count == 2;
            var hasTitleContentAndSecondContentElement = elements.Count == 3;


            if (hasTitleOrContentElement || hasTitleAndContentElement)
                elements[0].InnerText = toastContent.Title ?? toastContent.Content ?? string.Empty;

            if (hasTitleAndContentElement)
                elements[0].InnerText = toastContent.Content ?? string.Empty;

            if (hasTitleContentAndSecondContentElement)
                elements[0].InnerText = toastContent.SecondContent ?? string.Empty;
        }
Exemplo n.º 4
0
 private static void AppendLaunchArgumentToNotification(ToastContent toastContent, XmlDocument xml)
 {
     if (!string.IsNullOrWhiteSpace(toastContent.LaunchArguments))
         xml.DocumentElement.SetAttribute(LaunchAttr, toastContent.LaunchArguments);
 }
Exemplo n.º 5
0
 public void ShowToast(ToastContent toastContent)
 {
     var toast = BuildToastNotification(toastContent);
     var notifier = ToastNotificationManager.CreateToastNotifier();
     notifier.Show(toast);
 }
Exemplo n.º 6
0
        public void ShowToastImageAndText04(string image, string altText, string title, string content, string content2, string arg = null)
        {
            var toast = ToastContent.CreateToastImageAndText04(image, altText, title, content, content2, arg);

            _helper.ShowToast(toast);
        }
Exemplo n.º 7
0
        public void ShowToastText04(string title, string content, string content2, string arg = null)
        {
            var toast = ToastContent.CreateToastText04(title, content, content2, arg);

            _helper.ShowToast(toast);
        }
Exemplo n.º 8
0
        public void ShowToastText01(string content, string arg = null)
        {
            var toast = ToastContent.CreateToastText01(content, arg);

            _helper.ShowToast(toast);
        }