public void SendToastBG(string message)
        {
            var toastTemplate =
                ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01);

            var text = toastTemplate.GetElementsByTagName("text")[0] as XmlElement;
            text.AppendChild(toastTemplate.CreateTextNode(message));

            var toastNotification = new ToastNotification(toastTemplate);
            var toastNotifier = ToastNotificationManager.CreateToastNotifier();
            toastNotifier.Show(toastNotification);
        }
示例#2
0
        /// <summary>
        /// Show a toast notification from local
        /// </summary>
        /// <param name="title">Title string</param>
        /// <param name="content">Content string</param>
        public static void Show(string title, string content)
        {
            ToastTemplateType type              = ToastTemplateType.ToastText02;
            XmlDocument       toastXml          = ToastNotificationManager.GetTemplateContent(type);
            XmlNodeList       toastTextElements = toastXml.GetElementsByTagName("text");

            toastTextElements[0].AppendChild(toastXml.CreateTextNode(title));
            toastTextElements[1].AppendChild(toastXml.CreateTextNode(content));
            ToastNotification toast = new ToastNotification(toastXml);

            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
示例#3
0
        private void ShowToast(string msg)
        {
            ToastTemplateType toastTemplate     = ToastTemplateType.ToastText02;
            XmlDocument       toastXml          = ToastNotificationManager.GetTemplateContent(toastTemplate);
            XmlNodeList       toastTextElements = toastXml.GetElementsByTagName("text");

            toastTextElements[0].AppendChild(toastXml.CreateTextNode(msg));
            toastTextElements[1].AppendChild(toastXml.CreateTextNode(DateTime.Now.ToString()));
            ToastNotification toast = new ToastNotification(toastXml);

            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
示例#4
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            // make the json object
            var ps = new Person()
            {
                Name             = yourName.Text,
                PermissionToCall = mycheck.IsChecked.ToString(),
                PhoneNum         = new List <Person.PhoneNumber>()
                {
                    new Person.PhoneNumber()
                    {
                        Location = "Home", Number = yourHomephone.Text
                    },
                    new Person.PhoneNumber()
                    {
                        Location = "Work", Number = yourWorkePhone.Text
                    }
                }
            };

            var json = JsonConvert.SerializeObject(ps);

            // read number which location is home ( reading back the json)

            string homephonenumber           = "";
            var    data                      = JsonConvert.DeserializeObject <Person>(json);
            List <Person.PhoneNumber> number = data.PhoneNum;

            foreach (Person.PhoneNumber p in number)
            {
                if (p.Location == "Home")
                {
                    homephonenumber = p.Number;
                }
            }
            // make the toast noti

            ToastTemplateType toastTem = ToastTemplateType.ToastText01;
            XmlDocument       toastxml = ToastNotificationManager.GetTemplateContent(toastTem);

            XmlNodeList toastTextEle = toastxml.GetElementsByTagName("text");

            //dispaly json data
            toastTextEle[0].AppendChild(toastxml.CreateTextNode(json));

            // display homephone number
            //toastTextEle[1].AppendChild(toastxml.CreateTextNode(homephonenumber));

            // display toast
            ToastNotification toast = new ToastNotification(toastxml);

            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
示例#5
0
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
        async void HeartRate_ReadingChanged(object sender, BandSensorReadingEventArgs <IBandHeartRateReading> e)
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
        {
            Debug.WriteLine($"Change notified {DateTime.Now.Second}");

            var hr = e.SensorReading.HeartRate;
            var ts = e.SensorReading.Timestamp;

            //UpdateHistory(hr);
            _events.Publish(_hrv);

#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            _dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            {
                HeartRate = hr;
                TimeStamp = ts.ToString();

#if USE_NOTIFICATIONS
                //increment notification timer
                NotificationTimer++;
                if ((NotificationTimer % 30) == 0)
                {
                    //Display notification for heart rate
                    ToastTemplateType toastTemplate = ToastTemplateType.ToastImageAndText01;
                    XmlDocument toastXml            = ToastNotificationManager.GetTemplateContent(toastTemplate);

                    XmlNodeList toastTextElements = toastXml.GetElementsByTagName("text");
                    toastTextElements[0].AppendChild(toastXml.CreateTextNode(_bandInfo.Name + " is working hard!\nHeart Rate: " + HeartRate + " bpm"));

                    XmlNodeList toastImageAttributes = toastXml.GetElementsByTagName("image");
                    ((XmlElement)toastImageAttributes[0]).SetAttribute("src", "ms-appx:///assets/tpoc-heart-logo-hi.png");
                    ((XmlElement)toastImageAttributes[0]).SetAttribute("alt", "heart");

                    IXmlNode toastNode = toastXml.SelectSingleNode("/toast");
                    ((XmlElement)toastNode).SetAttribute("duration", "short");
                    ToastNotification toast = new ToastNotification(toastXml);
                    ToastNotificationManager.CreateToastNotifier().Show(toast);

                    NotificationTimer = 0;
                }
#endif
            });
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            _telemetry.PostTelemetryAsync(new Models.DeviceTelemetry
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            {
                DeviceId  = _bandInfo.Name,
                HeartRate = hr,
                Timestamp = ts.ToString()
            });
        }
示例#6
0
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            var deferral = taskInstance.GetDeferral();
            var session  = Session.Current;

            if (!session.HasToken)
            {
                return;
            }

            if (!await session.Login())
            {
                return;
            }

            var account = await session.GetInfo();

            var updater    = TileUpdateManager.CreateTileUpdaterForApplication("App");
            var contentXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWidePeekImage06);

            contentXml.GetElementsByTagName("text")[0].InnerText = account.ToString();

            foreach (XmlElement image in contentXml.GetElementsByTagName("image"))
            {
                image.SetAttribute("src", "ms-appx:///Assets/Wide310x150Logo.png");
            }

            updater.Update(new TileNotification(contentXml));

            if (session.PreviousAccount == null)
            {
                return;
            }

            if (session.CurrentAccount.DisposableAmountInteger > session.PreviousAccount.DisposableAmountInteger)
            {
                var toastXml  = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01);
                var toastText = toastXml.GetElementsByTagName("text").First();

                toastText.InnerText = String.Format("Du har mottatt {0} kroner",
                                                    session.CurrentAccount.DisposableAmountInteger - session.PreviousAccount.DisposableAmountInteger);

                IXmlNode toastNode = toastXml.SelectSingleNode("/toast");
                ((XmlElement)toastNode).SetAttribute("duration", "long");

                var toast = new ToastNotification(toastXml);
                ToastNotificationManager.CreateToastNotifier().Show(toast);
            }


            deferral.Complete();
        }
        public void NotificationsSetup()
        {
            var settings = ApplicationData.Current.LocalSettings;

            if (!settings.Values.ContainsKey("Notifications"))
            {
                settings.Values["Notifications"] = true;
            }

            var toasts = Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier().GetScheduledToastNotifications();

            foreach (var toast in toasts)
            {
                ToastNotificationManager.CreateToastNotifier().RemoveFromSchedule(toast);
            }

            bool isEnabled = (bool)settings.Values["Notifications"];

            if (isEnabled)
            {
                var toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
                var strings  = toastXml.GetElementsByTagName("text");
                strings[0].AppendChild(toastXml.CreateTextNode("Si se že danes pregrešil?"));
                strings[1].AppendChild(toastXml.CreateTextNode(""));
                Random r = new Random();

                for (int i = 0; i < 10; i++)
                {
                    try
                    {
                        // Create the toast notification object.
                        var idNumber = Math.Floor(r.NextDouble() * 100000000);
                        var toast    = new ScheduledToastNotification(toastXml, new DateTimeOffset(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 15, 0, 0).AddDays(i)));
                        toast.Id = "Toast" + idNumber;

                        var idNumber1 = Math.Floor(r.NextDouble() * 100000000);
                        var toast1    = new ScheduledToastNotification(toastXml, new DateTimeOffset(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 20, 0, 0).AddDays(i)));
                        toast1.Id = "Toast" + idNumber1;

                        ToastNotificationManager.CreateToastNotifier().AddToSchedule(toast);
                        ToastNotificationManager.CreateToastNotifier().AddToSchedule(toast1);
                    }
                    catch (Exception ex)
                    {
                        //Break because wrong date :)
                    }
                }
            }
            else
            {
            }
        }
示例#8
0
        public void onTaskCompleted(string result, APIRequest.requestCodeType requestCode)
        {
            if (result != null)
            {
                if (requestCode == APIRequest.requestCodeType.Portfolio)
                {
                    Items.Clear();

                    JsonArray json = JsonArray.Parse(result);

                    foreach (var share in json)
                    {
                        JsonObject shareObj = share.GetObject();
                        string     symbol   = shareObj.GetNamedString("symbol");
                        string     name     = shareObj.GetNamedString("name");
                        double     value    = shareObj.GetNamedNumber("value");
                        bool       isMain   = shareObj.GetNamedBoolean("is_main");
                        Quotation  q        = new Quotation()
                        {
                            Name = name, Symbol = symbol, Value = value, IsMain = isMain
                        };
                        Items.Add(q);
                    }
                }
                else if (requestCode == APIRequest.requestCodeType.PortfolioAdd)
                {
                    RefreshPortfolio();
                }
                else if (requestCode == APIRequest.requestCodeType.UpdateUri)
                {
                    // update sucessfull
                }
                else if (requestCode == APIRequest.requestCodeType.Logout)
                {
                    JsonObject json = new JsonObject();
                    JsonObject.TryParse(result, out json);
                    view.LogoutHandler(!json.ContainsKey("error"));
                }
            }
            else
            {
                var toastXmlContent = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);

                var txtNodes = toastXmlContent.GetElementsByTagName("text");
                txtNodes[0].AppendChild(toastXmlContent.CreateTextNode("Server request failed."));
                txtNodes[1].AppendChild(toastXmlContent.CreateTextNode("Server is down or you lost internet connection."));

                var toast         = new ToastNotification(toastXmlContent);
                var toastNotifier = ToastNotificationManager.CreateToastNotifier();
                toastNotifier.Show(toast);
            }
        }
示例#9
0
        public static void showToast(String message)
        {
            var toastTemplate     = ToastTemplateType.ToastImageAndText01;
            var toastXml          = ToastNotificationManager.GetTemplateContent(toastTemplate);
            var toastTextElements = toastXml.GetElementsByTagName("text");

            toastTextElements[0].AppendChild(toastXml.CreateTextNode(message));
            toast = new ToastNotification(toastXml);
            toast.ExpirationTime = DateTime.Now.AddSeconds(2);
            ToastNotificationManager.CreateToastNotifier().Show(toast);

            timer = new Timer(_ => HideToast(), null, new TimeSpan(0, 0, 2), new TimeSpan(0, 0, 2));
        }
示例#10
0
        public void Run(IBackgroundTaskInstance taskInstance)
        {
            // simple example with a Toast, to enable this go to manifest file
            // and mark App as TastCapable - it won't work without this
            // The Task will start but there will be no Toast.
            ToastTemplateType toastTemplate = ToastTemplateType.ToastText02;
            XmlDocument       toastXml      = ToastNotificationManager.GetTemplateContent(toastTemplate);
            XmlNodeList       textElements  = toastXml.GetElementsByTagName("text");

            textElements[0].AppendChild(toastXml.CreateTextNode("My first Task - Yeah"));
            textElements[1].AppendChild(toastXml.CreateTextNode("I'm a message from your background task!"));
            ToastNotificationManager.CreateToastNotifier().Show(new ToastNotification(toastXml));
        }
示例#11
0
        public static void SendToast(string message)
        {
            // build toast
            var template = ToastTemplateType.ToastText01;
            var xml      = ToastNotificationManager.GetTemplateContent(template);
            var elements = xml.GetElementsByTagName("text");
            var text     = xml.CreateTextNode(message);

            elements[0].AppendChild(text);
            var toast = new ToastNotification(xml);

            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
示例#12
0
        private void SendPlainTextToast()
        {
            var notifier = ToastNotificationManager.CreateToastNotifier();
            var tempate  = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);

            var element = tempate.GetElementsByTagName("text")[0];

            element.AppendChild(tempate.CreateTextNode(PlainTextValue));

            var toast = new ToastNotification(tempate);

            notifier.Show(toast);
        }
示例#13
0
        public void Show(string message)
        {
            var ToastNotifier = ToastNotificationManager.CreateToastNotifier();
            var toastXml      = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01);
            var toastNodeList = toastXml.GetElementsByTagName("text");

            toastNodeList.Item(0).AppendChild(toastXml.CreateTextNode(message));

            var toast = new ToastNotification(toastXml);

            toast.ExpirationTime = DateTime.Now.AddSeconds(4);
            ToastNotifier.Show(toast);
        }
示例#14
0
        private void Notify(string notificationText)
        {
            ToastTemplateType toastTemplate = ToastTemplateType.ToastImageAndText01;
            XmlDocument       toastXml      = ToastNotificationManager.GetTemplateContent(toastTemplate);

            XmlNodeList toastTextElements = toastXml.GetElementsByTagName("text");

            toastTextElements[0].AppendChild(toastXml.CreateTextNode(notificationText));

            ToastNotification toast = new ToastNotification(toastXml);

            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
示例#15
0
        static void ShowToastNotification(string title, string body)
        {
            var template  = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
            var textNodes = template.GetElementsByTagName("text");

            textNodes[0].AppendChild(template.CreateTextNode(title));
            textNodes[1].AppendChild(template.CreateTextNode(body));

            var toast   = new ToastNotification(template);
            var manager = ToastNotificationManager.CreateToastNotifier("Scrap.TF Raffle Bot");

            manager.Show(toast);
        }
示例#16
0
        private static void ShowToastNotification(string errorMessage)
        {
            ToastTemplateType toastTemplate     = ToastTemplateType.ToastText02;
            XmlDocument       toastXml          = ToastNotificationManager.GetTemplateContent(toastTemplate);
            XmlNodeList       toastTextElements = toastXml.GetElementsByTagName("text");

            toastTextElements[0].AppendChild(toastXml.CreateTextNode("Intelligent Kiosk"));
            toastTextElements[1].AppendChild(toastXml.CreateTextNode(errorMessage));

            ToastNotification toast = new ToastNotification(toastXml);

            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
示例#17
0
        public static void PopToast(string message)
        {
            var toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01);

            var textFields = toastXml.GetElementsByTagName("text");

            textFields[0].AppendChild(toastXml.CreateTextNode(message));
            ToastNotification toast = new ToastNotification(toastXml);

            toast.ExpirationTime = DateTime.Now.AddSeconds(20.0);

            ToastNotificationManager.CreateToastNotifier("Microsoft.Samples.DesktopToasts").Show(toast);
        }
示例#18
0
        public void notification(string notificationText)
        {
            Windows.Data.Xml.Dom.XmlDocument toastXml          = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastImageAndText01);
            Windows.Data.Xml.Dom.XmlNodeList toastTextElements = toastXml.GetElementsByTagName("text");
            toastTextElements[0].AppendChild(toastXml.CreateTextNode(notificationText));
            Windows.Data.Xml.Dom.XmlNodeList toastImageAttributes = toastXml.GetElementsByTagName("image");
            string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "notificationPhoto.png");

            ((Windows.Data.Xml.Dom.XmlElement)toastImageAttributes[0]).SetAttribute("src", path);
            ToastNotification toast = new ToastNotification(toastXml);

            ToastNotificationManager.CreateToastNotifier("Computer Monitor").Show(toast);
        }
示例#19
0
        public static void Send(string msg)
        {
            const ToastTemplateType toastTemplate = ToastTemplateType.ToastImageAndText01;
            var toastXml = ToastNotificationManager.GetTemplateContent(toastTemplate);

            var toastTextElements = toastXml.GetElementsByTagName("text");

            toastTextElements[0].AppendChild(toastXml.CreateTextNode(msg));

            var toast = new ToastNotification(toastXml);

            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
        public void ShowMessage(string message)
        {
            //clear toast
            ToastNotificationManager.History.Clear();
            //add toast message
            var toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01);
            var elements = toastXml.GetElementsByTagName("text");

            elements[0].AppendChild(toastXml.CreateTextNode(message));
            ToastNotification toast = new ToastNotification(toastXml);

            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
示例#21
0
        //デバッグ表示用
        private void ShowToast(string message)
        {
            //トーストテンプレートの取得
            XmlDocument doc = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01);

            //XMLの編集
            doc.GetElementsByTagName("text")[0].InnerText = message;

            ToastNotification notification = new ToastNotification(doc);

            //通知の送信
            ToastNotificationManager.CreateToastNotifier().Show(notification);
        }
示例#22
0
        private void Signals_ToastBurntReceived(org.alljoyn.example.Toaster.ToasterSignals sender, org.alljoyn.example.Toaster.ToasterToastBurntReceivedEventArgs args)
        {
            ToastTemplateType toastTemplate = ToastTemplateType.ToastText01;
            XmlDocument       toastXml      = ToastNotificationManager.GetTemplateContent(toastTemplate);

            XmlNodeList toastTextElements = toastXml.GetElementsByTagName("text");

            toastTextElements[0].AppendChild(toastXml.CreateTextNode("Your toast was burnt!"));

            ToastNotification toast = new ToastNotification(toastXml);

            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
        private static void ShowThrottlingToast(string api)
        {
            ToastTemplateType toastTemplate     = ToastTemplateType.ToastText02;
            XmlDocument       toastXml          = ToastNotificationManager.GetTemplateContent(toastTemplate);
            XmlNodeList       toastTextElements = toastXml.GetElementsByTagName("text");

            toastTextElements[0].AppendChild(toastXml.CreateTextNode("Intelligent Kiosk"));
            toastTextElements[1].AppendChild(toastXml.CreateTextNode("The " + api + " API is throttling your requests. Consider upgrading to a Premium Key."));

            ToastNotification toast = new ToastNotification(toastXml);

            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
示例#24
0
        private void SendNotification(string p)
        {
            XmlDocument toastXML = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01);
            XmlNodeList elements = toastXML.GetElementsByTagName("text");

            foreach (IXmlNode node in elements)
            {
                node.InnerText = p;
            }
            ToastNotification notification = new ToastNotification(toastXML);

            ToastNotificationManager.CreateToastNotifier().Show(notification);
        }
示例#25
0
        void Toast(string title, string message)
        {
            var template = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01);

            var textNodes = template.GetElementsByTagName("text");

            textNodes.Item(0).InnerText = message;

            var notifier     = ToastNotificationManager.CreateToastNotifier(title);
            var notification = new ToastNotification(template);

            notifier.Show(notification);
        }
示例#26
0
        public static void ShowDebugToast(string msg, string subMsg)
        {
#if DEBUG
            var toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);

            var toastTextElements = toastXml.GetElementsByTagName("text");
            toastTextElements[0].AppendChild(toastXml.CreateTextNode(msg));
            toastTextElements[1].AppendChild(toastXml.CreateTextNode(subMsg));

            var toast = new ToastNotification(toastXml);
            ToastNotificationManager.CreateToastNotifier().Show(toast);
#endif
        }
示例#27
0
        public void NotifyError(string er)
        {
            this.BenchmarkStatus = Status.Error;
            //make progressbar value full
            this.ProgressBarValue = this.ProgressBarMax;
            Debug.WriteLine(er);
            var xml   = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
            var texts = xml.GetElementsByTagName("text");

            texts[0].AppendChild(xml.CreateTextNode("prime_num_searcher_gui error"));
            texts[1].AppendChild(xml.CreateTextNode(er));
            windowsNotifier.Show(new ToastNotification(xml));
        }
        /// <summary>
        /// 创建本地toast 推送
        /// </summary>
        /// <param name="content"></param>
        public static void CreateToastNotifications(string content)
        {
            var toastNotifier = ToastNotificationManager.CreateToastNotifier();

            if (toastNotifier.Setting == NotificationSetting.Enabled)
            {
                var template       = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01);
                var tileAttributes = template.GetElementsByTagName("text")[0];
                tileAttributes.AppendChild(template.CreateTextNode(content));
                var notifications1 = new ToastNotification(template);
                toastNotifier.Show(notifications1);
            }
        }
示例#29
0
文件: Notice.cs 项目: SPNSPN/notice
    public static void Main(string[] args)
    {
        Console.WriteLine("Hello, World!");

        var content = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01);
        var text    = content.GetElementsByTagName("text")[0];

        text.AppendChild(content.CreateTextNode("てすとめっせーじ"));

        ToastNotificationManager.CreateToastNotifier("Microsoft.Windows.Computer").Show(new ToastNotification(content));

        Thread.Sleep(10000);
    }
示例#30
0
        private void SendToastNotification_Click(object sender, RoutedEventArgs e)
        {
            ToastTemplateType toastTemplate = ToastTemplateType.ToastText01;
            XmlDocument       toastXml      = ToastNotificationManager.GetTemplateContent(toastTemplate);

            XmlNodeList toastTextElements = toastXml.GetElementsByTagName("text");

            toastTextElements[0].AppendChild(toastXml.CreateTextNode("Toast notification"));

            ToastNotification toast = new ToastNotification(toastXml);

            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }