public void Test_Toast_XML_Visual_TitleText_All() { var visual = new ToastVisual() { TitleText = new ToastText() { Text = "Hi, I am a title", Language = "en-US" } }; AssertVisualPayload(@"<visual><binding template=""ToastGeneric""><text lang='en-US'>Hi, I am a title</text></binding></visual>", visual); }
public static void SendToast(ToastBindingGeneric generic) { ToastVisual visual = new ToastVisual(); visual.BindingGeneric = generic; ToastContent tcontent = new ToastContent() { Visual = visual }; var toast = new ToastNotification(tcontent.GetXml()); ToastNotificationManager.CreateToastNotifier().Show(toast); }
public void Test_Toast_XML_Visual_BodyTextLine2_All() { var visual = new ToastVisual() { BodyTextLine2 = new ToastText() { Text = "The second line of body text", Language = "en-US" } }; AssertVisualPayload(@"<visual><binding template=""ToastGeneric""><text/><text/><text lang='en-US'>The second line of body text</text></binding></visual>", visual); }
public static void PopToast(HNActivity activity) { try { string type = DataService.GetActivityType(activity.payload.activity_type); string body = DataService.GetBodyText(activity); #region Toast Visual ToastVisual visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = activity.action_user_name + type + body }, }, AppLogoOverride = new ToastGenericAppLogo() { Source = activity.action_user_image_url, HintCrop = ToastGenericAppLogoCrop.Circle }, } }; #endregion ToastContent toastContent = new ToastContent() { Visual = visual, ActivationType = ToastActivationType.Foreground, Launch = new QueryString() { { "type", activity.payload.activity_type }, { "id", activity.payload.id.ToString() }, }.ToString() }; var toast = new ToastNotification(toastContent.GetXml()); toast.Tag = activity.id.ToString(); toast.Group = activity.payload.id.ToString(); toast.NotificationMirroring = NotificationMirroring.Allowed; ToastNotificationManager.CreateToastNotifier().Show(toast); } catch (Exception) { LoggerService.LogEvent("Toast_failed"); } }
public static void Toast(string title, string content, string buttonText, QueryString queries, ToastActivationType toastActivationType = ToastActivationType.Foreground) { // Construct the visuals of the toast ToastVisual visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText { Text = title }, new AdaptiveText { Text = content }, }, } }; ToastActionsCustom actions = null; if (!string.IsNullOrEmpty(buttonText)) { // Construct the actions for the toast (inputs and buttons) actions = new ToastActionsCustom() { Buttons = { new ToastButton(buttonText, queries.ToString()) { ActivationType = toastActivationType } } }; } // Now we can construct the final toast content ToastContent toastContent = new ToastContent() { Visual = visual, Actions = actions, }; // And create the toast notification var toast = new ToastNotification(toastContent.GetXml()); ToastNotificationManager.CreateToastNotifier().Show(toast); }
/// <summary> /// Show toast alert notification with a warning icon. /// </summary> /// <param name="title">Title to show in the notification.</param> /// <param name="text">Text to show in the notification.</param> public static void ShowAlertNotification(string title, string text) { try { var visual = new ToastVisual { BindingGeneric = new ToastBindingGeneric { Children = { new AdaptiveText { Text = title }, new AdaptiveText { Text = text } }, AppLogoOverride = new ToastGenericAppLogo { Source = WarningUri, HintCrop = ToastGenericAppLogoCrop.Circle } } }; var toastContent = new ToastContent { Visual = visual, Audio = new ToastAudio() { Silent = false }, }; var toast = new ToastNotification(toastContent.GetXml()); 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 static void Do(Match fromWho) { ToastVisual visual = new ToastVisual() { TitleText = new ToastText() { Text = "Matched!" }, }; visual.BodyTextLine1 = new ToastText() { Text = "You have matched " + fromWho.person.name }; visual.BodyTextLine2 = new ToastText() { Text = "Chat em up!" }; // Pass a payload as JSON to the Toast dynamic payload = new JObject(); payload.source = typeof(NewMatchToast).ToString(); payload.args = fromWho._id; string payload_json = payload.ToString(); ToastContent toastContent = new ToastContent() { Visual = visual, Audio = null, Actions = new ToastActionsCustom() { Buttons = { new ToastButton("Go to Match", payload_json) { ActivationType = ToastActivationType.Foreground, }, new ToastButtonDismiss() } }, Launch = payload_json }; var toast = new ToastNotification(toastContent.GetXml()); ToastNotificationManager.CreateToastNotifier().Show(toast); }
private void PopObstacleToast() { // In a real app, these would be initialized with actual data string title = "Roadblock Alert"; string content = "Possible roadblock ahead!"; string description = "Please check the app for more information."; string logo = "ms-appx:///Assets/warningsign.png"; // Construct the visuals of the toast ToastVisual visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = title }, new AdaptiveText() { Text = content, }, new AdaptiveText() { Text = description } }, AppLogoOverride = new ToastGenericAppLogo() { Source = logo, HintCrop = ToastGenericAppLogoCrop.Default } } }; ToastContent toastContent = new ToastContent() { Scenario = ToastScenario.Alarm, Visual = visual, }; // And create the toast notification var toast = new ToastNotification(toastContent.GetXml()); ToastNotificationManager.CreateToastNotifier().Show(toast); }
public void ShowDownloadedFileNotification(string fileName, string filePath) { this.filePath = filePath; ToastVisual visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = "Pobrano plik" }, new AdaptiveText() { Text = $"Pobrano plik {fileName}" } }, AppLogoOverride = new ToastGenericAppLogo() { Source = "Assets/rocket-small-logo.png", HintCrop = ToastGenericAppLogoCrop.Circle } } }; ToastContent toastContent = new ToastContent() { Visual = visual, DisplayTimestamp = DateTime.Now, Actions = new ToastActionsCustom() { Buttons = { new ToastButton("Otwórz folder", "openDownloadsFolder") { ActivationType = ToastActivationType.Foreground } } } }; var toastXml = new XmlDocument(); toastXml.LoadXml(toastContent.GetContent()); var toast = new ToastNotification(toastXml); toast.Activated += DownloadedToast_Activated; ShowToastNotification(toast); }
private void CreateToast(string title) { string content = Company.Name; string image = Company.Image; string logo = "ms-appdata:///local/Andrew.jpg"; 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 } } }; ToastContent toastContent = new ToastContent() { Visual = visual }; try { var toast = new ToastNotification(toastContent.GetXml()); ToastNotificationManager.CreateToastNotifier().Show(toast); } catch (Exception) { // Do nothing } }
private void ButtonUpdateCallBack(byte pin, PinState state) { Debug.WriteLine("Button pressed"); string title = "Ding dong!"; string content = "Noen står bak deg!"; //string image = "BILDEbilde"; //string logo = "LOGObilde"; ToastVisual visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = title }, new AdaptiveText() { Text = content }, }, //AppLogoOverride = new ToastGenericAppLogo() { // Source = logo, // HintCrop = ToastGenericAppLogoCrop.Circle //} } }; 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()); notification.ExpirationTime = DateTime.Now.AddMinutes(10); // And then send the toast ToastNotificationManager.CreateToastNotifier().Show(notification); }
public void NotifyWithUrl(string title, string message, string url) { ToastVisual visual = new ToastVisual() { TitleText = new ToastText() { Text = title }, BodyTextLine1 = new ToastText() { Text = message }, AppLogoOverride = new ToastAppLogo() { Crop = ToastImageCrop.Circle, Source = new ToastImageSource("http://i.imgur.com/qeFYZoL.png?1") } }; ToastActionsCustom actions = new ToastActionsCustom() { Buttons = { new ToastButton("Browse unwatched", new QueryString() { { "action", "openurl"}, { "url", url } }.ToString()) { ActivationType = ToastActivationType.Foreground }, new ToastButtonDismiss("Not now...") } }; _toastContent = new ToastContent() { Visual = visual, Actions = actions, // Arguments when the user taps body of toast Launch = new QueryString() { { "action", "openurl" }, { "url", url } }.ToString() }; SendNotification(); }
static ToastContent MakeContent(string id, string subject, string body) { string title = subject; // Construct the visuals of the toast ToastVisual visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = title }, new AdaptiveText() { Text = body }, }, AppLogoOverride = new ToastGenericAppLogo() { Source = "ms-appdata:///local/Andrew.jpg", HintCrop = ToastGenericAppLogoCrop.Circle } } }; var qs = System.Web.HttpUtility.ParseQueryString(string.Empty); qs.Add("subject", subject); qs.Add("body", body); qs.Add("id", id); // Now we can construct the final toast content ToastContent toastContent = new ToastContent() { Launch = qs.ToString(), Visual = visual, Scenario = ToastScenario.Alarm, Actions = new ToastActionsCustom() { Buttons = { new ToastButton("Click Here!", qs.ToString()) } } // Arguments when the user taps body of toast }; return(toastContent); }
/// <summary> /// Generates and sends a toast notification /// </summary> /// <param name="url"></param> /// <param name="name"></param> /// <param name="time"></param> private void GenerateToast(string url, string name, DateTime time) { string title = name + " was spotted!"; string content = "Active on: " + url + " on " + time.ToLongDateString() + ", " + time.ToLongTimeString(); // Construct the visuals of the toast ToastVisual visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = title }, new AdaptiveText() { Text = content }, }, } }; // Construct the final toast content ToastContent toastContent = new ToastContent() { Visual = visual, }; // And create the toast notification var toast = new ToastNotification(toastContent.GetXml()); // If the same user appeared previously, remove the old notification ToastNotificationManager.History.Remove(name); // Set the expiration to now day toast.ExpirationTime = DateTime.Now.AddDays(1); // Set the name as the tag toast.Tag = name; // And the group name toast.Group = "PlatformMonitor"; // Show the notification ToastNotificationManager.CreateToastNotifier().Show(toast); }
internal static void ShowSyncSuspendedNotification(FolderSyncInfo fsi) { if (fsi == null) { return; } var loader = new ResourceLoader(); var title = loader.GetString("SyncSuspendedTitle"); var content = string.Format(loader.GetString("SyncSuspendedDescription"), fsi.Path); const string action = SyncAction; // Construct the visuals of the toast var visual = new ToastVisual { BindingGeneric = new ToastBindingGeneric { Children = { new AdaptiveText { Text = title }, new AdaptiveText { Text = content } } } }; var toastContent = new ToastContent { Visual = visual, // Arguments when the user taps body of toast Launch = new QueryString { { "action", action } }.ToString() }; var toast = new ToastNotification(toastContent.GetXml()) { ExpirationTime = DateTime.Now.AddMinutes(30), Group = action }; // TODO Replace with syncinterval from settings. // TODO groups/tags? ToastNotificationManager.CreateToastNotifier().Show(toast); }
public void ShowToast(String value) { var loader = new Windows.ApplicationModel.Resources.ResourceLoader(); ToastVisual visual = new ToastVisual() { TitleText = new ToastText() { Text = loader.GetString(value) }, }; ToastContent content = new ToastContent(); content.Visual = visual; var toast = new ToastNotification(content.GetXml()); ToastNotificationManager.CreateToastNotifier().Show(toast); }
private void createNotification(ToastVisual visual, string name) { ToastContent toastContent = new ToastContent() { Visual = visual, Launch = "" }; // And create the toast notification var toast = new ToastNotification(toastContent.GetXml()); toast.Group = LoginViewModel.Email; toast.Tag = name; ToastNotificationManager.CreateToastNotifier().Show(toast); }
public void SendGenericToast(string icon, string title, string content, QueryString launchQuery = null, double experationInHours = 24.0) { if (icon == null) { icon = "Assets/DiscordLogoSquare.png"; } // Construct the visuals of the toast ToastVisual visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = title }, new AdaptiveText() { Text = content }, }, AppLogoOverride = new ToastGenericAppLogo() { Source = icon, HintCrop = ToastGenericAppLogoCrop.Circle } } }; ToastContent toastContent = new ToastContent() { Visual = visual, }; if (launchQuery != null) { toastContent.Launch = launchQuery.ToString(); } var toast = new ToastNotification(toastContent.GetXml()); toast.ExpirationTime = DateTime.Now.AddHours(experationInHours); ToastNotificationManager.CreateToastNotifier().Show(toast); }
public void Test_Toast_XML_Visual_OneImage() { var visual = new ToastVisual() { InlineImages = { new ToastImageSource("http://msn.com/image.jpg") { AddImageQuery = true, Alt = "alternate" } } }; AssertVisualPayload(@"<visual><binding template=""ToastGeneric""><image src='http://msn.com/image.jpg' addImageQuery='True' alt='alternate'/></binding></visual>", visual); }
public virtual ActionResult notify() { string title = "Test"; ToastVisual t = new ToastVisual() { TitleText = new ToastText { Text = title }, }; ToastContent content = new ToastContent { Visual = t }; //ToastNotification return(null); }
private void OnSendNotificationWithExtension(object sender, RoutedEventArgs e) { ToastVisual visual = new ToastVisual { AppLogoOverride = new ToastAppLogo { Crop = ToastImageCrop.None, Source = new ToastImageSource("ms-appx:///Assets/MicrosoftLogo.png") }, TitleText = new ToastText { Text = "DotNet Spain Conference" }, BodyTextLine1 = new ToastText { Text = "How much do you like my session ?" } }; ToastSelectionBox selection = new ToastSelectionBox("rating"); selection.Items.Add(new ToastSelectionBoxItem("1", "1 (Not very much)")); selection.Items.Add(new ToastSelectionBoxItem("2", "2")); selection.Items.Add(new ToastSelectionBoxItem("3", "3")); selection.Items.Add(new ToastSelectionBoxItem("4", "4")); selection.Items.Add(new ToastSelectionBoxItem("5", "5 (A lot!)")); ToastButton button = new ToastButton("Vote", "vote"); button.ActivationType = ToastActivationType.Background; ToastContent toast = new ToastContent { Visual = visual, ActivationType = ToastActivationType.Background, Actions = new ToastActionsCustom { Inputs = { selection }, Buttons = { button } } }; XmlDocument doc = toast.GetXml(); ToastNotification notification = new ToastNotification(doc); ToastNotificationManager.CreateToastNotifier().Show(notification); }
/// <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) { 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)); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { string title = "titulo"; string content = "contenido"; string logo = "Assets/fb.png"; string image = "Assets/satya.jpg"; ToastVisual visual = new ToastVisual() { TitleText = new ToastText() { Text = title }, BodyTextLine1 = new ToastText() { Text = content }, AppLogoOverride = new ToastAppLogo() { Source = new ToastImageSource(logo), Crop = ToastImageCrop.Circle }, InlineImages = { new ToastImage() { Source = new ToastImageSource(image) } } }; ToastActionsCustom action = new ToastActionsCustom() { Inputs = { new ToastTextBox("txt") { PlaceholderContent = "comment here" } }, Buttons = { new ToastButton("Reply", new QueryString() { "Action", "Reply" }.ToString()) } }; ToastContent Content = new ToastContent() { Visual = visual, Actions = action }; ToastNotification notification = new ToastNotification(); ToastNotificationManager.CreateToastNotifier().Show(notification); }
public static void ShowToast(string title, string content, string image = "", string logo = "") { // 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 = "https://picsum.photos/360/202?image=883"; //string logo = "ms-appdata:///local/Andrew.jpg"; // 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, }; // And create the toast notification var toast = new ToastNotification(toastContent.GetXml()); ToastNotificationManager.CreateToastNotifier().Show(toast); }
public void Test_Toast_XML_Visual_SixImages() { var visual = new ToastVisual() { InlineImages = { new ToastImageSource("Assets/img1.jpg"), new ToastImageSource("Assets/img2.jpg"), new ToastImageSource("Assets/img3.jpg"), new ToastImageSource("Assets/img4.jpg"), new ToastImageSource("Assets/img5.jpg"), new ToastImageSource("Assets/img6.jpg") } }; AssertVisualPayload(@"<visual><binding template=""ToastGeneric""><image src='Assets/img1.jpg'/><image src='Assets/img2.jpg'/><image src='Assets/img3.jpg'/><image src='Assets/img4.jpg'/><image src='Assets/img5.jpg'/><image src='Assets/img6.jpg'/></binding></visual>", visual); }
private ToastContent BuildNotification(List <ResponsiveNotificationText> messages) { ToastVisual root = new ToastVisual(); ToastBindingGeneric binding = new ToastBindingGeneric(); root.BindingGeneric = binding; var results = messages.ElementAt(0); var fixtures = messages.ElementAt(1); if (!fixtures.Matches.Any() && !results.Matches.Any()) { return(null); } foreach (var notificationGroup in messages) { if (notificationGroup.Matches.Any()) { var group = new AdaptiveGroup(); var subgroup = new AdaptiveSubgroup() { HintTextStacking = AdaptiveSubgroupTextStacking.Center }; subgroup.Children.Add(new AdaptiveText() { Text = notificationGroup.MatchType, HintStyle = AdaptiveTextStyle.Subtitle }); foreach (var match in notificationGroup.Matches) { subgroup.Children.Add(new AdaptiveText() { Text = match, HintStyle = AdaptiveTextStyle.BaseSubtle }); } group.Children.Add(subgroup); binding.Children.Add(group); } } return(new ToastContent() { Visual = root }); }
private void SendToastNotification(string heartRate) { const string title = "New heart rate measurement"; var content = heartRate; const string image = "https://brunocapuano.files.wordpress.com/2016/02/clipboard012.png"; // "https://brunocapuano.files.wordpress.com/2016/01/ohhh-q-asombroso.gif"; const string logo = "ms-appdata:///local/Heart-02.png"; var visual = new ToastVisual() { TitleText = new ToastText() { Text = title }, BodyTextLine1 = new ToastText() { Text = content }, InlineImages = { new ToastImage() { Source = new ToastImageSource(image) } }, AppLogoOverride = new ToastAppLogo() { Source = new ToastImageSource(logo), Crop = ToastImageCrop.None } }; var toastContent = new ToastContent() { Visual = visual }; var toast = new ToastNotification(toastContent.GetXml()) { Tag = "1", Group = "Garmin" }; ToastNotificationManager.CreateToastNotifier().Show(toast); }
private void SendToast(string text, string title = "") { if (string.IsNullOrEmpty(title)) { title = Title; } if (!string.IsNullOrWhiteSpace(_regexLookupPattern) && !CheckPromoExists(text)) { return; } ToastVisual visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText() { Text = title }, new AdaptiveText() { Text = text.GetByPattern(_regexLookupPattern) } } } }; var toastContent = new ToastContent() { Visual = visual }; var doc = new XmlDocument(); doc.LoadXml(toastContent.GetContent()); var toast = new ToastNotification(doc) { ExpirationTime = DateTime.Now.AddHours(2), Tag = "1", Group = "PromoFound" }; ToastNotificationManager.CreateToastNotifier(Title).Show(toast); }
private string ComposeInteractiveToast() { var toastVisual = new ToastVisual { BindingGeneric = new ToastBindingGeneric { Children = { new AdaptiveText { Text = MessageTitle }, new AdaptiveText { Text = MessageBody }, }, AppLogoOverride = new ToastGenericAppLogo { Source = string.Format("file:///{0}", Path.GetFullPath("DesktopToast.png")), AlternateText = "" } } }; var toastAction = new ToastActionsCustom { Buttons = { new ToastButton(content: "More Info", arguments: "action=Replied") { ActivationType = ToastActivationType.Background }, new ToastButton(content: "Ignore", arguments: "action=Ignored") } }; var toastContent = new ToastContent { Visual = toastVisual, Actions = toastAction, Duration = ToastDuration.Long, Scenario = ToastScenario.Reminder }; return(toastContent.GetContent()); }
private void ShowToastWithProgress(double progress, string status, string message) { var loader = new ResourceLoader(); ToastVisual visual = new ToastVisual { BindingGeneric = new ToastBindingGeneric { Children = { new AdaptiveText { Text = loader.GetString("BackgroundNuGetCleaner_ToastTitle") }, new AdaptiveText { Text = message }, new AdaptiveProgressBar { Value = new BindableProgressBarValue("progress"), Status = new BindableString("status") } } } }; ToastContent toastContent = new ToastContent() { Visual = visual }; var toast = new ToastNotification(toastContent.GetXml()); toast.Data = new NotificationData(); toast.Data.Values["progress"] = progress.ToString(); toast.Data.Values["status"] = status; toast.Data.SequenceNumber = 0; toast.SuppressPopup = true; toast.Tag = toastTag; toast.Group = ToastGroup; ToastNotificationManager.CreateToastNotifier().Show(toast); }
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); }
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); }
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); }