private void SendToastNotification() { ToastContent content = new ToastContent() { Launch = "lei", Visual = new ToastVisual() { TitleText = new ToastText() { Text = "New message from Lei" }, BodyTextLine1 = new ToastText() { Text = "NotificationsExtensions is great!" }, AppLogoOverride = new ToastAppLogo() { Crop = ToastImageCrop.Circle, Source = new ToastImageSource("http://messageme.com/lei/profile.jpg") } }, Actions = new ToastActionsCustom() { Inputs = { new ToastTextBox("tbReply") { PlaceholderContent = "Type a response" } }, Buttons = { new ToastButton("reply", "reply") { ActivationType = ToastActivationType.Background, ImageUri = "Assets/QuickReply.png", TextBoxId = "tbReply" } } }, Audio = new ToastAudio() { Src = new Uri("ms-winsoundevent:Notification.IM") } }; DataPackage dp = new DataPackage(); dp.SetText(content.GetContent()); Clipboard.SetContent(dp); ToastNotificationManager.CreateToastNotifier().Show(new ToastNotification(content.GetXml())); }
static void Main() { Message bread = JsonConvert.DeserializeObject<Message>(Console.ReadLine()); switch (bread.Action) { case ActionType.CloseAll: ToastNotificationManager.History.Clear(); break; case ActionType.CloseLast: ToastNotificationManager.History.Remove(ToastNotificationManager.History.GetHistory().Last().Tag); break; case ActionType.Show: string imagePath = Path.ChangeExtension(Path.GetTempFileName(), "png"); bread.Image.Save(imagePath, ImageFormat.Png); ToastContent content = new ToastContent() { Visual = new ToastVisual() { TitleText = new ToastText() { Text = bread.Title }, BodyTextLine1 = new ToastText() { Text = bread.Body }, BodyTextLine2 = new ToastText() { Text = bread.AppName, }, AppLogoOverride = new ToastAppLogo { Source = new ToastImageSource("file:///" + imagePath) } } }; if (bread.Silent) { content.Audio = new ToastAudio() { Silent = true }; } if (bread.PersistNotifications) { content.ActivationType = ToastActivationType.Background; } XmlDocument doc = new XmlDocument(); doc.LoadXml(content.GetContent()); ToastNotification toast = new ToastNotification(doc); // too long for a tag? //toast.Tag = Guid.NewGuid().ToString(); ToastNotificationManager.CreateToastNotifier(APP_ID).Show(toast); break; } }
private static void AssertAdaptiveChildInToast(string expectedAdaptiveChildXml, IAdaptiveChild child) { var binding = new ToastBindingGeneric(); // If the child isn't text, we need to add a text element so notification is valid if (!(child is AdaptiveText)) { binding.Children.Add(new AdaptiveText() { Text = "Required text element" }); expectedAdaptiveChildXml = "<text>Required text element</text>" + expectedAdaptiveChildXml; } binding.Children.Add(child); var content = new ToastContent() { Visual = new ToastVisual() { BindingGeneric = binding } }; AssertHelper.AssertXml( "<toast><visual><binding template='ToastGeneric'>" + expectedAdaptiveChildXml + "</binding></visual></toast>", content.GetContent()); }
private static void AssertPayload(string expectedXml, ToastContent toast) { AssertHelper.AssertXml(expectedXml, toast.GetContent()); }
private void Show(ToastContent content) { try { Debug.WriteLine(content.GetContent()); ToastNotificationManager.CreateToastNotifier().Show(new ToastNotification(content.GetXml())); } catch (Exception ex) { var dontWait = new MessageDialog(ex.ToString()).ShowAsync(); } }