public static void ScheduleNotificationRepeating(int firstTriggerInSeconds, int intervalSeconds, string title, string text, int id, IDictionary <string, string> userData, string notificationProfile) { if (firstTriggerInSeconds <= 0) { throw new ArgumentOutOfRangeException("firstTriggerInSeconds"); } if (intervalSeconds <= 0) { throw new ArgumentOutOfRangeException("intervalSeconds"); } int triggerInSeconds; bool enabled = NotificationsEnabled(); if (enabled) { int scheduleInAdvanceSeconds = Math.Min(ScheduleRepeatedForSeconds + intervalSeconds, MaxRepeatsSchedulingAtOnce * intervalSeconds); IToastNotificationContent notificationContent = PrepareNotification(title, text, id, notificationProfile); int minTriggerInSecondsAllowed = GetMinTriggerInSecondsAllowed(); for (triggerInSeconds = firstTriggerInSeconds; triggerInSeconds < firstTriggerInSeconds + scheduleInAdvanceSeconds; triggerInSeconds += intervalSeconds) { ScheduleSingleNotification(triggerInSeconds, id, notificationContent, minTriggerInSecondsAllowed, true); } } else { triggerInSeconds = firstTriggerInSeconds - intervalSeconds; } RegisterNotification(triggerInSeconds, intervalSeconds, title, text, id, userData, notificationProfile, GetCurrentUnixTimeSeconds() + firstTriggerInSeconds - intervalSeconds - 1); }
private static void Reschedule(ApplicationDataCompositeValue registeredNotification, bool onEnabled) { int intervalSeconds = (int)registeredNotification["intervalSeconds"]; if (intervalSeconds <= 0 && !onEnabled) { //Not repeating return; } long currentTime = GetCurrentUnixTimeSeconds(); int lastTriggerInSecondsFromNow = (int)((long)registeredNotification["lastTriggerInSeconds"] - currentTime); int scheduleInAdvanceSeconds = Math.Min(ScheduleRepeatedForSeconds + intervalSeconds, MaxRepeatsSchedulingAtOnce * intervalSeconds); string title = (string)registeredNotification["title"]; string text = (string)registeredNotification["text"]; int id = (int)registeredNotification["id"]; IDictionary <string, string> userData = UnpackUserData(registeredNotification); string notificationProfile = (string)registeredNotification["notificationProfile"]; long lastTimeHandled = onEnabled ? currentTime : (long)registeredNotification["lastTimeHandled"]; if (intervalSeconds > 0) { //Repeating if (lastTriggerInSecondsFromNow + intervalSeconds < scheduleInAdvanceSeconds) { if (lastTriggerInSecondsFromNow < 0) { lastTriggerInSecondsFromNow %= intervalSeconds; } IToastNotificationContent notificationContent = PrepareNotification(title, text, id, notificationProfile); int minTriggerInSecondsAllowed = GetMinTriggerInSecondsAllowed(); int triggerInSeconds; for (triggerInSeconds = lastTriggerInSecondsFromNow + intervalSeconds; triggerInSeconds < scheduleInAdvanceSeconds; triggerInSeconds += intervalSeconds) { ScheduleSingleNotification(triggerInSeconds, id, notificationContent, minTriggerInSecondsAllowed, true); } RegisterNotification(triggerInSeconds, intervalSeconds, title, text, id, userData, notificationProfile, lastTimeHandled); } } else { //One shot if (lastTriggerInSecondsFromNow > 0) { ScheduleSingleNotification(lastTriggerInSecondsFromNow, title, text, id, notificationProfile); } else { UnregisterNotification(id); } } }
private void sendToast(object sender, RoutedEventArgs e) { IToastNotificationContent toastContent = null; IToastText01 templateContent = ToastContentFactory.CreateToastText01(); templateContent.TextBodyWrap.Text = "今天去游泳!(BeyondVincent|破船|)"; toastContent = templateContent; ToastNotification toast = toastContent.CreateNotification(); ToastNotificationManager.CreateToastNotifier().Show(toast); }
public static void DisplaySingleLine(String _text) { IToastImageAndText01 templateContent = ToastContentFactory.CreateToastImageAndText01(); templateContent.TextBodyWrap.Text = _text; templateContent.Image.Src = "Icons/toastImageAndText.png"; IToastNotificationContent toastContent = templateContent; ToastNotification toast = toastContent.CreateNotification(); ToastNotificationManager.CreateToastNotifier().Show(toast); }
void DisplayWebImageToast(ToastTemplateType templateType) { IToastNotificationContent toastContent = null; string toastImageSrc = Scenario3ImageUrl.Text; if (templateType == ToastTemplateType.ToastImageAndText01) { IToastImageAndText01 templateContent = ToastContentFactory.CreateToastImageAndText01(); templateContent.TextBodyWrap.Text = "Body text that wraps"; templateContent.Image.Src = toastImageSrc; templateContent.Image.Alt = ALT_TEXT; toastContent = templateContent; } else if (templateType == ToastTemplateType.ToastImageAndText02) { IToastImageAndText02 templateContent = ToastContentFactory.CreateToastImageAndText02(); templateContent.TextHeading.Text = "Heading text"; templateContent.TextBodyWrap.Text = "Body text that wraps."; templateContent.Image.Src = toastImageSrc; templateContent.Image.Alt = ALT_TEXT; toastContent = templateContent; } else if (templateType == ToastTemplateType.ToastImageAndText03) { IToastImageAndText03 templateContent = ToastContentFactory.CreateToastImageAndText03(); templateContent.TextHeadingWrap.Text = "Heading text that wraps"; templateContent.TextBody.Text = "Body text"; templateContent.Image.Src = toastImageSrc; templateContent.Image.Alt = ALT_TEXT; toastContent = templateContent; } else if (templateType == ToastTemplateType.ToastImageAndText04) { IToastImageAndText04 templateContent = ToastContentFactory.CreateToastImageAndText04(); templateContent.TextHeading.Text = "Heading text"; templateContent.TextBody1.Text = "Body text"; templateContent.TextBody2.Text = "Another body text"; templateContent.Image.Src = toastImageSrc; templateContent.Image.Alt = ALT_TEXT; toastContent = templateContent; } rootPage.NotifyUser(toastContent.GetContent(), NotifyType.StatusMessage); // Create a toast from the Xml, 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); }
private static void ScheduleSingleNotification(int triggerInSeconds, int id, IToastNotificationContent notificationContent, int minTriggerInSecondsAllowed, bool enabled) { if (enabled && triggerInSeconds >= minTriggerInSecondsAllowed) { DateTime dt = DateTime.Now.AddSeconds(triggerInSeconds); string launchArgs = notificationContent.Launch; notificationContent.Launch = launchArgs + "." + dt.ToFileTimeUtc(); ScheduledToastNotification notification = new ScheduledToastNotification(notificationContent.GetXml(), dt); notificationContent.Launch = launchArgs; notification.Id = "id" + id; ToastNotificationManager.CreateToastNotifier().AddToSchedule(notification); } }
public static void Show(string text) { IToastNotificationContent toastContent = null; IToastText01 templateContent = ToastContentFactory.CreateToastText01(); templateContent.TextBodyWrap.Text = text; toastContent = templateContent; ToastNotification toast = toastContent.CreateNotification(); toast.ExpirationTime = DateTimeOffset.UtcNow.AddSeconds(1); ToastNotificationManager.CreateToastNotifier().Show(toast); }
public static void DisplayTwoLines(String _text1, String _text2, String _picture) { IToastImageAndText02 templateContent = ToastContentFactory.CreateToastImageAndText02(); templateContent.TextHeading.Text = _text1; templateContent.TextBodyWrap.Text = _text2; templateContent.Image.Src = _picture; IToastNotificationContent toastContent = templateContent; ToastNotification toast = toastContent.CreateNotification(); ToastNotificationManager.CreateToastNotifier().Show(toast); }
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); }
private void ToashNotification(string message) { // Create a toast, then create a ToastNotifier object to show // the toast IToastNotificationContent toastContent = null; IToastText01 templateContent = ToastContentFactory.CreateToastText01(); templateContent.TextBodyWrap.Text = message; toastContent = templateContent; 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 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); }
public static void Display(string notificationText) { IToastNotificationContent toastContent = null; //Change ToastContentFactory.Template to try other toast types IToastText01 templateContent = ToastContentFactory.CreateToastText01(); templateContent.TextBodyWrap.Text = notificationText; toastContent = templateContent; // Create a toast from the Xml, 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); }
private void toastMessage(string img, string text) { IToastNotificationContent itnc = null; //Tạo toast message template IToastImageAndText01 itoast = ToastContentFactory.CreateToastImageAndText01(); //Đưa nội dung message lên itoast itoast.TextBodyWrap.Text = text; //Đưa image lên itoast itoast.Image.Src = "ms-appx:///Assets/" + img; itnc = itoast; //Tạo toast message ToastNotification tnc = itnc.CreateNotification(); //Hiển thị toast message ToastNotificationManager.CreateToastNotifier().Show(tnc); }
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 void Show(IToastNotificationContent content) { var notification = content.CreateNotification(); ToastNotificationManager.CreateToastNotifier().Show(notification); }
private static void ScheduleSingleNotification(int triggerInSeconds, string title, string text, int id, string notificationProfile) { IToastNotificationContent notificationContent = PrepareNotification(title, text, id, notificationProfile); ScheduleSingleNotification(triggerInSeconds, id, notificationContent, GetMinTriggerInSecondsAllowed(), NotificationsEnabled()); }
public void Show(IToastNotificationContent content) { Notifications.Add(content); }