private async void SendClick(object sender, RoutedEventArgs e) { VisualStateManager.GoToElementState(Content as Grid, "Sending", true); //await Task.Yield(); await Task.Delay(500); var uri = TB_ChannelURL.Text; var secret = TB_ClientSecret.Text; var sid = TB_PackageSID.Text; var result = await Task.Run(() => { try { var notificationType = "wns/toast"; var contentType = "text/xml"; var accessToken = GetAccessToken(secret, sid); var request = HttpWebRequest.Create(uri) as HttpWebRequest; request.Method = "POST"; request.Headers.Add("X-WNS-Type", notificationType); request.ContentType = contentType; request.Headers.Add("Authorization", String.Format("Bearer {0}", accessToken.AccessToken)); var tileContent = ToastContentFactory.CreateToastText01(); tileContent.TextBodyWrap.Text = "123 Test!"; byte[] contentInBytes = Encoding.UTF8.GetBytes(tileContent.ToString()); using (Stream requestStream = request.GetRequestStream()) requestStream.Write(contentInBytes, 0, contentInBytes.Length); using (HttpWebResponse webResponse = (HttpWebResponse)request.GetResponse()) { var txt = webResponse.StatusCode.ToString(); return(txt); } } catch (Exception ex) { return(ex.Message); } }); MessageBox.Show($"Response '{result}", "Sending..."); VisualStateManager.GoToElementState(Content as Grid, "NotSending", true); }
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 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); }
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); }
private void showToast(string str) { var toast = ToastContentFactory.CreateToastText01(); toast.TextBodyWrap.Text = str; toast.Duration = NotificationsExtensions.ToastContent.ToastDuration.Long; //Shortだと設定できない(実行時に例外発生)! toast.Audio.Content = NotificationsExtensions.ToastContent.ToastAudioContent.LoopingAlarm; toast.Audio.Loop = true; //なんだろう? //toast.Launch = "{\"type\":\"toast\",\"param1\":\"12345\",\"param2\":\"67890\"}"; var toastNfy = toast.CreateNotification(); ToastNotificationManager.CreateToastNotifier().Show(toastNfy); }
/// <summary> /// 토스트 /// </summary> /// <param name="body"></param> /// <param name="header"></param> public override void ToastShow(string body, string header = null) { IToastNotificationContent templateContent; if (header == null) { templateContent = ToastContentFactory.CreateToastText01(); ((IToastText01)templateContent).TextBodyWrap.Text = body; } else { templateContent = ToastContentFactory.CreateToastText02(); ((IToastText02)templateContent).TextHeading.Text = header; ((IToastText02)templateContent).TextBodyWrap.Text = body; } ToastNotification toast = templateContent.CreateNotification(); ToastNotificationManager.CreateToastNotifier().Show(toast); }
/// <summary> /// 创建通知信息 /// </summary> /// <param name="toastText"></param> public static void CreateToast(string toastText) { IToastNotificationContent toastContent = null; IToastText01 templateContent = ToastContentFactory.CreateToastText01(); templateContent.TextBodyWrap.Text = toastText; templateContent.Audio.Content = ToastAudioContent.SMS; 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); }
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); }