private static ScheduledToastNotification GenerateAlarmNotification(MyRemind remind) { ToastContent content = new ToastContent() { Scenario = ToastScenario.Alarm, Visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = $"提醒: {remind.Title}" }, new AdaptiveText() { Text = remind.Content } } } }, Actions = new ToastActionsSnoozeAndDismiss()//自动创建一个自动本地化的有延迟提醒时间间隔,贪睡和取消的按钮,贪睡时间由系统自动处理 }; return new ScheduledToastNotification(content.GetXml(), remind.time) { Tag = GetTag(remind) }; }
private ToastNotification CreateToastNotification(int ping, double downloadSpeed, double uploadSpeed) { ToastVisual toastVisual = this.CreateToastVisual(ping, downloadSpeed, uploadSpeed); ToastContent toastContent = this.CreateToastContent(toastVisual); ToastNotification toast = new ToastNotification(toastContent.GetXml()); return(toast); }
public static void SendToast(ToastVisual visual) { ToastContent tcontent = new ToastContent() { Visual = visual }; var toast = new ToastNotification(tcontent.GetXml()); ToastNotificationManager.CreateToastNotifier().Show(toast); }
public void ShowScheduledMessage(string name, string message, int id, bool silent, DateTime time) { //Dont set the past time notification if (time < DateTime.Now) { return; } //Toast template ToastContent toastContent = new ToastContent { Launch = "app-defined-string", Visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = name, HintMaxLines = 1 }, new AdaptiveText() { Text = message }, //new AdaptiveText() //{ // Text = "10:00 AM - 10:30 AM" //} } } }, Actions = new ToastActionsCustom() { }, Audio = new ToastAudio() { Src = new Uri("ms-appx:///Assets/NewMessage.mp3"), Silent = silent } }; XmlDocument doc = toastContent.GetXml(); ScheduledToastNotification toast = new ScheduledToastNotification(doc, time) { Id = id.ToString() }; ToastNotificationManager.CreateToastNotifier().AddToSchedule(toast); }
public void ShowToastNotificationSample() { // Create the toast content var content = new ToastContent() { // More about the Launch property at https://docs.microsoft.com/dotnet/api/microsoft.toolkit.uwp.notifications.toastcontent Launch = "ToastContentActivationParams", Visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = "Sample Toast Notification" }, new AdaptiveText() { Text = @"Click OK to see how activation from a toast notification can be handled in the ToastNotificationService." } } } }, Actions = new ToastActionsCustom() { Buttons = { // More about Toast Buttons at https://docs.microsoft.com/dotnet/api/microsoft.toolkit.uwp.notifications.toastbutton new ToastButton("OK", "ToastButtonActivationArguments") { ActivationType = ToastActivationType.Foreground }, new ToastButtonDismiss("Cancel") } } }; // Add the content to the toast var toast = new ToastNotification(content.GetXml()) { // TODO WTS: Set a unique identifier for this notification within the notification group. (optional) // More details at https://docs.microsoft.com/uwp/api/windows.ui.notifications.toastnotification.tag Tag = "ToastTag" }; // And show the toast //ShowToastNotification(toast); }
async Task PushToast(string keyword) { var result = (await QueryEngine.QueryEngine.MainDictQueryEngine.QueryForUIAsync(StringHelper.ResolveReplicator(keyword))).GroupBy(x => x.ItemId).Select(g => new GroupedDictItem(g)).First(); string parameters = new QueryString() { { "action", "detailResult" }, { "keyword", keyword } }.ToString(); var toastContent = new ToastContent() { Visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { } }, Actions = new ToastActionsCustom() { Buttons = { new ToastButton("详细", parameters) { ActivationType = ToastActivationType.Foreground } } }, Launch = parameters }; string header = ""; if (!string.IsNullOrEmpty(result.Kanji)) { header = $"{result.Kanji}({result.Reading})"; } else { header = result.Keyword; } toastContent.Visual.BindingGeneric.Children.Add(new AdaptiveText() { Text = header }); foreach (var r in result) { toastContent.Visual.BindingGeneric.Children.Add(new AdaptiveText() { Text = r.Pos + " " + r.Definition }); } // Create the toast notification var toastNotif = new ToastNotification(toastContent.GetXml()); // And send the notification ToastNotificationManager.CreateToastNotifier().Show(toastNotif); }
public void ShowToastNotificationSample() { // Create the toast content var content = new ToastContent() { // TODO UWPTemplates: Check this documentation to know more about the Launch property // Documentation: https://developer.microsoft.com/en-us/windows/uwp-community-toolkit/api/microsoft_toolkit_uwp_notifications_toastcontent Launch = "ToastContentActivationParams", Visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = "Sample Toast Notification" }, new AdaptiveText() { Text = @"Click OK to see how activation from a toast notification can be handled in the ToastNotificationService." } } } }, Actions = new ToastActionsCustom() { Buttons = { // TODO UWPTemplates: Check this documentation to know more about Toast Buttons // Documentation: https://developer.microsoft.com/en-us/windows/uwp-community-toolkit/api/microsoft_toolkit_uwp_notifications_toastbutton new ToastButton("OK", "ToastButtonActivationArguments") { ActivationType = ToastActivationType.Foreground }, new ToastButtonDismiss("Cancel") } } }; // Create the toast var toast = new ToastNotification(content.GetXml()) { // TODO UWPTemplates: Gets or sets the unique identifier of this notification within the notification Group. Max length 16 characters. // Documentation: https://docs.microsoft.com/uwp/api/windows.ui.notifications.toastnotification Tag = "ToastTag" }; // And show the toast ShowToastNotification(toast); }
private void Copy_Click(object sender, RoutedEventArgs e) { //复制色卡内容到剪贴板 DataPackage dataPackage = new DataPackage(); dataPackage.RequestedOperation = DataPackageOperation.Copy; String text = "「色卡推荐」\n"; foreach (Color color in _card.Colors) { text += (_card.Colors.IndexOf(color) + 1).ToString() + "."; text += color.RGB + "\n"; } dataPackage.SetText(text); Clipboard.SetContent(dataPackage); //构造通知内容 string title = "色卡已复制到剪贴板"; string content = text; content = content.Replace("「色卡推荐」\n", ""); ToastVisual visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = title }, new AdaptiveText() { Text = content }, } } }; int conversationId = 1; ToastContent toastContent = new ToastContent() { Visual = visual, //Actions = actions, // Arguments when the user taps body of toast Launch = new QueryString() { { "action", "viewConversation" }, { "conversationId", conversationId.ToString() } }.ToString() }; var toast = new ToastNotification(toastContent.GetXml()); toast.ExpirationTime = DateTime.Now.AddMinutes(1); ToastNotificationManager.CreateToastNotifier().Show(toast); }
private static void SendUpdatableToastWithProgressForTranscode(StorageFile SourceFile, StorageFile DestinationFile) { string Tag = "TranscodeNotification"; ToastContent content = new ToastContent() { Launch = "Transcode", Scenario = ToastScenario.Reminder, Visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = $"{Globalization.GetString("Transcode_Toast_Title")} {SourceFile.Name}" }, new AdaptiveProgressBar() { Title = SourceFile.FileType.Substring(1).ToUpper()+" ⋙⋙⋙⋙ "+DestinationFile.FileType.Substring(1).ToUpper(), Value = new BindableProgressBarValue("ProgressValue"), ValueStringOverride = new BindableString("ProgressValueString"), Status = new BindableString("ProgressStatus") } } } } }; NotificationData Data = new NotificationData { SequenceNumber = 0 }; Data.Values["ProgressValue"] = "0"; Data.Values["ProgressValueString"] = "0%"; Data.Values["ProgressStatus"] = Globalization.GetString("Toast_ClickToCancel_Text"); ToastNotification Toast = new ToastNotification(content.GetXml()) { Tag = Tag, Data = Data }; Toast.Activated += (s, e) => { if (s.Tag == "TranscodeNotification") { AVTranscodeCancellation.Cancel(); } }; ToastNotificationManager.CreateToastNotifier().Show(Toast); }
public static ToastNotification CreateToastNotification(string title, string content, string filePath) { ToastContent toastContent = new ToastContent() { Visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = title }, new AdaptiveText() { Text = content }, }, AppLogoOverride = new ToastGenericAppLogo() { Source = "ms-appx:///Assets/Icon/ic_done_white_48dp.png", HintCrop = ToastGenericAppLogoCrop.Default }, HeroImage = new ToastGenericHeroImage() { Source = filePath, AlternateText = Path.GetFileName(filePath) } } }, Actions = new ToastActionsCustom() { Buttons = { new ToastButton("Set as wallpaper", new QueryString() { { Key.ACTION_KEY, Value.SET_AS}, { Key.FILE_PATH_KEY, filePath } }.ToString()) } }, Launch = new QueryString() { { Key.ACTION_KEY, Value.DOWNLOADS }, }.ToString() }; return(new ToastNotification(toastContent.GetXml())); }
public void CreateNotification(TodoItem todo) { foreach (var item in ToastNotificationManager.CreateToastNotifier().GetScheduledToastNotifications()) { if (item.Id == todo.ID.ToString()) { ToastNotificationManager.CreateToastNotifier().RemoveFromSchedule(item); } } //Nuget Packacke UWP.ToastNotification var content = new ToastContent() { // More about the Launch property at https://docs.microsoft.com/dotnet/api/microsoft.toolkit.uwp.notifications.toastcontent Launch = "ToastContentActivationParams", Visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = "TODO ist fällig!" }, new AdaptiveText() { Text = $"{todo.Title}: {todo.Description}" } } } }, Actions = new ToastActionsCustom() { Buttons = { // More about Toast Buttons at https://docs.microsoft.com/dotnet/api/microsoft.toolkit.uwp.notifications.toastbutton new ToastButton("Anzeigen", todo.ID.ToString()) { ActivationType = ToastActivationType.Foreground }, new ToastButtonDismiss("Abbrechen") } } }; var toast = new ScheduledToastNotification(content.GetXml(), todo.TimeDue); toast.Id = todo.ID.ToString(); ToastNotificationManager.CreateToastNotifier().AddToSchedule(toast); }
private void CreateToast(string Schedule_name, string tipText, int dayNum) { string text; if (dayNum == 0) { text = "日程到期提醒:" + Schedule_name; } else { text = Schedule_name + ",还有" + dayNum + "天"; } var toastContent = new ToastContent() { Visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = text }, new AdaptiveText() { Text = tipText } } } }, Actions = new ToastActionsCustom() { Buttons = { new ToastButton("打开夏日", "action") { ActivationType = ToastActivationType.Foreground } } }, Audio = new ToastAudio() { Src = new Uri("ms-winsoundevent:Notification.Looping.Alarm") } }; // Create the toast notification var toastNotif = new ToastNotification(toastContent.GetXml()); toastNotif.ExpirationTime = DateTime.Now.AddDays(1); // And send the notification ToastNotificationManager.CreateToastNotifier().Show(toastNotif); }
/// <summary> /// Show toast text notification and app logo. /// </summary> /// <param name="title">Title to show in the notification.</param> /// <param name="text">Text to show in the notification.</param> /// <param name="duration"> /// How long (in seconds) will the notification be visible in the /// action center. Default is 5 seconds. /// To keep the system default value set zero or a negative value. /// </param> public static void ShowTextNotification(string title, string text, int duration = 5) { try { var visual = new ToastVisual { BindingGeneric = new ToastBindingGeneric { Children = { new AdaptiveText { Text = title }, new AdaptiveText { Text = text } }, AppLogoOverride = new ToastGenericAppLogo { Source = LogoUri, HintCrop = ToastGenericAppLogoCrop.Circle } } }; var toastContent = new ToastContent { Visual = visual, Audio = new ToastAudio() { Silent = true }, }; var toast = new ToastNotification(toastContent.GetXml()); if (duration > 0) { toast.ExpirationTime = new DateTimeOffset(DateTime.Now.AddSeconds(duration)); } try { ToastNotificationManager.CreateToastNotifier().Show(toast); } catch (Exception e) { LogService.Log(MLogLevel.LOG_LEVEL_WARNING, "Error showing toast notification", e); UiService.OnUiThread(async() => await DialogService.ShowAlertAsync(title, text)); } } catch (Exception e) { LogService.Log(MLogLevel.LOG_LEVEL_WARNING, "Error creating toast notification", e); UiService.OnUiThread(async() => await DialogService.ShowAlertAsync(title, text)); } }
public void SendToast() { var visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = title }, new AdaptiveText() { Text = content } } } }; if (!(string.IsNullOrEmpty(image))) { visual.BindingGeneric.Children.Add(new AdaptiveImage() { Source = image }); } if (!(string.IsNullOrEmpty(logo))) { visual.BindingGeneric.AppLogoOverride = new ToastGenericAppLogo() { Source = logo, HintCrop = ToastGenericAppLogoCrop.Circle }; } var toastContent = new ToastContent() { Visual = visual, Launch = new QueryString() { { launch.Key, launch.Value } }.ToString() }; var toast = new ToastNotification(toastContent.GetXml()); toast.ExpirationTime = DateTime.Now.AddDays(7); toast.Tag = tag; toast.Group = group; ToastNotificationManager.CreateToastNotifier().Show(toast); }
private static void SendUpdatableToastWithProgressForMergeVideo() { ToastContent content = new ToastContent() { Launch = "Transcode", Scenario = ToastScenario.Reminder, Visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = Globalization.GetString("Merge_Toast_ProbarTitle") }, new AdaptiveProgressBar() { Title = Globalization.GetString("Merge_Toast_ProbarTitle"), Value = new BindableProgressBarValue("ProgressValue"), ValueStringOverride = new BindableString("ProgressValueString"), Status = new BindableString("ProgressStatus") } } } } }; NotificationData Data = new NotificationData { SequenceNumber = 0 }; Data.Values["ProgressValue"] = "0"; Data.Values["ProgressValueString"] = "0%"; Data.Values["ProgressStatus"] = Globalization.GetString("Toast_ClickToCancel_Text"); ToastNotification Toast = new ToastNotification(content.GetXml()) { Tag = "MergeVideoNotification", Data = Data }; Toast.Activated += (s, e) => { if (s.Tag == "MergeVideoNotification") { AVTranscodeCancellation.Cancel(); } }; ToastNotificationManager.CreateToastNotifier().Show(Toast); }
public async Task Send(Notification notification) { if (notification.Id == 0) { notification.Id = this.settings.IncrementValue("NotificationId"); } if (notification.ScheduleDate != null) { await this.repository.Set(notification.Id.ToString(), notification); return; } var toastContent = new ToastContent { Duration = notification.Windows.UseLongDuration ? ToastDuration.Long : ToastDuration.Short, Launch = notification.Payload, ActivationType = ToastActivationType.Background, Visual = new ToastVisual { BindingGeneric = new ToastBindingGeneric { Children = { new AdaptiveText { Text = notification.Title }, new AdaptiveText { Text = notification.Message } } } } }; if (!Notification.CustomSoundFilePath.IsEmpty()) { toastContent.Audio = new ToastAudio { Src = new Uri(Notification.CustomSoundFilePath) } } ; this.toastNotifier.Show(new ToastNotification(toastContent.GetXml())); if (notification.BadgeCount != null) { await this.SetBadge(notification.BadgeCount.Value); } await this.services.SafeResolveAndExecute <INotificationDelegate>(x => x.OnReceived(notification)); }
//Note: You can update or replace a toast notification by updating/sending another toast using //The same tag and group as the original toast. public static void SendUpdatableToastWithProgress(double progress) { // Define a tag value and a group value to uniquely identify a notification, in order to target it to apply the update later; string toastTag = "appInstall"; string toastGroup = "Install1"; // Construct the toast content with updatable data fields inside; var content = new ToastContent() { Visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = new BindableString("changingText4Mobile") }, new AdaptiveProgressBar() { Title = "Progress", Value = new BindableProgressBarValue("progressValue"), ValueStringOverride = new BindableString("progressString"), Status = new BindableString("progressStatus") } } } } }; // Generate the toast notification; var toast = new ToastNotification(content.GetXml()); // Assign the tag and group properties; toast.Tag = toastTag; toast.Group = toastGroup; // Define NotificationData property and add it to the toast notification to bind the initial data; // Data.Values are assigned with string values; toast.Data = new NotificationData(); toast.Data.Values["progressValue"] = String.Format("{0}", progress / 100); toast.Data.Values["progressString"] = String.Format("{0}%", progress); toast.Data.Values["progressStatus"] = "Installing"; toast.Data.Values["changingText4Mobile"] = String.Format("Install Progress at {0}%", progress); // Provide sequence number to prevent updating out-of-order or assign it with value 0 to indicate "always update"; toast.Data.SequenceNumber = 1; // Show the toast notification to the user; ToastNotificationManager.CreateToastNotifier().Show(toast); }
public void ShowToastNotificationSample() { // Create the toast content var content = new ToastContent() { // More about the Launch property at https://docs.microsoft.com/dotnet/api/microsoft.toolkit.uwp.notifications.toastcontent Launch = "ToastContentActivationParams", Visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = "BENVENUTO IN PIANTE E FIORI" }, new AdaptiveText() { Text = @"Visualizza le schede botaniche o crea un promemoria sul calendario!" } } } }, Actions = new ToastActionsCustom() { Buttons = { // More about Toast Buttons at https://docs.microsoft.com/dotnet/api/microsoft.toolkit.uwp.notifications.toastbutton new ToastButton("OK", "ToastButtonActivationArguments") { ActivationType = ToastActivationType.Foreground }, new ToastButtonDismiss("Cancel") } } }; // Add the content to the toast var toast = new ToastNotification(content.GetXml()) { // TODO WTS: Set a unique identifier for this notification within the notification group. (optional) // More details at https://docs.microsoft.com/uwp/api/windows.ui.notifications.toastnotification.tag Tag = "ToastTag" }; // And show the toast ShowToastNotification(toast); }
private static ToastNotification PopToast(ToastContent content) { ToastNotification toast = new ToastNotification(content.GetXml()) { Data = new NotificationData() }; OnChatMessageToastEventArgs args = new OnChatMessageToastEventArgs(toast, null); OnChatMessageToast?.Invoke(args); PopToast(toast, args); return(toast); }
public void ShowToastNotificationSample() { // Create the toast content var content = new ToastContent() { // More about the Launch property at https://developer.microsoft.com/en-us/windows/uwp-community-toolkit/api/microsoft_toolkit_uwp_notifications_toastcontent Launch = "ToastContentActivationParams", Visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = "Intelligent Identificator Security System" }, new AdaptiveText() { Text = @"Welcome to IISS, now you will be able to interact with the System, please be careful to read the Users Guide for better performance." } } } }, Actions = new ToastActionsCustom() { Buttons = { // More about Toast Buttons at https://developer.microsoft.com/en-us/windows/uwp-community-toolkit/api/microsoft_toolkit_uwp_notifications_toastbutton new ToastButton("OK", "ToastButtonActivationArguments") { ActivationType = ToastActivationType.Foreground }, new ToastButtonDismiss("Cancel") } } }; // Add the content to the toast var toast = new ToastNotification(content.GetXml()) { // TODO WTS: Set a unique identifier for this notification within the notification group. (optional) // More details at https://docs.microsoft.com/en-gb/uwp/api/windows.ui.notifications.toastnotification#Windows_UI_Notifications_ToastNotification_Tag Tag = "jpd21122012" }; // And show the toast ShowToastNotification(toast); }
public void ShowToastNotificationSample() { // Create the toast content var content = new ToastContent() { // More about the Launch property at https://docs.microsoft.com/dotnet/api/microsoft.toolkit.uwp.notifications.toastcontent Launch = "ToastContentActivationParams", Visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = "推送消息示例" }, new AdaptiveText() { Text = @"看到此消息表明您的设备设置正确。可以收到订阅的新闻和公共基础设施状态变更消息。" } } } }, Actions = new ToastActionsCustom() { Buttons = { // More about Toast Buttons at https://docs.microsoft.com/dotnet/api/microsoft.toolkit.uwp.notifications.toastbutton new ToastButton("👌好的", "ToastButtonActivationArguments") { ActivationType = ToastActivationType.Foreground }, new ToastButtonDismiss("🤚删除") } } }; // Add the content to the toast var toast = new ToastNotification(content.GetXml()) { // TODO WTS: Set a unique identifier for this notification within the notification group. (optional) // More details at https://docs.microsoft.com/uwp/api/windows.ui.notifications.toastnotification.tag Tag = "ToastTag" }; // And show the toast ShowToastNotification(toast); }
/// <summary> /// Metoda wyświetlająca przykładowe powiadomienie w systemie Windows /// </summary> public async Task ShowToastNotificationSampleAsync() { // Create the toast content var content = new ToastContent() { // More about the Launch property at https://docs.microsoft.com/dotnet/api/microsoft.toolkit.uwp.notifications.toastcontent Launch = "ToastContentActivationParams", Visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = "Przykładowe powiadomienie" }, new AdaptiveText() { Text = "Naciśnij przycisk OK, aby zamknąć powiadomienie." } } } }, Actions = new ToastActionsCustom() { Buttons = { // More about Toast Buttons at https://docs.microsoft.com/dotnet/api/microsoft.toolkit.uwp.notifications.toastbutton new ToastButton("OK", "ToastButtonActivationArguments") { ActivationType = ToastActivationType.Foreground }, new ToastButtonDismiss("Cancel") } } }; // Add the content to the toast var toast = new ToastNotification(content.GetXml()) { // TODO WTS: Set a unique identifier for this notification within the notification group. (optional) // More details at https://docs.microsoft.com/uwp/api/windows.ui.notifications.toastnotification.tag Tag = "ToastTag" }; // And show the toast await ShowToastNotificationAsync(toast).ConfigureAwait(false); }
private static void ShowToast(string id, string subject, string body) { ToastContent toastContent = MakeContent(id, subject, body); // And create the toast notification var toast = new ToastNotification(toastContent.GetXml()) { Tag = "foo" }; ToastNotificationManager.CreateToastNotifier().Show(toast); }
public static void SendMessageWithoutTextNotify(string name, string message, string image, string action, string heroImage = null) { var toastContent = new ToastContent() { Visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = name, HintMaxLines = 1 }, new AdaptiveText() { Text = message } }, AppLogoOverride = new ToastGenericAppLogo() { Source = image, HintCrop = ToastGenericAppLogoCrop.Circle }, HeroImage = heroImage != null ? new ToastGenericHeroImage { Source = heroImage } : null } }, Actions = new ToastActionsCustom() { Buttons = { new ToastButton("Open", action) { ActivationType = ToastActivationType.Background, }, new ToastButton("Dismiss", "dismiss=True") { ActivationType = ToastActivationType.Background, } } }, Launch = action }; // Create the toast notification var toastNotif = new ToastNotification(toastContent.GetXml()); // And send the notification ToastNotificationManager.CreateToastNotifier().Show(toastNotif); }
public async void Update(AdaptiveBlockContent block, AdaptiveBlock sourceBlock, PreviewBlockHostViewModel args) { MyPreviewToast.Properties = new PreviewToastProperties() { DisplayName = args.AppName, Square44x44Logo = args.AppLogo }; ToastContent content = (await new AdaptiveBlockToToastContentTransformer().TransformAsync(sourceBlock)).Result; MyPreviewToast.Initialize(content.GetXml()); }
public static void SendPrivateFollowRequestNotify(string message, string image, string action, string heroImage = null) { var toastContent = new ToastContent() { Visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = message } }, AppLogoOverride = new ToastGenericAppLogo() { Source = image, HintCrop = ToastGenericAppLogoCrop.Circle }, HeroImage = heroImage != null ? new ToastGenericHeroImage { Source = heroImage } : null } }, Actions = new ToastActionsCustom() { Buttons = { new ToastButton("Accept", action + "&action=acceptFriendshipRequest") { ActivationType = ToastActivationType.Background }, new ToastButton("Decline", action + "&action=declineFriendshipRequest") { ActivationType = ToastActivationType.Background }, new ToastButton("Open profile", action + "&action=openProfile") { ActivationType = ToastActivationType.Foreground } } }, Launch = action }; // Create the toast notification var toastNotif = new ToastNotification(toastContent.GetXml()); // And send the notification ToastNotificationManager.CreateToastNotifier().Show(toastNotif); }
internal void UpdateSongToastNotification(ExtendedSongMetadata metaData) { string toastLogo = FindToastLogo(metaData); ToastContent content = new ToastContent() { Launch = "now-playing", Audio = new ToastAudio() { Silent = true, }, Visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = metaData.Track, HintStyle = AdaptiveTextStyle.Title }, new AdaptiveText() { Text = metaData.Artist, HintStyle = AdaptiveTextStyle.Subtitle }, new AdaptiveText() { Text = metaData.StationPlayedOn, HintStyle = AdaptiveTextStyle.Caption }, }, AppLogoOverride = new ToastGenericAppLogo() { Source = toastLogo } } } }; var notification = new ToastNotification(content.GetXml()); notification.Tag = SongNotificationTag; notification.NotificationMirroring = NotificationMirroring.Disabled; // notification.SuppressPopup = true; // toastNotifier.Show(notification); }
public async Task Send(Notification notification) { if (notification.Id == 0) { notification.Id = this.settings.IncrementValue("NotificationId"); } if (notification.ScheduleDate != null) { await this.repository.Set(notification.Id.ToString(), notification); return; } var toastContent = new ToastContent { Duration = notification.Windows.UseLongDuration ? ToastDuration.Long : ToastDuration.Short, Launch = notification.Payload, Visual = new ToastVisual { BindingGeneric = new ToastBindingGeneric { Children = { new AdaptiveText { Text = notification.Title }, new AdaptiveText { Text = notification.Message } } } } }; if (!notification.Sound.IsEmpty()) { var sound = this.BuildSoundPath(notification.Sound); toastContent.Audio = new ToastAudio { Src = new Uri(sound) }; } //toastContent.Actions //toastContent.AdditionalProperties.Ad //toastContent.Launch = ""; var native = new ToastNotification(toastContent.GetXml()); this.toastNotifier.Show(native); }
public static void NotifyWrongVerifyCode() { if (Window.Current.CoreWindow.IsActive()) { return; } ToastContent content = VerificationNotifyBuilder.GenerateToastWrongVerifyCodeContent(); ToastNotificationManager .CreateToastNotifier() .Show(new ToastNotification(content.GetXml())); }
private void ShowToast(ToastContent content) { var now = DateTime.Now; //show only one exception every 5 sec (minimum value for toast notifications to be visible) if (_lastException == null || now - _lastException.Value > TimeSpan.FromSeconds(5)) { _lastException = DateTime.Now; var notifier = ToastNotificationManager.CreateToastNotifier(); var notification = new ToastNotification(content.GetXml()); notifier.Show(notification); } }
private static void PopToast(ToastContent content, ChatModel chat, string group) { ToastNotification toast = new ToastNotification(content.GetXml()) { Group = group }; OnChatMessageToastEventArgs args = new OnChatMessageToastEventArgs(toast, chat); OnChatMessageToast?.Invoke(args); PopToast(toast, args); }
public void ShowNotification() { // https://blogs.msdn.microsoft.com/tiles_and_toasts/2015/07/08/quickstart-sending-a-local-toast-notification-and-handling-activations-from-it-windows-10/; // In a real app, these would be initialized with actual data string title = "Smart City"; string content = "Nouveaux travaux signalés!"; string image = "https://upload.wikimedia.org/wikipedia/commons/thumb/f/f1/France_road_sign_AK5.svg/200px-France_road_sign_AK5.svg.png"; string logo = "ms-appdata:///Assets/Travaux.png"; // Construct the visuals of the toast ToastVisual visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = title }, new AdaptiveText() { Text = content }, new AdaptiveImage() { Source = image } }, AppLogoOverride = new ToastGenericAppLogo() { Source = logo, HintCrop = ToastGenericAppLogoCrop.Circle } } }; // Now we can construct the final toast content ToastContent toastContent = new ToastContent() { Visual = visual, //Actions = actions, // Arguments when the user taps body of toast // Launch = new QueryString() //{ // { "action", "viewConversation" }, // { "conversationId", conversationId.ToString() } //}.ToString() }; // And create the toast notification var toast = new ToastNotification(toastContent.GetXml()); toast.ExpirationTime = DateTime.Now.AddMinutes(2); ToastNotificationManager.CreateToastNotifier().Show(toast); }
private void ButtonSendToast_Click(object sender, RoutedEventArgs e) { // In a real app, these would be initialized with actual data string title = "Andrew sent you a picture"; string content = "Check this out, Happy Canyon in Utah!"; string image = "http://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-71-81-permanent/2727.happycanyon1_5B00_1_5D00_.jpg"; string logo = "ms-appdata:///local/Andrew.jpg"; int conversationId = 384928; // Construct the visuals of the toast ToastVisual visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = title }, new AdaptiveText() { Text = content }, new AdaptiveImage() { Source = image } }, AppLogoOverride = new ToastGenericAppLogo() { Source = logo, HintCrop = ToastGenericAppLogoCrop.Circle } } }; // Construct the actions for the toast (inputs and buttons) ToastActionsCustom actions = new ToastActionsCustom() { Inputs = { new ToastTextBox("tbReply") { PlaceholderContent = "Type a response" } }, Buttons = { new ToastButton("Reply", new QueryString() { { "action", "reply" }, { "conversationId", conversationId.ToString() } }.ToString()) { ActivationType = ToastActivationType.Background, ImageUri = "Assets/Reply.png", // Reference the text box's ID in order to // place this button next to the text box TextBoxId = "tbReply" }, new ToastButton("Like", new QueryString() { { "action", "like" }, { "conversationId", conversationId.ToString() } }.ToString()) { ActivationType = ToastActivationType.Background }, new ToastButton("View", new QueryString() { { "action", "viewImage" }, { "imageUrl", image } }.ToString()) } }; // Now we can construct the final toast content ToastContent toastContent = new ToastContent() { Visual = visual, Actions = actions, // Arguments when the user taps body of toast Launch = new QueryString() { { "action", "viewConversation" }, { "conversationId", conversationId.ToString() } }.ToString() }; // And create the toast notification ToastNotification notification = new ToastNotification(toastContent.GetXml()); // And then send the toast ToastNotificationManager.CreateToastNotifier().Show(notification); }
/// <summary> /// Simple method to show a basic toast with a message. /// </summary> /// <param name="message"></param> private void SendToast(string message) { ToastContent content = new ToastContent() { Visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = "Background Task Completed" }, new AdaptiveText() { Text = message } } } } }; ToastNotificationManager.CreateToastNotifier().Show(new ToastNotification(content.GetXml())); }
public void AddNotification(LaunchData launchData, NotificationType type) { if (launchData?.Launch == null) return; var deliverytime = TimeConverter.DetermineTimeSettings(launchData.Launch.Net, true) .AddMinutes(-LaunchPal.App.Settings.NotifyBeforeLaunch.ToIntValue()); if (deliverytime < DateTime.Now) { return; } switch (type) { case NotificationType.NextLaunch: if (!LaunchPal.App.Settings.LaunchInProgressNotifications) return; break; case NotificationType.TrackedLaunch: if (!LaunchPal.App.Settings.TrackedLaunchNotifications) return; break; default: throw new ArgumentOutOfRangeException(nameof(type), type, null); } var groupName = GetGroupNameFromNotificationType(type); ToastVisual visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = "Launch Alert!" }, new AdaptiveText() { Text = $"{launchData?.Launch?.Name} is about to launch." }, new AdaptiveText() { Text = $"Time: {TimeConverter.SetStringTimeFormat(launchData.Launch.Net, LaunchPal.App.Settings.UseLocalTime).Replace(" Local", "")}" } }, AppLogoOverride = new ToastGenericAppLogo() { Source = "Assets/BadgeLogo.scale-200.png", HintCrop = ToastGenericAppLogoCrop.Default } } }; // Now we can construct the final toast content ToastContent toastContent = new ToastContent() { Visual = visual, // Arguments when the user taps body of toast Launch = new QueryString() { { "action", "viewLaunch" }, { "LaunchId", launchData?.Launch?.Id.ToString() } }.ToString(), Actions = new ToastActionsCustom() { Inputs = { new ToastSelectionBox("snoozeTime") { DefaultSelectionBoxItemId = "15", Items = { new ToastSelectionBoxItem("5", "5 minutes"), new ToastSelectionBoxItem("15", "15 minutes"), new ToastSelectionBoxItem("30", "30 minutes"), new ToastSelectionBoxItem("45", "45 minutes"), new ToastSelectionBoxItem("60", "1 hour") } } }, Buttons = { new ToastButtonSnooze() { SelectionBoxId = "snoozeTime" }, new ToastButtonDismiss() } } }; // And create the toast notification var scheduleToast = new ScheduledToastNotification(toastContent.GetXml(), deliverytime) { Id = launchData?.Launch?.Id.ToString() ?? "0", Tag = launchData?.Launch?.Id.ToString() ?? "0", Group = groupName, NotificationMirroring = NotificationMirroring.Allowed, }; ToastNotificationManager.CreateToastNotifier().AddToSchedule(scheduleToast); }