public void ShowToast(string s) { var toast = ToastContentFactory.CreateToastImageAndText02(); toast.TextBodyWrap.Text = s; toast.TextHeading.Text = "Windows Toast"; ToastNotificationManager.CreateToastNotifier().Show(toast.CreateNotification()); }
private IToastImageAndText02 BuildToast(PlaybackNotificationOptions options) { var toast = ToastContentFactory.CreateToastImageAndText02(); toast.Image.Src = options.ImageUrl; toast.Image.Alt = "Cover Art"; toast.TextHeading.Text = options.Title; toast.TextBodyWrap.Text = options.Subtitle; toast.Audio.Content = UseSound ? ToastAudioContent.Default : ToastAudioContent.Silent; return(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); }
public MainPage() { this.InitializeComponent(); this.DataContext = new SampleViewModel(); IToastImageAndText02 trying_toast = ToastContentFactory.CreateToastImageAndText02(); trying_toast.TextHeading.Text = "Toast notification Example"; trying_toast.TextBodyWrap.Text = "Animu Quiz app"; ScheduledToastNotification giveittime; giveittime = new ScheduledToastNotification(trying_toast.GetXml(), DateTime.Now.AddSeconds(2)); giveittime.Id = "Any_ID"; ToastNotificationManager.CreateToastNotifier().AddToSchedule(giveittime); }
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); }
/// <summary> /// Post弹出消息对话框可设置WEB的图片 /// </summary> /// <param name="toastImageSrc">Web Uri</param> /// <param name="title">主题</param> /// <param name="description">内容</param> /// <param name="notificationSound">声音(默认是成功的声音)</param> public static void DisplayWebImageCustomToast(string toastImageSrc, string title, string description, NotificationToastSound notificationSound = NotificationToastSound.Success) { IToastImageAndText02 toastContent = ToastContentFactory.CreateToastImageAndText02(); toastContent.TextHeading.Text = title; toastContent.TextBodyWrap.Text = description; toastContent.Image.Src = toastImageSrc; toastContent.Image.Alt = toastImageSrc; switch (notificationSound) { case NotificationToastSound.Success: { toastContent.Audio.Content = ToastAudioContent.Default; break; } case NotificationToastSound.Failure: { toastContent.Audio.Content = ToastAudioContent.Mail; break; } case NotificationToastSound.News: { toastContent.Audio.Content = ToastAudioContent.Reminder; break; } default: { toastContent.Audio.Content = ToastAudioContent.Default; break; } } ToastNotification toast = toastContent.CreateNotification(); ToastNotificationManager.CreateToastNotifier().Show(toast); }
public MainPage() { this.InitializeComponent(); ApplicationView.PreferredLaunchViewSize = new Size(770, 550); ApplicationView.PreferredLaunchWindowingMode = ApplicationViewWindowingMode.PreferredLaunchViewSize; //notification IToastImageAndText02 weather_notifications = ToastContentFactory.CreateToastImageAndText02(); weather_notifications.TextHeading.Text = "Aplikacja pogodowa załadowana poprawnie"; weather_notifications.TextBodyWrap.Text = "WeatherApp"; ScheduledToastNotification giveittime; giveittime = new ScheduledToastNotification(weather_notifications.GetXml(), DateTime.Now.AddSeconds(2)); giveittime.Id = "Any_ID"; ToastNotificationManager.CreateToastNotifier().AddToSchedule(giveittime); //live tiles var template = TileContentFactory.CreateTileSquare150x150PeekImageAndText01(); template.TextBody1.Text = "Aplikacja pogodowa"; template.Image.Src = "ms-appx:///Assets/pogoda.png"; var wideTemlate = TileContentFactory.CreateTileWide310x150PeekImageAndText01(); wideTemlate.TextBodyWrap.Text = "Aplikacja pogodowa - szerszy tile"; wideTemlate.Image.Src = "ms-appx:///Assets/pogoda.png"; wideTemlate.Square150x150Content = template; TileNotification wideNotification = wideTemlate.CreateNotification(); TileUpdater updater = TileUpdateManager.CreateTileUpdaterForApplication(); updater.Update(wideNotification); }
/// <summary> /// Post弹出消息对话框可设置WEB的图片 /// </summary> /// <param name="toastImageSrc"></param> /// <param name="title"></param> /// <param name="description"></param> public static void DisplayWebImageToast(string toastImageSrc, string title, string description, ToastAudioContent toastAudioContent = ToastAudioContent.Default) { //var toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastImageAndText02); //var imageElements = toastXml.GetElementsByTagName("image"); //var imageElement = (XmlElement)imageElements.Item(0); //imageElement.SetAttribute("src", toastImageSrc == null ? string.Empty : toastImageSrc); //imageElement.SetAttribute("alt", ""); //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)); //} ////Debug.WriteLine(toastXml.GetXml()); //var toast = new ToastNotification(toastXml); ////toast.Failed += toast_Failed; //ToastNotificationManager.CreateToastNotifier().Show(toast); IToastImageAndText02 toastContent = ToastContentFactory.CreateToastImageAndText02(); toastContent.TextHeading.Text = title; toastContent.TextBodyWrap.Text = description; toastContent.Image.Src = toastImageSrc; toastContent.Image.Alt = toastImageSrc; toastContent.Audio.Content = toastAudioContent; ToastNotification toast = toastContent.CreateNotification(); ToastNotificationManager.CreateToastNotifier().Show(toast); }
private async void ExtendedSplashScreen_Loaded(object sender, RoutedEventArgs e) { ProgressText.Text = ApplicationData.Current.LocalSettings.Values.ContainsKey("Initialized") && (bool)ApplicationData.Current.LocalSettings.Values["Initialized"] ? "Loading blogs..." : "Initializing for first use: this may take several minutes..."; await App.Instance.DataSource.LoadGroups(); foreach (var group in App.Instance.DataSource.GroupList) { Progress.IsActive = true; ProgressText.Text = "Loading " + group.Title; await App.Instance.DataSource.LoadAllItems(group); } ApplicationData.Current.LocalSettings.Values["Initialized"] = true; // Create a Frame to act as the navigation context and associate it with // a SuspensionManager key var rootFrame = new Frame(); SuspensionManager.RegisterFrame(rootFrame, "AppFrame"); var list = App.Instance.DataSource.GroupList; var totalNew = list.Sum(g => g.NewItemCount); if (totalNew > 99) { totalNew = 99; } if (totalNew > 0) { var badgeContent = new BadgeNumericNotificationContent((uint)totalNew); BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeContent.CreateNotification()); } else { BadgeUpdateManager.CreateBadgeUpdaterForApplication().Clear(); } // load most recent 5 items then order from oldest to newest var query = from i in (from g in list from i in g.Items orderby i.PostDate descending select i).Take(5) orderby i.PostDate select i; var x = 0; var notificationCount = totalNew; TileUpdateManager.CreateTileUpdaterForApplication().Clear(); TileUpdateManager.CreateTileUpdaterForApplication().EnableNotificationQueue(true); foreach (var item in query) { var squareTile = new TileSquarePeekImageAndText04(); squareTile.TextBodyWrap.Text = item.Title; squareTile.Image.Alt = item.Title; squareTile.Image.Src = item.DefaultImageUri.ToString(); var wideTile = new TileWideSmallImageAndText03 { SquareContent = squareTile }; wideTile.Image.Alt = item.Title; wideTile.Image.Src = item.DefaultImageUri.ToString(); wideTile.TextBodyWrap.Text = item.Title; var notification = wideTile.CreateNotification(); notification.Tag = string.Format("Item {0}", x++); TileUpdateManager.CreateTileUpdaterForApplication().Update(notification); // send a notification if (notificationCount-- <= 0) { continue; } var notifier = ToastNotificationManager.CreateToastNotifier(); if (notifier.Setting == NotificationSetting.Enabled) { // send a toast notification var notificationTemplate = ToastContentFactory.CreateToastImageAndText02(); notificationTemplate.Launch = string.Format("Item={0}", item.Id); notificationTemplate.TextHeading.Text = item.Group.Title; notificationTemplate.TextBodyWrap.Text = item.Title; notificationTemplate.Image.Src = item.DefaultImageUri.ToString(); notificationTemplate.Image.Alt = item.Title; var toast = notificationTemplate.CreateNotification(); var date = DateTimeOffset.Now.AddSeconds(30); var scheduledToast = new ScheduledToastNotification(toast.Content, date); notifier.AddToSchedule(scheduledToast); } } if (_activationArgs.Arguments.StartsWith("Group")) { var group = _activationArgs.Arguments.Split('='); rootFrame.Navigate(typeof(GroupDetailPage), group[1]); } else if (_activationArgs.Arguments.StartsWith("Item")) { var item = _activationArgs.Arguments.Split('='); rootFrame.Navigate(typeof(ItemDetailPage), item[1]); } else if (_activationArgs.PreviousExecutionState == ApplicationExecutionState.Terminated) { // Restore the saved session state only when appropriate await SuspensionManager.RestoreAsync(); } if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter if (!rootFrame.Navigate(typeof(GroupedItemsPage), "AllGroups")) { throw new Exception("Failed to create initial page"); } } // Place the frame in the current Window and ensure that it is active Window.Current.Content = rootFrame; Window.Current.Activate(); }