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); }
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 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); }
/// <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); }
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); }
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 string HandleNotificationType(Notification notification, IToastText02 toastNotification) { if (notification == null) { return("Viddi://"); } var type = notification.NotificationType; var notificationParameter = "¬ificationId=" + notification.NotificationId; switch (type) { case NotificationType.ChannelSubscribed: toastNotification.TextHeading.Text = Resources.NotificationChannelSubscription; var channel = notification.Channel; if (channel != null) { return(channel.ToViddiLink() + notificationParameter); } break; case NotificationType.UserSubscribed: toastNotification.TextHeading.Text = Resources.NotificationUserSubscription; var user = notification.User; if (user != null) { return(user.ToViddiLink() + notificationParameter); } break; case NotificationType.CommentReply: case NotificationType.VideoComment: case NotificationType.VideoUpVoted: if (type == NotificationType.CommentReply) { toastNotification.TextHeading.Text = Resources.NotificationCommentReply; } else if (type == NotificationType.VideoComment) { toastNotification.TextHeading.Text = Resources.NotificationVideoComment; } else if (type == NotificationType.VideoUpVoted) { toastNotification.TextHeading.Text = Resources.NotificationVideoUpVote; } var video = notification.Video; if (video != null) { return(video.ToViddiLink() + notificationParameter); } break; } return("Viddi://"); }
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); } } }
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); }
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()); }
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); }
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); }
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); }
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)); }
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); }
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); }
/// <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); }
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); }
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)); } } } }