Beispiel #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);
        }
Beispiel #2
0
        /// <summary>
        /// Permet d'enregistrer un toast à afficher à une date précise
        /// </summary>
        /// <param name="titre">le titre du Toast</param>
        /// <param name="phrase">La phrase du toast</param>
        /// <param name="activationTime">la date d'activation</param>
        /// <param name="idNotif">l'id du toast</param>
        /// <param name="minute">le nombre de minutes avant une répétition (0 pour aucun)</param>
        /// <param name="repeat">le nombre de répétition (0 pour aucun)</param>
        public static void LancerToast(string titre, string phrase, DateTime activationTime, int idNotif, int minute, uint repeat)
        {
            //création du toast
            var toastContent = ToastContentFactory.CreateToastText02();

            toastContent.TextHeading.Text  = titre;
            toastContent.TextBodyWrap.Text = phrase;
            ScheduledToastNotification toast;

            if (minute > 0 && repeat > 0)
            {
                toast = new ScheduledToastNotification(toastContent.GetXml(), activationTime, TimeSpan.FromMinutes(minute), repeat)
                {
                    Id = idNotif.ToString()
                };
            }
            else
            {
                toast = new ScheduledToastNotification(toastContent.GetXml(), activationTime)
                {
                    Id = idNotif.ToString()
                };
            }
            ToastNotificationManager.CreateToastNotifier().AddToSchedule(toast);
        }
        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);
        }
Beispiel #4
0
        private void AttachNotifications(BackgroundUploader uploader, IUpload upload)
        {
            var successToast = ToastContentFactory.CreateToastText02();

            successToast.Audio.Content     = ToastAudioContent.SMS;
            successToast.TextHeading.Text  = _locService["Toast_Uploads_SuccessReturn_Text"];
            successToast.TextBodyWrap.Text = upload.Uploadable.Name;

            var successXml = successToast.GetXml();

            ToastAudioHelper.SetSuccessAudio(successXml);

            var successNotification = new ToastNotification(successXml);

            var failToast = ToastContentFactory.CreateToastText02();

            failToast.Audio.Content     = ToastAudioContent.IM;
            failToast.TextHeading.Text  = _locService["Toast_Uploads_Fail_Text"];
            failToast.TextBodyWrap.Text = upload.Uploadable.Name;

            var failXml = failToast.GetXml();

            ToastAudioHelper.SetFailAudio(failXml);

            var failNotification = new ToastNotification(failXml);

            uploader.SuccessToastNotification = successNotification;
            uploader.FailureToastNotification = failNotification;
        }
Beispiel #5
0
        private async void reminder_button_Click(object sender, RoutedEventArgs e)
        {
            MessageDialog showDialog = new MessageDialog("wenst u een reminder een half uur voor de afspraak ?");

            showDialog.Commands.Add(new UICommand("Ok")
            {
                Id = 0
            });
            showDialog.Commands.Add(new UICommand("Cancel")
            {
                Id = 1
            });
            showDialog.DefaultCommandIndex = 1;
            var result = await showDialog.ShowAsync();

            if ((int)result.Id == 1)
            {
                Frame.Navigate(typeof(Newsfeed));
            }
            if ((int)result.Id == 0)
            {
                String[] datumFormat       = datum.Text.Split('/');
                String[] tijdformat        = tijd.Text.Split(':');
                DateTime datumNotification = new DateTime(Int32.Parse(datumFormat[2]), Int32.Parse(datumFormat[0]), Int32.Parse(datumFormat[1]), Int32.Parse(tijdformat[0]), Int32.Parse(tijdformat[1]), Int32.Parse(tijdformat[2]));
                datumNotification.AddMinutes(-30);
                IToastText02 toast = ToastContentFactory.CreateToastText02();
                toast.TextHeading.Text  = newsitem.Titel;;
                toast.TextBodyWrap.Text = newsitem.Inhoud;
                ScheduledToastNotification toastNotification = new ScheduledToastNotification(toast.GetXml(), datumNotification);
                toastNotification.Id = "id";
                ToastNotificationManager.CreateToastNotifier().AddToSchedule(toastNotification);
                Frame.Navigate(typeof(Newsfeed));
            }
        }
        void ScheduleToast(String updateString, DateTime dueTime, int idNumber)
        {
            // Scheduled toasts use the same toast templates as all other kinds of toasts.
            IToastText02 toastContent = ToastContentFactory.CreateToastText02();

            toastContent.TextHeading.Text  = updateString;
            toastContent.TextBodyWrap.Text = "Received: " + dueTime.ToLocalTime();

            ScheduledToastNotification toast;

            if (RepeatBox.IsChecked != null && (bool)RepeatBox.IsChecked)
            {
                toast = new ScheduledToastNotification(toastContent.GetXml(), dueTime, TimeSpan.FromSeconds(60), 5);

                // You can specify an ID so that you can manage toasts later.
                // Make sure the ID is 15 characters or less.
                toast.Id = "Repeat" + idNumber;
            }
            else
            {
                toast    = new ScheduledToastNotification(toastContent.GetXml(), dueTime);
                toast.Id = "Toast" + idNumber;
            }

            ToastNotificationManager.CreateToastNotifier().AddToSchedule(toast);
            rootPage.NotifyUser("Scheduled a toast with ID: " + toast.Id, NotifyType.StatusMessage);
        }
Beispiel #7
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);
        }
        public void SubmitNewTask()
        {
            String   head   = taskHeader;
            String   cont   = taskContent;
            DateTime output = taskDate;

            String valid = Validate(head, cont, output);

            if (valid.Equals("true"))
            {
                //UKRYJ TWORZENIE KARTECZKi
                isNewTaskVisible = Visibility.Collapsed;
                taskHeader       = "";
                taskContent      = "";
                //taskDate = "";

                //STWORZ DATE ZE STRINGA
                //DateTime output;
                //DateTime.TryParseExact(dat, "dd.MM.yyyy", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out output);

                //UTWORZ KARTECZKE
                int  lastId = GetLastID();
                Note custom = new Note {
                    id = lastId, parentid = 0, header = head, content = cont, date = output
                };

                //ADD #1
                custom.header = custom.header + " #1";

                //UTWÓRZ NOW¥ LISTE
                var empty = new CollectionRepresentation {
                    NoteCollection = new ObservableCollection <Note>()
                };
                //DODAJ KARTECZKE DO LISTY
                empty.NoteCollection.Add(custom);
                //DODAJ LISTE DO GRIDVIEW
                NotesCollection.Add(empty);

                //WYSWIETL KOMUNIKAT SUKCESU
                IToastText02 notification = ToastContentFactory.CreateToastText02();
                notification.TextHeading.Text  = "Sukces";
                notification.TextBodyWrap.Text = "Utworzono now¹ karteczkê!";
                notification.Duration          = ToastDuration.Short;

                ToastNotification not = new ToastNotification(notification.GetXml());
                ToastNotificationManager.CreateToastNotifier().Show(not);
            }
            else
            {
                //WYSWIETL KOMUNIKAT BLEDU
                IToastText02 notification = ToastContentFactory.CreateToastText02();
                notification.TextHeading.Text  = "B³¹d";
                notification.TextBodyWrap.Text = valid;
                notification.Duration          = ToastDuration.Short;

                ToastNotification not = new ToastNotification(notification.GetXml());
                ToastNotificationManager.CreateToastNotifier().Show(not);
            }
        }
        private static IToastNotificationContent PrepareNotification(string title, string text, int id, string notificationProfile)
        {
            IToastText02 toastContent = ToastContentFactory.CreateToastText02();

            toastContent.TextHeading.Text  = title;
            toastContent.TextBodyWrap.Text = text;
            toastContent.Launch            = "-notification=" + id.ToString();

            return(toastContent);
        }
        public void NotificateAboutUpcomingTask()
        {
            if (Notificate == true && NotesCollection.Count > 0)
            {
                DateTime early = new DateTime(9999, 12, 30);
                String   head  = "";
                DateTime today = DateTime.Now.Date;
                foreach (CollectionRepresentation collection in NotesCollection)
                {
                    foreach (Note n in collection.NoteCollection)
                    {
                        if (n.date.CompareTo(early) < 0)
                        {
                            early = n.date;
                            head  = n.header;
                        }
                    }
                }

                //DISPLAY MSG TODAY
                if (early.Date.CompareTo(today) < 0)
                {
                    IToastText02 notification = ToastContentFactory.CreateToastText02();
                    notification.TextHeading.Text  = "Min¹³ termin zadania!";
                    notification.TextBodyWrap.Text = head;
                    notification.Duration          = ToastDuration.Short;

                    ToastNotification not = new ToastNotification(notification.GetXml());
                    not.ExpirationTime = DateTimeOffset.Now.AddSeconds(5);
                    ToastNotificationManager.CreateToastNotifier().Show(not);
                }
                else if (early.Date.CompareTo(today) == 0)
                {
                    IToastText02 notification = ToastContentFactory.CreateToastText02();
                    notification.TextHeading.Text  = "Dzisiaj mija termin zadania!";
                    notification.TextBodyWrap.Text = head;
                    notification.Duration          = ToastDuration.Short;

                    ToastNotification not = new ToastNotification(notification.GetXml());
                    not.ExpirationTime = DateTimeOffset.Now.AddSeconds(5);
                    ToastNotificationManager.CreateToastNotifier().Show(not);
                }
                else
                {
                    IToastText02 notification = ToastContentFactory.CreateToastText02();
                    notification.TextHeading.Text  = "Zbli¿a siê termin zadania!";
                    notification.TextBodyWrap.Text = head + " (" + early.Date.ToString("dd.MM.yyyy") + ")";
                    notification.Duration          = ToastDuration.Short;

                    ToastNotification not = new ToastNotification(notification.GetXml());
                    not.ExpirationTime = DateTimeOffset.Now.AddSeconds(5);
                    ToastNotificationManager.CreateToastNotifier().Show(not);
                }
            }
        }
Beispiel #11
0
 private async void NotificationButton_Click_1(object sender, RoutedEventArgs e)
 {
     if (await ValidateUri())
     {
         SetTitleAndText();
         var notification = ToastContentFactory.CreateToastText02();
         notification.TextHeading.Text  = _title;
         notification.TextBodyWrap.Text = _text;
         await PostToCloud(notification.CreateNotification().Content, "wns/toast");
     }
 }
Beispiel #12
0
        //toast notification function
        public static void CreateToast(string head, string body)
        {
            var toast = ToastContentFactory.CreateToastText02();

            toast.TextHeading.Text  = head;
            toast.TextBodyWrap.Text = body;

            ToastNotification t = toast.CreateNotification();

            ToastNotificationManager.CreateToastNotifier().Show(t);
        }
Beispiel #13
0
        private void SaveToast(string updatedString, DateTime dueTime, int id)
        {
            IToastText02 toastContent = ToastContentFactory.CreateToastText02();

            toastContent.TextHeading.Text  = updatedString;
            toastContent.TextBodyWrap.Text = "Notificare de la World Of Quizz!";

            ScheduledToastNotification toast;

            toast = new ScheduledToastNotification(toastContent.GetXml(), dueTime);
            ToastNotificationManager.CreateToastNotifier().AddToSchedule(toast);
        }
Beispiel #14
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());
        }
        private ToastNotification getToastNotification(string title, string describe)
        {
            var toastContent = ToastContentFactory.CreateToastText02();

            toastContent.TextHeading.Text  = title;
            toastContent.TextBodyWrap.Text = describe;
            toastContent.Audio.Content     = ToastAudioContent.LoopingAlarm;
            toastContent.Audio.Loop        = true;
            toastContent.Duration          = ToastDuration.Long;
            var toast = toastContent.CreateNotification();

            toast.ExpirationTime = null;
            return(toast);
        }
Beispiel #16
0
        public static void Display(string heading, string body)
        {
            IToastText02 templateContent = ToastContentFactory.CreateToastText02();

            templateContent.TextHeading.Text  = heading;
            templateContent.TextBodyWrap.Text = body;

            IToastNotificationContent toastContent = templateContent;

            toastContent.Duration = ToastDuration.Short;
            ToastNotification toast = toastContent.CreateNotification();

            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
Beispiel #17
0
        void ScheduleToast(String updateString, DateTime dueTime, int idNumber)
        {
            IToastText02 toastContent = ToastContentFactory.CreateToastText02();

            toastContent.TextHeading.Text  = updateString;
            toastContent.TextBodyWrap.Text = "Received: " + dueTime.ToLocalTime();

            ScheduledToastNotification toast;

            toast    = new ScheduledToastNotification(toastContent.GetXml(), dueTime);
            toast.Id = "Toast" + idNumber;

            ToastNotificationManager.CreateToastNotifier().AddToSchedule(toast);

            noti.Text = "Toast ID: " + toast.Id;
        }
        void DisplayTextToast(ToastTemplateType templateType)
        {
            // Creates a toast using the notification object model, which is another project
            // in this solution.  For an example using Xml manipulation, see the function
            // DisplayToastUsingXmlManipulation below.
            IToastNotificationContent toastContent = null;

            if (templateType == ToastTemplateType.ToastText01)
            {
                IToastText01 templateContent = ToastContentFactory.CreateToastText01();
                templateContent.TextBodyWrap.Text = "Body text that wraps over three lines";
                toastContent = templateContent;
            }
            else if (templateType == ToastTemplateType.ToastText02)
            {
                IToastText02 templateContent = ToastContentFactory.CreateToastText02();
                templateContent.TextHeading.Text  = "Heading text";
                templateContent.TextBodyWrap.Text = "Body text that wraps over two lines";
                toastContent = templateContent;
            }
            else if (templateType == ToastTemplateType.ToastText03)
            {
                IToastText03 templateContent = ToastContentFactory.CreateToastText03();
                templateContent.TextHeadingWrap.Text = "Heading text that is very long and wraps over two lines";
                templateContent.TextBody.Text        = "Body text";
                toastContent = templateContent;
            }
            else if (templateType == ToastTemplateType.ToastText04)
            {
                IToastText04 templateContent = ToastContentFactory.CreateToastText04();
                templateContent.TextHeading.Text = "Heading text";
                templateContent.TextBody1.Text   = "First body text";
                templateContent.TextBody2.Text   = "Second body text";
                toastContent = templateContent;
            }

            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);
        }
Beispiel #19
0
        private void SendNotification(Customer customer)
        {
            var clientId      = ConfigurationManager.AppSettings["ClientId"];
            var clientSecret  = ConfigurationManager.AppSettings["ClientSecret"];
            var tokenProvider = new WnsAccessTokenProvider(clientId, clientSecret);
            var notification  = ToastContentFactory.CreateToastText02();

            notification.TextHeading.Text  = "New customer added!";
            notification.TextBodyWrap.Text = customer.Name;

            var channels = db.Channels;

            foreach (var channel in channels)
            {
                var result = notification.Send(new Uri(channel.Uri), tokenProvider);
            }
        }
        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);
        }
Beispiel #21
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));
        }
        /// <summary>
        ///     토스트
        /// </summary>
        /// <param name="body"></param>
        /// <param name="header"></param>
        public override void ToastShow(string body, string header = null)
        {
            IToastNotificationContent templateContent;

            if (header == null)
            {
                templateContent = ToastContentFactory.CreateToastText01();
                ((IToastText01)templateContent).TextBodyWrap.Text = body;
            }
            else
            {
                templateContent = ToastContentFactory.CreateToastText02();
                ((IToastText02)templateContent).TextHeading.Text  = header;
                ((IToastText02)templateContent).TextBodyWrap.Text = body;
            }

            ToastNotification toast = templateContent.CreateNotification();

            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
Beispiel #23
0
        private void AttachNotifications(BackgroundDownloader downloader, IDownloadable download)
        {
            if (!_settingsService.Get(AppConstants.PUSH_NOTIFICATIONS_PARAMETER, true))
            {
                return;
            }

            string name = null;

            if (download.ContentType == FileContentType.Music)
            {
                name = ((VKSaverAudio)download.Metadata).Track.Title;
            }
            else
            {
                name = download.FileName;
            }

            var successToast = ToastContentFactory.CreateToastText02();

            successToast.Audio.Content     = ToastAudioContent.SMS;
            successToast.TextHeading.Text  = _locService["Toast_Downloads_Success_Text"];
            successToast.TextBodyWrap.Text = name;

            var successXml = successToast.GetXml();

            ToastAudioHelper.SetSuccessAudio(successXml);

            var failToast = ToastContentFactory.CreateToastText02();

            failToast.Audio.Content     = ToastAudioContent.IM;
            failToast.TextHeading.Text  = _locService["Toast_Downloads_Fail_Text"];
            failToast.TextBodyWrap.Text = name;

            var failXml = failToast.GetXml();

            ToastAudioHelper.SetFailAudio(failXml);

            downloader.SuccessToastNotification = new ToastNotification(successXml);
            downloader.FailureToastNotification = new ToastNotification(failXml);
        }
Beispiel #24
0
        private void ShowToasts()
        {
            var toastManager = ToastNotificationManager.CreateToastNotifier();

            // Show toast
            foreach (var notification in _notifications.Where(x => !x.Read))
            {
                if (_previousToastIds.Contains(notification.NotificationId))
                {
                    continue;
                }

                var toastNotification = ToastContentFactory.CreateToastText02();
                toastNotification.Launch            = HandleNotificationType(notification, toastNotification);
                toastNotification.TextBodyWrap.Text = notification.Text;

                var toast = toastNotification.CreateNotification();
                toast.Tag = notification.NotificationId;
                toastManager.Show(toast);

                _previousToastIds.Add(notification.NotificationId);
            }
        }
Beispiel #25
0
        public static void ScheduleToast(string updateString, int eventID, DateTime dueTime, bool RepeatToast = false)
        {
            if (dueTime < DateTime.Now)
            {
                return;
            }
            //Random rand = new Random();
            //int idNumber = rand.Next(0, 10000000);
            // Scheduled toasts use the same toast templates as all other kinds of toasts.
            //ToastContent toastContent = To
            IToastText02 toastContent = ToastContentFactory.CreateToastText02();

            toastContent.TextHeading.Text = updateString;
            //toastContent.TextBodyWrap.Text = "Received: " + dueTime.ToLocalTime();

            ScheduledToastNotification toast;

            //Этот код нужен если отложить напоминайку
            if (RepeatToast == true)
            {
                toast = new ScheduledToastNotification(toastContent.GetXml(), dueTime, TimeSpan.FromSeconds(60), 5);

                // You can specify an ID so that you can manage toasts later.
                // Make sure the ID is 15 characters or less.
                //toast.Id = "Repeat" + eventID;
            }
            else
            {
                toast = new ScheduledToastNotification(toastContent.GetXml(), dueTime);
            }
            toast.Id = eventID.ToString();
            //Everyday.listNotrfications.Add(toast.Id);
            ToastNotifier notifier = ToastNotificationManager.CreateToastNotifier();

            notifier.AddToSchedule(toast);
            //NotifyUser("Event scheduled on " + dueTime + ", a toast with ID: " + toast.Id, NotifyType.StatusMessage);
        }
Beispiel #26
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);
        }
Beispiel #27
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);
        }
Beispiel #28
0
        public TestPageOld()
        {
            InitializeComponent();

            Logout                 = new RelayCommand(() => VKHelper.Reset());
            GetUniqueDeviceID      = new RelayCommand(async() => await(new MessageDialog(CoreHelper.GetUniqueDeviceID(), "UniqueDeviceID")).ShowAsync());
            GetDeviceName          = new RelayCommand(async() => await(new MessageDialog(CoreHelper.GetDeviceName(), "DeviceName")).ShowAsync());
            GetOperatingSystemName = new RelayCommand(async() => await(new MessageDialog(CoreHelper.GetOperatingSystemName(), "OperatingSystem")).ShowAsync());
            CaptchaForce           = new RelayCommand(async() => await(new CaptchaForceRequest()).ExecuteAsync());
            ShowLocalFolderPath    = new RelayCommand(async() => await(new MessageDialog(ApplicationData.Current.LocalFolder.Path, "LocalFolder Path")).ShowAsync());
            TurnOnNotification     = new RelayCommand(async() =>
            {
                bool result = await NotificationsHelper.Connect();
                await(new MessageDialog(result ? "Success" : "Fail", "Push notifications")).ShowAsync();
            });

            TestMessageFlags = new RelayCommand(async() =>
            {
                var flags = (VKMessageFlags)243;
                await(new MessageDialog(flags.ToString(), "243 as VKMessageFlags")).ShowAsync();
                flags = (VKMessageFlags)241;
                await(new MessageDialog(flags.ToString(), "241 as VKMessageFlags")).ShowAsync();
            });
            StartLongPolling = new RelayCommand(() =>
            {
                ServiceHelper.VKLongPollService.StartLongPolling();
                StopLongPolling.RaiseCanExecuteChanged();
                StartLongPolling.RaiseCanExecuteChanged();
            }, () => true);
            StopLongPolling = new RelayCommand(() =>
            {
                ServiceHelper.VKLongPollService.StopLongPolling();
                StartLongPolling.RaiseCanExecuteChanged();
                StopLongPolling.RaiseCanExecuteChanged();
            }, () => true);

            ShowToast = new RelayCommand(() =>
            {
                ((ChromeFrame)Frame).ShowPopup(new PopupMessage
                {
                    Title     = "Добро пожаловать в OneVK", Content = "Это уведомление вернет вас на тестовую страницу",
                    Parameter = new NavigateToPageMessage()
                    {
                        Page = AppViews.TestView
                    },
                    Type = PopupMessageType.Info
                });
            });

            GoToBotView = new RelayCommand(() =>
            {
                Messenger.Default.Send <NavigateToPageMessage>(new NavigateToPageMessage
                {
                    Page      = AppViews.BotView,
                    Operation = NavigationType.New
                });
            });
            GoToBlankPage = new RelayCommand(() => Frame.Navigate(typeof(BlankPage1)));

            ClearBadgeTile = new RelayCommand(() =>
            {
                BadgeUpdateManager.CreateBadgeUpdaterForApplication().Clear();
            });

            SendBadgeTile = new RelayCommand(() =>
            {
                var badge = new BadgeNumericNotificationContent(7).CreateNotification();
                BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badge);
            });

            SendMessageTile = new RelayCommand(() =>
            {
                var tile           = TileContentFactory.CreateTileSquare150x150IconWithBadge();
                tile.ImageIcon.Src = "ms-appx:///Assets/BadgeIcon.png";
                TileUpdateManager.CreateTileUpdaterForApplication().Update(tile.CreateNotification());

                var badge = new BadgeNumericNotificationContent(7).CreateNotification();
                BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badge);
            });

            SendToast = new RelayCommand(() =>
            {
                var toast               = ToastContentFactory.CreateToastText02();
                toast.Audio.Content     = ToastAudioContent.IM;
                toast.Duration          = ToastDuration.Long;
                toast.TextHeading.Text  = "OneVK";
                toast.TextBodyWrap.Text = "Это тестовое уведомление";

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

            StartVKSaver = new RelayCommand(async() =>
            {
                IVKSaverCommand command = new VKSaverStartAppCommand();
                await command.TryExecute();
            });
        }
Beispiel #29
0
        public static void DisplayTextToast(ToastTemplateType templateType, string fromId, string content, string imageUri)
        {
            // Creates a toast using the notification object model, which is another project
            // in this solution.  For an example using Xml manipulation, see the function
            // DisplayToastUsingXmlManipulation below.
            IToastNotificationContent toastContent = null;

            if (templateType == ToastTemplateType.ToastText01)
            {
                IToastText01 templateContent = ToastContentFactory.CreateToastText01();
                templateContent.TextBodyWrap.Text = "Body text that wraps over three lines";
                toastContent = templateContent;
            }
            else if (templateType == ToastTemplateType.ToastText02)
            {
                IToastText02 templateContent = ToastContentFactory.CreateToastText02();
                templateContent.TextHeading.Text  = "Heading text";
                templateContent.TextBodyWrap.Text = "Body text that wraps over two lines";
                toastContent = templateContent;
            }
            else if (templateType == ToastTemplateType.ToastText03)
            {
                IToastText03 templateContent = ToastContentFactory.CreateToastText03();
                templateContent.TextHeadingWrap.Text = "Heading text that is very long and wraps over two lines";
                templateContent.TextBody.Text        = "Body text";
                toastContent = templateContent;
            }
            else if (templateType == ToastTemplateType.ToastText04)
            {
                IToastText04 templateContent = ToastContentFactory.CreateToastText04();
                templateContent.TextHeading.Text = "Heading text";
                templateContent.TextBody1.Text   = "First body text";
                templateContent.TextBody2.Text   = "Second body text";
                toastContent = templateContent;
            }
            else if (templateType == ToastTemplateType.ToastImageAndText01)
            {
                IToastImageAndText01 templateContent = ToastContentFactory.CreateToastImageAndText01();
                if (String.IsNullOrWhiteSpace(content) == false)
                {
                    templateContent.TextBodyWrap.Text = content;
                }
                else
                {
                    templateContent.TextBodyWrap.Text = "text here!";
                }

                if (String.IsNullOrWhiteSpace(imageUri) == false)
                {
                    templateContent.Image.Src = imageUri;
                }
                else
                {
                    templateContent.Image.Src = "http://singularlabs.com/wp-content/uploads/2011/11/System-Ninja-2.2.png";
                }

                toastContent = templateContent;
            }

            // Create a toast, then create a ToastNotifier object to show
            // the toast
            ToastNotification           toast = toastContent.CreateNotification();
            Dictionary <String, String> args  = new Dictionary <String, String>();

            args.Add("fromId", fromId);
            args.Add("content", content);
            //toast.Activated += ToastTapped(toast, args);
            toast.Activated += new TypedEventHandler <ToastNotification, object>((sender, e) => ToastTapped(toast, args));
            // 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);
        }
Beispiel #30
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));
                    }
                }
            }
        }