Пример #1
0
        public static void UpdateBadgeGlyph(BadgeGlyph glyph)
        {
            // Create the badge updater for the application
            BadgeUpdater updater = BadgeUpdateManager.CreateBadgeUpdaterForApplication();

            if (glyph == BadgeGlyph.None)
            {
                updater.Clear();
            }
            else
            {
                // Get the blank badge XML payload for a badge number
                XmlDocument badgeXml = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeGlyph);

                // Set the value of the badge in the xml to our number
                XmlElement badgeElem = badgeXml.SelectSingleNode("/badge") as XmlElement;
                badgeElem.SetAttribute("value", glyph.DescriptionAttr());

                // Create the badge notification
                BadgeNotification badge = new BadgeNotification(badgeXml)
                {
                    ExpirationTime = DateTimeOffset.UtcNow.AddMinutes(10)
                };
                // And update the badge
                updater.Update(badge);
            }
        }
Пример #2
0
        public static void SendBadgeNotification(BadgeGlyph value)
        {
            string xml1     = @"<badge value='";
            string xml2     = @"' />";
            var    badgeXml = new Windows.Data.Xml.Dom.XmlDocument();

            badgeXml.LoadXml(xml1 + value.ToString() + xml2);

            var badge = new BadgeNotification(badgeXml);

            BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badge);

            // Create a badge notification from the XML content.
            string payload = App.GetString("/TileTemplates/Iconic");
            var    tileXml = new Windows.Data.Xml.Dom.XmlDocument();

            tileXml.LoadXml(payload);
            var badgeNotification = new TileNotification(tileXml);

            TileUpdateManager.CreateTileUpdaterForApplication().Update(badgeNotification);
        }
Пример #3
0
        /// <summary>
        /// Creates a badge notification with the required glyph.
        /// </summary>
        /// <param name="glyph">Glyph to show on the badge.
        /// None will hide the badge.</param>
        /// <returns></returns>
        /// <remarks>
        /// <para/><list type="table">
        /// <listheader><term>Platform</term><description>Version supported</description></listheader>
        /// <item><term>macOS</term><description>OS X 10.7 and later</description></item>
        /// <item><term>Windows UWP</term><description>Windows 10</description></item>
        /// <item><term>Windows Store</term><description>Windows 8.1 or later</description></item>
        /// <item><term>Windows Phone Store</term><description>Windows Phone 8.1 or later</description></item>
        /// <item><term>Windows Phone Silverlight</term><description>Windows Phone 8.1 or later</description></item></list>
        /// </remarks>
        public static BadgeNotification CreateBadgeNotification(BadgeGlyph glyph)
        {
#if WINDOWS_UWP || WINDOWS_APP || WINDOWS_PHONE_APP || WINDOWS_PHONE_81
            XmlDocument doc           = Windows.UI.Notifications.BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeGlyph);
            var         badgeElements = doc.GetElementsByTagName("badge");
            badgeElements[0].Attributes[0].InnerText = glyph.ToString().ToLower();
            return(new Windows.UI.Notifications.BadgeNotification(doc));
#elif __MAC__
            switch (glyph)
            {
            case BadgeGlyph.Alert:
                return(new BadgeNotification('*'));

            case BadgeGlyph.Attention:
                return(new BadgeNotification('!'));
            }

            return(new BadgeNotification(0));
#else
            throw new PlatformNotSupportedException();
#endif
        }
        /// <summary>
        /// Creates a badge notification with the required glyph.
        /// </summary>
        /// <param name="glyph">Glyph to show on the badge.
        /// None will hide the badge.</param>
        /// <returns></returns>
        /// <remarks>
        /// <para/><list type="table">
        /// <listheader><term>Platform</term><description>Version supported</description></listheader>
        /// <item><term>macOS</term><description>OS X 10.7 and later</description></item>
        /// <item><term>Windows UWP</term><description>Windows 10</description></item>
        /// <item><term>Windows Store</term><description>Windows 8.1 or later</description></item>
        /// <item><term>Windows Phone Store</term><description>Windows Phone 8.1 or later</description></item>
        /// <item><term>Windows Phone Silverlight</term><description>Windows Phone 8.1 or later</description></item></list>
        /// </remarks>
        public static BadgeNotification CreateBadgeNotification(BadgeGlyph glyph)
        {
#if WINDOWS_UWP || WINDOWS_APP || WINDOWS_PHONE_APP || WINDOWS_PHONE_81
            XmlDocument doc = Windows.UI.Notifications.BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeGlyph);
            var badgeElements = doc.GetElementsByTagName("badge");
            badgeElements[0].Attributes[0].InnerText = glyph.ToString().ToLower();
            return new BadgeNotification(new Windows.UI.Notifications.BadgeNotification(doc));
#elif __MAC__
            switch(glyph)
            {
                case BadgeGlyph.Alert:
                    return new BadgeNotification('*');

                case BadgeGlyph.Attention:
                    return new BadgeNotification('!');
            }

            return new BadgeNotification(0);
#else
            throw new PlatformNotSupportedException();
#endif
        }
Пример #5
0
 public static void UpdateBadgeGlyph(this Page page, BadgeGlyph glyph) => UpdateBadgeGlyph(glyph);
Пример #6
0
 public BadgeNotificationBuilder(BadgeGlyph glyph)
 {
     this.Glyph    = glyph;
     this.HasGlyph = true;
 }