Esempio n. 1
0
        public static void UpdateTile(int value)
        {
            var type     = BadgeTemplateType.BadgeNumber;
            var xml      = BadgeUpdateManager.GetTemplateContent(type);
            var elements = xml.GetElementsByTagName("badge");
            var element  = elements[0] as XmlElement;

            element.SetAttribute("value", value.ToString());

            var updater      = BadgeUpdateManager.CreateBadgeUpdaterForApplication();
            var notification = new BadgeNotification(xml);

            updater.Update(notification);

            Debug.WriteLine("Background task badge updated: " + value.ToString());

            var template = ToastTemplateType.ToastText01;

            xml = ToastNotificationManager.GetTemplateContent(template);
            var text = xml.CreateTextNode(string.Format("Badge updated to {0}", value));

            elements = xml.GetElementsByTagName("text");
            elements[0].AppendChild(text);

            var toast    = new ToastNotification(xml);
            var notifier = ToastNotificationManager.CreateToastNotifier();

            notifier.Show(toast);

            Debug.WriteLine("Background task toast shown: " + value.ToString());
        }
Esempio n. 2
0
        private async void ButtonUpdateBadgeNumber_Click(object sender, RoutedEventArgs e)
        {
            int num;

            if (!int.TryParse(TextBoxBadgeNumber.Text, out num))
            {
                await new MessageDialog("You must provide a valid integer.", "Error").ShowAsync();
                return;
            }

            // Get the blank badge XML payload for a badge number
            XmlDocument badgeXml = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);

            // Set the value of the badge in the XML to our number
            XmlElement badgeElement = badgeXml.SelectSingleNode("/badge") as XmlElement;

            badgeElement.SetAttribute("value", num.ToString());

            // Create the badge notification
            BadgeNotification badge = new BadgeNotification(badgeXml);

            // Create the badge updater for our secondary tile, using our tile ID for the secondary tile
            BadgeUpdater badgeUpdater = BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile(SECONDARY_TILE_ID);

            // And update the badge
            badgeUpdater.Update(badge);
        }
Esempio n. 3
0
        //--------------------------------------------------------Misc Methods:---------------------------------------------------------------\\
        #region --Misc Methods (Public)--
        public static void IncBadgeCount()
        {
            // Get the blank badge XML payload for a badge number
            XmlDocument badgeXml = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);

            // Set the value of the badge in the XML to our number
            XmlElement badgeElement = badgeXml.SelectSingleNode("/badge") as XmlElement;
            string     value        = null;

            try
            {
                value = badgeElement.GetAttribute("value");
            }
            catch (Exception) { Logger.Debug("Failed to retrieve badge count value node."); }

            if (int.TryParse(value, out int count))
            {
                badgeElement.SetAttribute("value", (count + 1).ToString());
            }
            else
            {
                badgeElement.SetAttribute("value", "1");
            }

            // Create the badge notification
            BadgeNotification badge = new BadgeNotification(badgeXml);

            // Create the badge updater for the application
            BadgeUpdater badgeUpdater = BadgeUpdateManager.CreateBadgeUpdaterForApplication();

            // And update the badge
            badgeUpdater.Update(badge);
        }
Esempio n. 4
0
        private async void BadgeToggleSwitch_Toggled(object sender, RoutedEventArgs e)
        {
            if (Badge.IsOn)
            {
                badgeTile = new SecondaryTile(
                    "BadgeTile",
                    "Badge",
                    "Arguments",
                    new Uri("ms-appx:///Assets/green.150x150.png", UriKind.Absolute),
                    TileSize.Square150x150);
                await badgeTile.RequestCreateAsync();

                tileXml   = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeGlyph);
                tileImage = tileXml.SelectSingleNode("/badge") as XmlElement;
                tileImage.SetAttribute("value", "alert");

                BadgeNotification badgeNotification = new BadgeNotification(tileXml);
                BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile(badgeTile.TileId).Update(badgeNotification);

                tileXml   = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);
                tileImage = tileXml.SelectSingleNode("/badge") as XmlElement;
                tileImage.SetAttribute("value", "31");
                badgeNotification = new BadgeNotification(tileXml);
                BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeNotification);
            }
            else
            {
                BadgeUpdateManager.CreateBadgeUpdaterForApplication().Clear();
                await badgeTile.RequestDeleteAsync();
            }
        }
Esempio n. 5
0
        static public void UpdateWatchedBadge(WhirlMonData.WhirlPoolAPIData.RootObject data)
        {
            try
            {
                int unread = data.totalUnread;

                if (unread == 0)
                {
                    BadgeUpdateManager.CreateBadgeUpdaterForApplication().Clear();
                }
                else
                {
                    XmlDocument badgeXml = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);

                    XmlElement badgeElement = (XmlElement)badgeXml.SelectSingleNode("/badge");
                    badgeElement.SetAttribute("value", unread.ToString());

                    BadgeNotification badge = new BadgeNotification(badgeXml);
                    BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badge);
                }
            }
            catch (Exception x)
            {
                ShowErrorToast("UpdateWatchedBadge", x);
            }
        }
Esempio n. 6
0
        private static void UpdateBadgeGlyph(string badgeGlyphValue)
        {
            //https://docs.microsoft.com/en-us/windows/uwp/controls-and-patterns/tiles-and-notifications-badges

            if (badgeGlyphValue.IsNullOrWhiteSpace())
            {
                badgeGlyphValue = "alert";
            }

            // Get the blank badge XML payload for a badge glyph
            XmlDocument badgeXml =
                BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeGlyph);

            // Set the value of the badge in the XML to our glyph value
            XmlElement badgeElement =
                badgeXml.SelectSingleNode("/badge") as XmlElement;

            badgeElement.SetAttribute("value", badgeGlyphValue);

            // Create the badge notification
            BadgeNotification badge = new BadgeNotification(badgeXml);

            // Create the badge updater for the application
            BadgeUpdater badgeUpdater =
                BadgeUpdateManager.CreateBadgeUpdaterForApplication();

            // And update the badge
            badgeUpdater.Update(badge);
        }
        public void Run(IBackgroundTaskInstance taskInstance)
        {
            var deferal = taskInstance.GetDeferral();

            if (taskInstance.TriggerDetails is RawNotification)
            {
                var details   = taskInstance.TriggerDetails as RawNotification;
                var arguments = details.Content.Split(':');

                if (arguments.Count() > 0)
                {
                    switch (arguments[0])
                    {
                    case "new_items":
                        if (arguments.Count() > 1)
                        {
                            XmlDocument badgeXml     = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);
                            XmlElement  badgeElement = (XmlElement)badgeXml.SelectSingleNode("/badge");
                            badgeElement.SetAttribute("value", arguments[1]);
                            BadgeNotification badge = new BadgeNotification(badgeXml);
                            BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badge);
                        }
                        break;
                    }
                }
            }



            deferal.Complete();
        }
Esempio n. 8
0
        private void SetState(StateType state)
        {
            BadgeUpdateManager.CreateBadgeUpdaterForApplication().Clear();
            string badgeGlyphValue = "";

            switch (state)
            {
            case StateType.available:
                badgeGlyphValue = "available";
                break;

            case StateType.away:
                badgeGlyphValue = "away";
                break;

            case StateType.busy:
                badgeGlyphValue = "busy";
                break;

            default:
                break;
            }
            XmlDocument badgeXml     = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeGlyph);
            XmlElement  badgeElement = badgeXml.SelectSingleNode("/badge") as XmlElement;

            badgeElement.SetAttribute("value", badgeGlyphValue);
            BadgeNotification badge        = new BadgeNotification(badgeXml);
            BadgeUpdater      badgeUpdater = BadgeUpdateManager.CreateBadgeUpdaterForApplication();

            badgeUpdater.Update(badge);
        }
Esempio n. 9
0
        private static void UpdateBadge(int badgeNumber)
        {
            var badgeUpdater = BadgeUpdateManager.CreateBadgeUpdaterForApplication();

            if (badgeNumber == 0)
            {
                badgeUpdater.Clear();
                return;
            }

            var badgeXml = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);

            var badgeElement = (XmlElement)badgeXml.SelectSingleNode("/badge");

            badgeElement.SetAttribute("value", badgeNumber.ToString());

            try
            {
                badgeUpdater.Update(new BadgeNotification(badgeXml));
            }
            catch (Exception ex)
            {
                Telegram.Logs.Log.Write(ex.ToString());
            }
        }
Esempio n. 10
0
        private static void UpdateBadge(int badgeNumber)
        {
#if WNS_PUSH_SERVICE
            var badgeUpdater = BadgeUpdateManager.CreateBadgeUpdaterForApplication("xcee0f789y8059y4881y8883y347265c01f93x");
            if (badgeNumber == 0)
            {
                badgeUpdater.Clear();
                return;
            }

            var badgeXml = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);

            var badgeElement = (XmlElement)badgeXml.SelectSingleNode("/badge");
            badgeElement.SetAttribute("value", badgeNumber.ToString());

            try
            {
                badgeUpdater.Update(new BadgeNotification(badgeXml));
            }
            catch (Exception ex)
            {
                Telegram.Logs.Log.Write(ex.ToString());
            }
#endif
        }
Esempio n. 11
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);
            }
        }
        public NotificationsImpl()
        {
            this.badgeUpdater  = BadgeUpdateManager.CreateBadgeUpdaterForApplication();
            this.toastNotifier = ToastNotificationManager.CreateToastNotifier();

            this.badgeXml = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);
            this.badgeEl  = (XmlElement)this.badgeXml.SelectSingleNode("/badge");
        }
Esempio n. 13
0
        internal static XmlDocument CreateBadgeNumber(int number)
        {
            var badgeXml     = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);
            var badgeElement = (XmlElement)badgeXml.SelectSingleNode("/badge");

            badgeElement.SetAttribute("value", number.ToString());
            return(badgeXml);
        }
        private void OnSetBadgeClick(object sender, RoutedEventArgs e)
        {
            var template = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);

            (template.GetElementsByTagName("badge")[0] as XmlElement).SetAttribute("value", countTextBox.Text);
            BadgeUpdater updater = BadgeUpdateManager.CreateBadgeUpdaterForApplication();

            updater.Update(new BadgeNotification(template));
        }
Esempio n. 15
0
        public static void CreateBadge(String value)
        {
            var badgeXml        = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);
            var badgeAttributes = badgeXml.GetElementsByTagName("badge");

            badgeAttributes[0].Attributes.GetNamedItem("value").NodeValue = value;

            BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(new BadgeNotification(badgeXml));
        }
Esempio n. 16
0
        private static void UpdateBadge()
        {
            XmlDocument badgeXml     = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeGlyph);
            XmlElement  badgeElement = (XmlElement)badgeXml.SelectSingleNode("/badge");

            badgeElement.SetAttribute("value", "1");
            BadgeNotification badge = new BadgeNotification(badgeXml);

            BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badge);
        }
Esempio n. 17
0
        public static void UpdateBadge(int count)
        {
            XmlDocument badgeXml     = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);
            XmlElement  badgeElement = (XmlElement)badgeXml.SelectSingleNode("/badge");

            badgeElement.SetAttribute("value", count.ToString());
            BadgeNotification badge = new BadgeNotification(badgeXml);

            BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badge);
        }
Esempio n. 18
0
        private static BadgeNotification BuildBadge(int number)
        {
            // Get the blank badge XML payload for a badge number
            var badgeXml = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);

            // Set the value of the badge in the XML to our number
            var badgeElement = badgeXml.SelectSingleNode("/badge") as XmlElement;

            badgeElement.SetAttribute("value", number.ToString());
            return(new BadgeNotification(badgeXml));
        }
Esempio n. 19
0
        private void setBadgeNumber(int num)
        {
            XmlDocument badgeXml     = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);
            XmlElement  badgeElement = badgeXml.SelectSingleNode("/badge") as XmlElement;

            badgeElement.SetAttribute("value", num.ToString());
            BadgeNotification badge        = new BadgeNotification(badgeXml);
            BadgeUpdater      badgeUpdater = BadgeUpdateManager.CreateBadgeUpdaterForApplication();

            badgeUpdater.Update(badge);
        }
Esempio n. 20
0
        public static void Clear()
        {
            XmlDocument       badgeXml = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);
            BadgeNotification badge    = new BadgeNotification(badgeXml);

            BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badge);

            TileUpdater tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();

            tileUpdater.Clear();
        }
Esempio n. 21
0
        public void UpdateBadge()
        {
            var badgeXml        = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);
            var badgeAttributes = badgeXml.GetElementsByTagName("badge");

            bool clearValue = false;

            if (errorState)
            {
                badgeAttributes[0].Attributes.GetNamedItem("value").NodeValue = "error";
            }
            else if (NotificationCount > 0)
            {
                badgeAttributes[0].Attributes.GetNamedItem("value").NodeValue = NotificationCount.ToString();
            }
            else if (new Accounts().Enabled.Count() <= 0)
            {
                clearValue = true;
            }
            else
            {
                var    status = new Status();
                string value  = "";
                switch (status.status)
                {
                case StatusType.Available:
                    value = "available";
                    break;

                case StatusType.Away:
                    value = "away";
                    break;

                case StatusType.Busy:
                    value = "busy";
                    break;

                case StatusType.Offline:
                    value = "unavailable";
                    break;
                }

                badgeAttributes[0].Attributes.GetNamedItem("value").NodeValue = value;
            }

            if (clearValue)
            {
                BadgeUpdater.Clear();
            }
            else
            {
                BadgeUpdater.Update(new BadgeNotification(badgeXml));
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Sets the badge.
        /// </summary>
        /// <param name="badgeNumber">The badge number.</param>
        /// <param name="title">The title. Used only by Android</param>
        public void SetBadge(int badgeNumber, string title = null)
        {
            var badgeXml     = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);
            var badgeElement = (XmlElement)badgeXml.SelectSingleNode("/badge");

            badgeElement.SetAttribute("value", badgeNumber.ToString());

            var badge = new BadgeNotification(badgeXml);

            BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badge);
        }
        public static void SetBadgeCount(int c)
        {
            XmlDocument badgeXml        = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);
            var         badgeAttributes = (XmlElement)badgeXml.GetElementsByTagName("badge")[0];

            badgeAttributes.SetAttribute("value", c.ToString());

            var badgeNotification = new BadgeNotification(badgeXml);

            BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeNotification);
        }
Esempio n. 24
0
        private void btnBadge_Click(object sender, RoutedEventArgs e)
        {
            XmlDocument badgeXml     = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeGlyph);
            XmlElement  badgeElement = (XmlElement)badgeXml.SelectSingleNode("/badge");

            badgeElement.SetAttribute("value", "alarm");
            BadgeNotification badge = new BadgeNotification(badgeXml);

            badge.ExpirationTime = DateTimeOffset.Now.AddMinutes(1);
            BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badge);
        }
        //バッジ通知を表示
        public static void SendBasicBadge(int number)
        {
            var template = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);

            Debug.WriteLine(template.GetXml());
            template.FirstChild.Attributes.First(q => q.NodeName == "value").InnerText = number.ToString();

            var notification = new BadgeNotification(template);

            BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(notification);
        }
Esempio n. 26
0
        private void btnCleraBadge_Click(object sender, RoutedEventArgs e)
        {
            XmlDocument badgeXml =
                BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);
            XmlElement badgeElement = (XmlElement)badgeXml.SelectSingleNode("/badge");

            badgeElement.SetAttribute("value", "0");
            BadgeNotification badge = new BadgeNotification(badgeXml);

            BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badge);
        }
Esempio n. 27
0
        public void showGlyphBadge(string glyph)
        {
            XmlDocument badgeXml =
                BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeGlyph);

            XmlElement badgeElement = badgeXml.SelectSingleNode("/badge") as XmlElement;

            badgeElement.SetAttribute("value", glyph);

            createBadge(badgeXml);
        }
        private void ButtonSetLockScreenClick(object sender, RoutedEventArgs e)
        {
            var lockscreen = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);
            var template   = lockscreen.GetElementsByTagName("badge");

            ((XmlElement)template[0]).SetAttribute("value", TextboxLockScreen.Text);

            BadgeNotification badge = new BadgeNotification(lockscreen);

            BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badge);
        }
Esempio n. 29
0
File: Help.cs Progetto: fffweb/wp
        public static void UpdateBadge(int wordCount)

        {
            XmlDocument xdoc   = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);
            XmlElement  xBadge = (XmlElement)xdoc.SelectSingleNode("/badge");

            xBadge.SetAttribute("value", wordCount.ToString());
            BadgeNotification notifi = new BadgeNotification(xdoc);

            BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(notifi);
        }
Esempio n. 30
0
        public void showNumericalBadge(int num)
        {
            XmlDocument badgeXml =
                BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber);

            XmlElement badgeElement = badgeXml.SelectSingleNode("/badge") as XmlElement;

            badgeElement.SetAttribute("value", num.ToString());

            createBadge(badgeXml);
        }