Ejemplo n.º 1
0
        static IXmlNode GetNode(IXmlNodeList nodes, uint index)
        {
            IXmlNode node;

            ComFunctions.CheckHRESULT(nodes.Item(index, out node));
            return(node);
        }
Ejemplo n.º 2
0
        static IXmlNode AppendNode(IXmlNode parentNode, IXmlNode childNode)
        {
            IXmlNode appendedChild;

            ComFunctions.CheckHRESULT(parentNode.AppendChild(childNode, out appendedChild));
            return(appendedChild);
        }
Ejemplo n.º 3
0
        static IXmlElement CreateElement(IXmlDocument xmldoc, string elementName)
        {
            IXmlElement element;

            ComFunctions.CheckHRESULT(xmldoc.CreateElement(elementName, out element));
            return(element);
        }
Ejemplo n.º 4
0
        static void SetSound(IXmlDocument xmldoc, PredefinedSound sound)
        {
            string      soundXml = "ms-winsoundevent:" + sound.ToString().Replace("_", ".");
            IXmlElement soundElement;

            ComFunctions.CheckHRESULT(xmldoc.CreateElement("audio", out soundElement));
            if (sound == PredefinedSound.NoSound)
            {
                ComFunctions.CheckHRESULT(soundElement.SetAttribute("silent", "true"));
            }
            else
            {
                ComFunctions.CheckHRESULT(soundElement.SetAttribute("src", soundXml));
                ComFunctions.CheckHRESULT(soundElement.SetAttribute("loop", IsLoopingSound(sound).ToString().ToLower()));
            }
            var          asNode = (IXmlNode)xmldoc;
            IXmlNode     appendedChild;
            IXmlNodeList nodes;

            ComFunctions.CheckHRESULT(xmldoc.GetElementsByTagName("toast", out nodes));
            IXmlNode toastNode;

            ComFunctions.CheckHRESULT(nodes.Item(0, out toastNode));
            ComFunctions.CheckHRESULT(toastNode.AppendChild((IXmlNode)soundElement, out appendedChild));
        }
Ejemplo n.º 5
0
        static IXmlNodeList GetNodes(IXmlDocument xmldoc, string tagName)
        {
            IXmlNodeList nodes;

            ComFunctions.CheckHRESULT(xmldoc.GetElementsByTagName(tagName, out nodes));
            return(nodes);
        }
Ejemplo n.º 6
0
        static void SetNodeValueString(string str, IXmlDocument xmldoc, IXmlNode node)
        {
            IXmlText textNode;

            using (var hStrign_str = HSTRING.FromString(str))
                ComFunctions.CheckHRESULT(xmldoc.CreateTextNode(hStrign_str, out textNode));
            AppendNode(node, (IXmlNode)textNode);
        }
Ejemplo n.º 7
0
        static IXmlNodeList GetNodes(IXmlDocument xmldoc, string tagName)
        {
            IXmlNodeList nodes;

            using (var hStrign_tagName = HSTRING.FromString(tagName))
                ComFunctions.CheckHRESULT(xmldoc.GetElementsByTagName(hStrign_tagName, out nodes));
            return(nodes);
        }
Ejemplo n.º 8
0
        static void SetNodeValueString(string str, IXmlDocument xmldoc, IXmlNode node)
        {
            IXmlText textNode;
            int      res = xmldoc.CreateTextNode(str, out textNode);

            ComFunctions.CheckHRESULT(res);
            AppendNode(node, (IXmlNode)textNode);
        }
Ejemplo n.º 9
0
        static IXmlElement CreateElement(IXmlDocument xmldoc, string elementName)
        {
            IXmlElement element;

            using (var hStrign_elementName = HSTRING.FromString(elementName))
                ComFunctions.CheckHRESULT(xmldoc.CreateElement(hStrign_elementName, out element));
            return(element);
        }
Ejemplo n.º 10
0
        static void SetImageSrc(IXmlDocument xmldoc, string imagePath)
        {
            IXmlNode imageNode = GetNode(xmldoc, "image");
            IXmlNode srcAttribute;

            using (var hString_name = HSTRING.FromString("src"))
                ComFunctions.CheckHRESULT(imageNode.Attributes.GetNamedItem(hString_name, out srcAttribute));
            SetNodeValueString(imagePath, xmldoc, srcAttribute);
        }
Ejemplo n.º 11
0
        static void SetImageSrc(IXmlDocument xmldoc, string imagePath)
        {
            IXmlNode imageNode = GetNode(xmldoc, "image");
            IXmlNode srcAttribute;
            int      res = imageNode.Attributes.GetNamedItem("src", out srcAttribute);

            ComFunctions.CheckHRESULT(res);
            SetNodeValueString(imagePath, xmldoc, srcAttribute);
        }
Ejemplo n.º 12
0
        static void SetDuration(IXmlDocument xmldoc, NotificationDuration duration)
        {
            IXmlNodeList nodes;

            ComFunctions.CheckHRESULT(xmldoc.GetElementsByTagName("toast", out nodes));
            IXmlNode toastNode;

            ComFunctions.CheckHRESULT(nodes.Item(0, out toastNode));
            ((IXmlElement)toastNode).SetAttribute("duration", "long");
        }
Ejemplo n.º 13
0
        static void SetTextLine(IXmlDocument xmldoc, uint index, string text)
        {
            IXmlNodeList nodes;

            ComFunctions.CheckHRESULT(xmldoc.GetElementsByTagName("text", out nodes));
            Debug.Assert(nodes.Length >= index + 1);
            IXmlNode node;

            ComFunctions.CheckHRESULT(nodes.Item(index, out node));
            SetNodeValueString(text, xmldoc, node);
        }
        public Task <ToastNotificationResultInternal> ShowAsync()
        {
            if (Notification == null)
            {
                Notification = Adapter.Create(Content.Info);
            }
            Subscribe();
            var source = new TaskCompletionSource <ToastNotificationResultInternal>();

            Activated += (s, e) =>
            {
                Unsubscribe();
                source.SetResult(ToastNotificationResultInternal.Activated);
            };
            Dismissed += (s, e) =>
            {
                Unsubscribe();
                switch (e)
                {
                case ToastDismissalReason.ApplicationHidden:
                    source.SetResult(ToastNotificationResultInternal.ApplicationHidden);
                    break;

                case ToastDismissalReason.TimedOut:
                    source.SetResult(ToastNotificationResultInternal.TimedOut);
                    break;

                case ToastDismissalReason.UserCanceled:
                    source.SetResult(ToastNotificationResultInternal.UserCanceled);
                    break;
                }
            };
            Failed += (s, e) =>
            {
                Unsubscribe();
                if ((UInt32)e.ErrorCode == WPN_E_TOAST_NOTIFICATION_DROPPED)
                {
                    source.SetResult(ToastNotificationResultInternal.Dropped);
                }
                else
                {
                    source.SetException(e);
                }
            };
            ComFunctions.Safe(() => Adapter.Show(Notification),
                              ce =>
            {
                Unsubscribe();
                source.SetException(new ToastNotificationFailedException(ce, ce.ErrorCode));
            });
            return(source.Task);
        }
Ejemplo n.º 15
0
        static void SetNodeValueString(string str, IXmlDocument xmldoc, IXmlNode node)
        {
            IXmlText textNode;
            int      res = xmldoc.CreateTextNode(str, out textNode);

            ComFunctions.CheckHRESULT(res);

            IXmlNode textNodeAsNode = (IXmlNode)textNode;
            IXmlNode appendedChild;

            res = node.AppendChild(textNodeAsNode, out appendedChild);
            ComFunctions.CheckHRESULT(res);
        }
Ejemplo n.º 16
0
        static void SetImageSrc(IXmlDocument xmldoc, string imagePath)
        {
            IXmlNodeList nodes;
            int          res = xmldoc.GetElementsByTagName("image", out nodes);

            ComFunctions.CheckHRESULT(res);

            IXmlNode imageNode;

            res = nodes.Item(0, out imageNode);
            ComFunctions.CheckHRESULT(res);

            IXmlNode srcAttribute;

            res = imageNode.Attributes.GetNamedItem("src", out srcAttribute);
            ComFunctions.CheckHRESULT(res);

            SetNodeValueString(imagePath, xmldoc, srcAttribute);
        }
Ejemplo n.º 17
0
 static void SetAttribute(IXmlElement node, string attributeName, string attributeValue)
 {
     using (var hString_attributeName = HSTRING.FromString(attributeName))
         using (var hString_attributeValue = HSTRING.FromString(attributeValue))
             ComFunctions.CheckHRESULT(node.SetAttribute(hString_attributeName, hString_attributeValue));
 }
Ejemplo n.º 18
0
 static void SetAttribute(IXmlElement node, string attributeName, string attributeValue)
 {
     ComFunctions.CheckHRESULT(node.SetAttribute(attributeName, attributeValue));
 }