示例#1
0
        /// <summary>
        /// Post弹出消息对话框系统APP图片
        /// </summary>
        /// <param name="title">主题</param>
        /// <param name="description">内容</param>
        public static void DisplayTextTost(string title, string description, ToastAudioContent toastAudioContent = ToastAudioContent.Default)
        {
            //var toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
            //var textElements = toastXml.GetElementsByTagName("text");
            //for (uint i = 0; i < textElements.Length; i++)
            //{
            //    string text = null;
            //    if (i == 0) text = title;
            //    else if (i == 1) text = description;
            //    if (text != null)
            //        textElements.Item(i).AppendChild(toastXml.CreateTextNode(text));
            //}

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

            IToastText02 toastContent = ToastContentFactory.CreateToastText02();

            toastContent.TextHeading.Text  = title;
            toastContent.TextBodyWrap.Text = description;
            toastContent.Audio.Content     = toastAudioContent;
            ToastNotification toast = toastContent.CreateNotification();

            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
示例#2
0
        void Scenario5DisplayToastWithCallbacks_Click(object sender, RoutedEventArgs e)
        {
            IToastText02 toastContent = ToastContentFactory.CreateToastText02();

            // Set the launch activation context parameter on the toast.
            // The context can be recovered through the app Activation event
            toastContent.Launch = "Context123";

            toastContent.TextHeading.Text  = "Tap toast";
            toastContent.TextBodyWrap.Text = "Or swipe to dismiss";

            // You can listen for the "Activated" event provided on the toast object
            // or listen to the "OnLaunched" event off the Windows.UI.Xaml.Application
            // object to tell when the user clicks the toast.
            //
            // The difference is that the OnLaunched event will
            // be raised by local, scheduled and cloud toasts, while the event provided by the
            // toast object will only be raised by local toasts.
            //
            // In this example, we'll use the event off the CoreApplication object.
            scenario5Toast            = toastContent.CreateNotification();
            scenario5Toast.Dismissed += toast_Dismissed;
            scenario5Toast.Failed    += toast_Failed;

            ToastNotificationManager.CreateToastNotifier().Show(scenario5Toast);
        }
        void DisplayLongToast(bool loopAudio)
        {
            IToastText02 toastContent = ToastContentFactory.CreateToastText02();

            // Toasts can optionally be set to long duration
            toastContent.Duration = ToastDuration.Long;

            toastContent.TextHeading.Text = "Long Duration Toast";

            if (loopAudio)
            {
                toastContent.Audio.Loop        = true;
                toastContent.Audio.Content     = ToastAudioContent.LoopingAlarm;
                toastContent.TextBodyWrap.Text = "Looping audio";
            }
            else
            {
                toastContent.Audio.Content = ToastAudioContent.IM;
            }

            scenario6Toast = toastContent.CreateNotification();
            ToastNotificationManager.CreateToastNotifier().Show(scenario6Toast);

            rootPage.NotifyUser(toastContent.GetContent(), NotifyType.StatusMessage);
        }
示例#4
0
        private ToastNotification CreateToastText02(string title, string content)
        {
            IToastText02 toastContent = ToastContentFactory.CreateToastText02();

            // Set the launch activation context parameter on the toast.
            // The context can be recovered through the app Activation event
            toastContent.Launch = "Context123";

            toastContent.TextHeading.Text  = title;
            toastContent.TextBodyWrap.Text = content;

            return(toastContent.CreateNotification());
        }
        void DisplayAudioToast(string audioSrc)
        {
            IToastText02 toastContent = ToastContentFactory.CreateToastText02();

            toastContent.TextHeading.Text  = "Sound:";
            toastContent.TextBodyWrap.Text = audioSrc;
            toastContent.Audio.Content     = (ToastAudioContent)Enum.Parse(typeof(ToastAudioContent), audioSrc);

            rootPage.NotifyUser(toastContent.GetContent(), NotifyType.StatusMessage);

            // Create a toast, then create a ToastNotifier object to show
            // the toast
            ToastNotification toast = toastContent.CreateNotification();

            // If you have other applications in your package, you can specify the AppId of
            // the app to create a ToastNotifier for that application
            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
示例#6
0
        public void ShowToastNotification(string title, string message,
                                          ToastDisplayDuration displayDuration, ToastTag tag = ToastTag.Default, PortableImage image = null, bool vibrate = false)
        {
            var duration = ToastDuration.Short;

            switch (displayDuration)
            {
            case ToastDisplayDuration.Short:
                duration = ToastDuration.Short;
                break;

            case ToastDisplayDuration.Long:
                duration = ToastDuration.Long;
                break;

            default:
                throw new ArgumentOutOfRangeException("timeTillHide");
            }

            IToastText02 templateContent = ToastContentFactory.CreateToastText02();

            //templateContent.TextHeading.Text = title;
            templateContent.TextBodyWrap.Text = message;
            templateContent.Duration          = duration;

            templateContent.Audio.Content = ToastAudioContent.Silent;


            var toast = templateContent.CreateNotification();

            toast.Tag        = tag.ToString();
            toast.Activated += ToastOnActivated;
            toast.Dismissed += ToastOnDismissed;
            toast.Failed    += ToastOnFailed;

            if (vibrate)
            {
                VibrationDevice.GetDefault().Vibrate(TimeSpan.FromSeconds(0.5));
            }

            ServiceLocator.DispatcherService.RunOnMainThread(() =>
                                                             ToastNotificationManager.CreateToastNotifier().Show(toast));
        }
示例#7
0
        /// <summary>
        /// Post弹出消息对话框系统APP图片
        /// </summary>
        /// <param name="title">主题</param>
        /// <param name="description">内容</param>
        /// <param name="notificationSound">声音(默认是成功的声音)</param>
        public static void DisplayTextCustomTost(string title, string description, NotificationToastSound notificationSound = NotificationToastSound.Success)
        {
            IToastText02 toastContent = ToastContentFactory.CreateToastText02();

            toastContent.TextHeading.Text  = title;
            toastContent.TextBodyWrap.Text = description;
            switch (notificationSound)
            {
            case NotificationToastSound.Success:
            {
                toastContent.Audio.Content = ToastAudioContent.Reminder;
                break;
            }

            case NotificationToastSound.Failure:
            {
                toastContent.Audio.Content = ToastAudioContent.Mail;
                break;
            }

            case NotificationToastSound.News:
            {
                toastContent.Audio.Content = ToastAudioContent.Default;
                break;
            }

            default:
            {
                toastContent.Audio.Content = ToastAudioContent.Default;
                break;
            }
            }
            ToastNotification toast = toastContent.CreateNotification();

            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
示例#8
0
        private async void testBtn_Click(object sender, RoutedEventArgs e)
        {
            IToastText02 toastContent = ToastContentFactory.CreateToastText02();

            // Set the launch activation context parameter on the toast.
            // The context can be recovered through the app Activation event
            toastContent.Launch = "reminder";

            toastContent.TextHeading.Text = "即将到站提醒";
            string desc = "";

            foreach (StationInfo info in this.CurrentReminderStation.StationInfos)
            {
                if (info.isReminder)
                {
                    desc = info.caption;
                }
            }
            toastContent.TextBodyWrap.Text = desc + "就要到站了,请准备下车,以免坐过站!";

            ToastNotification testNotification = toastContent.CreateNotification();

            ToastNotificationManager.CreateToastNotifier().Show(testNotification);
        }
示例#9
0
        public async void CheckReminder()
        {
            lock (reminderLock)
            {
                if (this.CurrentReminderStation != null)
                {
                    bool        needAlert    = false;
                    StationInfo neareastInfo = null;
                    double      distance     = double.MaxValue;

                    foreach (StationInfo info in this.CurrentReminderStation.StationInfos)
                    {
                        double len = (info.longitude - this.CurrentSogoLongitude) * (info.longitude - this.CurrentSogoLongitude) +
                                     (info.latitude - this.CurrentSogoLatitude) * (info.latitude - this.CurrentSogoLatitude);
                        if (info.isReminder && len < MinDistanceToAlert)
                        {
                            needAlert    = true;
                            neareastInfo = info;
                            distance     = len;
                            break;
                        }

                        if (len < distance)
                        {
                            distance     = len;
                            neareastInfo = info;
                        }
                    }

                    if (neareastInfo != null)
                    {
                        this.CurrentReminderStation.status = "靠近站点" + neareastInfo.caption;
                    }

                    if (needAlert && !this.CurrentReminderStation.alertResponse)
                    {
                        if (this.notification != null && this.CurrentReminderStation.alertDisplaying)
                        {
                            return;
                        }
                        this.CurrentReminderStation.needAlert = true;
                        this.CurrentReminderStation.status    = "即将到站!!!" + this.CurrentReminderStation.status;
                        IToastText02 toastContent = ToastContentFactory.CreateToastText02();

                        // Set the launch activation context parameter on the toast.
                        // The context can be recovered through the app Activation event
                        toastContent.Launch = "reminder";

                        toastContent.TextHeading.Text  = "即将到站提醒";
                        toastContent.TextBodyWrap.Text = neareastInfo.caption + " 就要到了,请准备下车,以免坐过站";

                        this.notification            = toastContent.CreateNotification();
                        this.notification.Dismissed += toast_Dismissed;

                        ToastNotificationManager.CreateToastNotifier().Show(this.notification);
                        this.CurrentReminderStation.alertDisplaying = true;
                        this.loadView(typeof(ReminderPage));
                    }
                }
            }
        }