public static void NotifyMessageDeliveryFailed(Recipients recipients, long threadId) { var content = new ToastContent() { Launch = new QueryString() { {"action", "viewConversation" }, { "threadId", threadId.ToString() } }.ToString(), Visual = new ToastVisual() { TitleText = new ToastText() { Text = $"Message delivery failed" }, }, /*Audio = new ToastAudio() { Src = new Uri("ms-winsoundevent:Notification.IM") }*/ }; var doc = content.GetXml(); // Generate WinRT notification var noti = new ToastNotification(doc); ToastNotificationManager.CreateToastNotifier().Show(noti); }
public static void Simple(string textline1, string title = "HFR10") { var content = new ToastContent(); content.Visual = new ToastVisual() { TitleText = new ToastText() { Text = title, }, BodyTextLine1 = new ToastText() { Text = textline1, } }; content.Audio = new ToastAudio() { Src = new Uri("ms-winsoundevent:Notification.IM") }; XmlDocument doc = content.GetXml(); // Generate WinRT notification var toast = new ToastNotification(doc); toast.ExpirationTime = DateTimeOffset.Now.AddSeconds(30); ToastNotificationManager.CreateToastNotifier().Show(toast); }
public void NotifyWithTemperature(string title, string message, float temperature) { StringBuilder sb = new StringBuilder(); ToastVisual visual = new ToastVisual() { TitleText = new ToastText() { Text = title }, BodyTextLine1 = new ToastText() { Text = sb.AppendFormat(message, temperature).ToString() } }; _toastContent = new ToastContent() { Visual = visual, // Arguments when the user taps body of toast Launch = new QueryString() { { "action", "showtemperature" }, { "temperature", temperature.ToString() } }.ToString() }; SendNotification(); }
public void NotifyWithDistance(string title, string message, double distance) { ToastVisual visual = new ToastVisual() { TitleText = new ToastText() { Text = title }, BodyTextLine1 = new ToastText() { Text = message } }; _toastContent = new ToastContent() { Visual = visual, // Arguments when the user taps body of toast Launch = new QueryString() { { "action", "gettingfar" }, { "distance", distance.ToString() } }.ToString() }; SendNotification(); }
public void Test_Toast_XML_Toast_Duration_Long() { var toast = new ToastContent() { Duration = ToastDuration.Long }; AssertPayload("<toast duration='long' />", toast); }
public void Test_Toast_XML_Toast_Duration_Short() { var toast = new ToastContent() { Duration = ToastDuration.Short }; AssertPayload("<toast />", toast); }
public void Test_Toast_XML_Toast_ActivationType_Protocol() { var toast = new ToastContent() { ActivationType = ToastActivationType.Protocol }; AssertPayload("<toast activationType='protocol' />", toast); }
public void Test_Toast_XML_Toast_ActivationType_Background() { var toast = new ToastContent() { ActivationType = ToastActivationType.Background }; AssertPayload("<toast activationType='background' />", toast); }
public void Test_Toast_XML_Toast_ActivationType_Foreground() { var toast = new ToastContent() { ActivationType = ToastActivationType.Foreground }; AssertPayload("<toast />", toast); }
public void Test_Toast_XML_Toast_Launch_Value() { var toast = new ToastContent() { Launch = "tacos" }; AssertPayload("<toast launch='tacos'/>", toast); }
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); }
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); }
public void HandleApiExceptionForCityData(ApiException e, MetaDataCityRow city) { _tracking.TrackException(e, new Dictionary<string, string>() { { "handled", "true"}, { "type", "city"}, { "city", city?.Id } }); var mailStr = string.Format(EmailFormat, ContactEmail, Uri.EscapeDataString(string.Format(_res.ExceptionMailCitySubject, city?.Name)), Uri.EscapeDataString(string.Format(_res.ExceptionMailCityBody, city?.Name, e.Message)) ); var content = new ToastContent { Launch = "handledCityDataApiException", Visual = new ToastVisual { TitleText = new ToastText { Text = _res.ExceptionToastTitle }, BodyTextLine1 = new ToastText { Text = string.Format(_res.ExceptionToastCityContent, city?.Name) } }, Actions = new ToastActionsCustom { Buttons = { new ToastButton(_res.ExceptionToastShowInBrowserButton, city?.Url.ToString()) { ActivationType = ToastActivationType.Protocol, }, new ToastButton(_res.ExceptionToastContactDevButton, mailStr) { ActivationType = ToastActivationType.Protocol, } } } }; ShowToast(content); }
public ToastContent GetToastContent(ToastVisual visual, ToastActionsCustom actions) { var content = new ToastContent(); if (visual != null) { content.Visual = visual; } if (actions != null) { content.Actions = actions; } //content.Audio = new ToastAudio() //{ // Src = new Uri("ms-winsoundevent:Notification.IM") //}; return content; }
public void Run(IBackgroundTaskInstance taskInstance) { Debug.WriteLine("Background Task Started!"); string title = "Holy Balls Background Agent Works!"; string content = "Shits Great Son!"; string imageUrl = "http://community.zimbra.com/cfs-file/__key/communityserver-discussions-components-files/1589/girl-happy.JPG"; ToastVisual visual = new ToastVisual() { TitleText = new ToastText() { Text = title }, BodyTextLine1 = new ToastText() { Text = content }, InlineImages = { new ToastImage() { Source = new ToastImageSource(imageUrl) } } }; ToastContent Tcontent = new ToastContent() { Visual = visual }; var toast = new ToastNotification(Tcontent.GetXml()); toast.ExpirationTime = DateTime.Now.AddHours(1); toast.Tag = "1"; toast.Group = "t1"; ToastNotificationManager.CreateToastNotifier().Show(toast); }
public void ShowToast(string message = "File not found") { var image = "https://raw.githubusercontent.com/Windows-XAML/Template10/master/Assets/Template10.png"; var content = new NotificationsExtensions.Toasts.ToastContent() { Launch = "", Visual = new NotificationsExtensions.Toasts.ToastVisual() { BindingGeneric = new ToastBindingGeneric() { AppLogoOverride = new ToastGenericAppLogo { HintCrop = ToastGenericAppLogoCrop.Circle, Source = image }, Children = { new AdaptiveText { Text = "File not found." } }, Attribution = new ToastGenericAttributionText { Text = "Request Cancelled." }, } }, Audio = new NotificationsExtensions.Toasts.ToastAudio() { Src = new Uri("ms-winsoundevent:Notification.IM") } }; var notification = new Windows.UI.Notifications.ToastNotification(content.GetXml()); var notifier = Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier(); notifier.Show(notification); }
private void ToastGenerator() { const string title = "Click on time of Emergency!"; var visual = new ToastVisual() { TitleText = new ToastText() { Text = title } }; const int conversationId = 177777; var toastContent = new ToastContent() { Visual = visual, Launch = new QueryString() { {"conversationId", conversationId.ToString()} }.ToString() }; var toast = new ToastNotification(toastContent.GetXml()) { ExpirationTime = DateTime.Now.AddHours(5), SuppressPopup = true, Tag = "Friends" }; if (ToastNotificationManager.History != null) { ToastNotificationManager.History.Remove("Friends"); } ToastNotificationManager.CreateToastNotifier().Show(toast); }
public async Task ShowMessage(string text) { var content = new ToastContent() { Visual = new ToastVisual() { TitleText = new ToastText() { Text = "Temperature Listener" }, BodyTextLine1 = new ToastText() { Text = text } } }; var toast = new ToastNotification(content.GetXml()); var toastNotifier = ToastNotificationManager.CreateToastNotifier(); toastNotifier.Show(toast); }
public static void NewMessage(MessageRecord message) { var content = new ToastContent() { Launch = new QueryString() { {"action", "viewConversation" }, { "threadId", message.ThreadId.ToString() } }.ToString(), Visual = new ToastVisual() { TitleText = new ToastText() { Text = $"{message.IndividualRecipient.ShortString} sent you a message" }, BodyTextLine1 = new ToastText() { Text = $"{message.Body.Body}" } }, Actions = new ToastActionsCustom() { Inputs = { new ToastTextBox("tbReply") { PlaceholderContent = "Type a response" } }, Buttons = { new ToastButton("reply", "reply") { ActivationType = ToastActivationType.Background, ImageUri = "Assets/ic_done_all_white_18dp.png", TextBoxId = "tbReply" } } }, Audio = new ToastAudio() { Src = new Uri("ms-winsoundevent:Notification.IM") } }; var doc = content.GetXml(); // Generate WinRT notification var noti = new ToastNotification(doc); ToastNotificationManager.CreateToastNotifier().Show(noti); }
private void ShowNotification(ToastContent toast) { _notifier.Show(new ToastNotification(toast.GetXml())); }
private void Button_Click(object sender, RoutedEventArgs e) { ToastContent tnc = new ToastContent() { Visual = new ToastVisual() { TitleText = new ToastText() { Text = "aaaaaaaa" } } }; var tn = new Windows.UI.Notifications.ToastNotification(tnc.GetXml()); var notifier = Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier(); notifier.Show(tn); }
/// <summary> /// Updates all of the notifications based on the message list. /// </summary> /// <param name="newMessages"></param> public async void UpdateNotifications(List<Message> newMessages) { bool updateSliently = !m_baconMan.IsBackgroundTask; // Check if we are disabled. if (!IsEnabled || !m_baconMan.UserMan.IsUserSignedIn) { // Clear things out ToastNotificationManager.History.Clear(); // Clear the tile BadgeNumericNotificationContent content = new BadgeNumericNotificationContent(); content.Number = 0; BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(new BadgeNotification(content.GetXml())); return; } try { // Get the current state of the messages. IReadOnlyList<ToastNotification> history = ToastNotificationManager.History.GetHistory(); // We need to keep track of anything new to send to the band. List<Tuple<string, string, string>> newNotifications = new List<Tuple<string, string, string>>(); // We also need to keep track of how many are unread so we can updates our badge. int unreadCount = 0; if (NotificationType == 0) { // For help look here. // http://blogs.msdn.com/b/tiles_and_toasts/archive/2015/07/09/quickstart-sending-a-local-toast-notification-and-handling-activations-from-it-windows-10.aspx // We need to keep track of what notifications we should have so we can remove ones we don't need. Dictionary<string, bool> unReadMessages = new Dictionary<string, bool>(); foreach (Message message in newMessages.Reverse<Message>()) { // If it is new if (message.IsNew) { unreadCount++; // Add the message to our list unReadMessages.Add(message.Id, true); // Check if it is already been reported but dismissed from the UI if (ShownMessageNotifications.ContainsKey(message.Id)) { continue; } // If not add that we are showing it. ShownMessageNotifications[message.Id] = true; // Check if it is already in the UI foreach (ToastNotification oldToast in history) { if (oldToast.Tag.Equals(message.Id)) { continue; } } // Get the post title. string title = ""; if (message.WasComment) { string subject = message.Subject; if (subject.Length > 0) { subject = subject.Substring(0, 1).ToUpper() + subject.Substring(1); } title = subject + " from " + message.Author; } else { title = message.Subject; } // Get the body string body = message.Body; // Add the notification to our list newNotifications.Add(new Tuple<string, string, string>(title, body, message.Id)); } } // Make sure that all of the messages in our history are still unread // if not remove them. for(int i = 0; i < history.Count; i++) { if(!unReadMessages.ContainsKey(history[i].Tag)) { // This message isn't unread any longer. ToastNotificationManager.History.Remove(history[i].Tag); } } // Save any settings we changed SaveSettings(); } else { // Count how many are unread foreach (Message message in newMessages) { if (message.IsNew) { unreadCount++; } } // If we have a different unread count now show the notification. if(LastKnownUnreadCount != unreadCount) { // Update the notification. LastKnownUnreadCount = unreadCount; // Clear anything we have in the notification center already. ToastNotificationManager.History.Clear(); if (unreadCount != 0) { newNotifications.Add(new Tuple<string, string, string>($"You have {unreadCount} new inbox message" + (unreadCount == 1 ? "." : "s."), "", "totalCount")); } } } // For every notification, show it. bool hasShownNote = false; foreach(Tuple<string, string, string> newNote in newNotifications) { // Make the visual ToastVisual visual = new ToastVisual(); visual.TitleText = new ToastText() { Text = newNote.Item1 }; if(!String.IsNullOrWhiteSpace(newNote.Item2)) { visual.BodyTextLine1 = new ToastText() { Text = newNote.Item2 }; } // Make the toast content ToastContent toastContent = new ToastContent(); toastContent.Visual = visual; toastContent.Launch = c_messageInboxOpenArgument; toastContent.ActivationType = ToastActivationType.Foreground; toastContent.Duration = ToastDuration.Short; var toast = new ToastNotification(toastContent.GetXml()); toast.Tag = newNote.Item3; // Only show if we should and this is the first message to show. toast.SuppressPopup = hasShownNote || updateSliently || AddToNotificationCenterSilently; ToastNotificationManager.CreateToastNotifier().Show(toast); // Mark that we have shown one. hasShownNote = true; } // Make sure the main tile is an iconic tile. m_baconMan.TileMan.EnsureMainTileIsIconic(); // Update the badge BadgeNumericNotificationContent content = new BadgeNumericNotificationContent(); content.Number = (uint)unreadCount; BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(new BadgeNotification(content.GetXml())); // Update the band if we have one. if(!updateSliently) { await m_baconMan.BackgroundMan.BandMan.UpdateInboxMessages(newNotifications, newMessages); } // If all was successful update the last time we updated LastUpdateTime = DateTime.Now; } catch (Exception ex) { m_baconMan.TelemetryMan.ReportUnExpectedEvent(this, "messageUpdaterFailed", ex); m_baconMan.MessageMan.DebugDia("failed to update message notifications", ex); } // When we are done release the deferral ReleaseDeferal(); }
private async void downloadbutton_Click(object sender, RoutedEventArgs e) { try { Tracker myTracker = EasyTracker.GetTracker(); myTracker.SendEvent("Downloads", "Download Button Clicked", "Download Attempted",1); Uri source = new Uri("http://convertmyurl.net/?url=" + urltext.Text.Trim()); ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings; StorageFolder folder; string pathname; object v = localSettings.Values["pathkey"]; if (v != null) { pathname = v.ToString(); try { folder = await StorageFolder.GetFolderFromPathAsync(pathname); } catch(FileNotFoundException ex) { folder = await KnownFolders.PicturesLibrary.CreateFolderAsync("PDF Me", CreationCollisionOption.OpenIfExists); } } else { folder = await KnownFolders.PicturesLibrary.CreateFolderAsync("PDF Me", CreationCollisionOption.OpenIfExists); } string filename; object value = localSettings.Values["filekey"]; if (value != null) { filename = localSettings.Values["filekey"].ToString(); Debug.WriteLine("New filename"); } else { filename = "PDF Me.pdf"; Debug.WriteLine("Default filename"); } char[] a = new char[25]; StorageFile destinationFile; if (browserweb.DocumentTitle.Length > 60) { destinationFile = await folder.CreateFileAsync( "PDF Me.pdf", CreationCollisionOption.GenerateUniqueName); } else { destinationFile = await folder.CreateFileAsync( browserweb.DocumentTitle+".pdf", CreationCollisionOption.GenerateUniqueName); } BackgroundDownloader downloader = new BackgroundDownloader(); DownloadOperation download = downloader.CreateDownload(source, destinationFile); downloading.Visibility = Visibility.Visible; downloadprogress.Visibility = Visibility.Visible; downloadprogress.IsActive = true; await download.StartAsync(); int progress = (int)(100 * (download.Progress.BytesReceived / (double)download.Progress.TotalBytesToReceive)); if (progress >= 100) { myTracker.SendEvent("Downloads", "Download Finished", "Download Successfull", 2); downloading.Visibility = Visibility.Collapsed; downloading.Text = "Downloading: "; downloadprogress.Visibility = Visibility.Collapsed; BasicProperties basic = await download.ResultFile.GetBasicPropertiesAsync(); string size; double siz = basic.Size; // ulong mb = ulong.Parse(1000000); if (siz > 1000000) { double s = siz / 1000000; size = s.ToString() + "MB"; } else { double s = siz / 1000; size = s.ToString() + "KB"; } DatabaseController.AddDownload(destinationFile.Name, download.ResultFile.Path,download.ResultFile.DateCreated.DateTime.ToString(),size); AdDuplex.InterstitialAd interstitialAd = new AdDuplex.InterstitialAd("180815"); await interstitialAd.LoadAdAsync(); /* MessageDialog m = new MessageDialog(destinationFile.Name + " is saved in PDF Me folder.", "Download Completed"); m.Commands.Add(new UICommand("Open File", (command) => { Launcher.LaunchFileAsync(download.ResultFile); } )); m.Commands.Add(new UICommand("Close", (command) => { }, 0)); m.CancelCommandIndex = 0; await m.ShowAsync(); */ string title = "Download Successful"; string content = destinationFile.Name + " is saved in PDF Me folder."; ToastVisual visual = new ToastVisual() { TitleText = new ToastText() { Text = title }, BodyTextLine1 = new ToastText() { Text = content } }; // In a real app, these would be initialized with actual data int conversationId = 384928; // Construct the actions for the toast (inputs and buttons) ToastActionsCustom actions = new ToastActionsCustom() { Buttons = { new ToastButton("Open", new QueryString() { { "action", "open" }, {"file",destinationFile.Path } }.ToString()) { ActivationType = ToastActivationType.Foreground, // Reference the text box's ID in order to // place this button next to the text box }, new ToastButton("Share", new QueryString() { { "action", "share" }, {"file",destinationFile.Path } }.ToString()) { ActivationType = ToastActivationType.Foreground } } }; // 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() { { "conversationId", conversationId.ToString() } }.ToString() }; // And create the toast notification var toast = new ToastNotification(toastContent.GetXml()); toast.ExpirationTime = DateTime.Now.AddSeconds(10); ToastNotificationManager.CreateToastNotifier().Show(toast); await interstitialAd.LoadAdAsync(); await interstitialAd.ShowAdAsync(); } else { downloading.Visibility = Visibility.Collapsed; downloadprogress.Visibility = Visibility.Collapsed; BasicProperties basic = await download.ResultFile.GetBasicPropertiesAsync(); double siz = basic.Size; if(siz == 0) { await destinationFile.DeleteAsync(); myTracker.SendEvent("Downloads", "Download Failed due to Server Error", null, 3); MessageDialog m = new MessageDialog("Server is down. Try again later","Fatal Error"); await m.ShowAsync(); } } /* var authClient = new LiveAuthClient(); var authResult = await authClient.LoginAsync(new string[] { "wl.skydrive", "wl.skydrive_update" }); if (authResult.Session == null) { throw new InvalidOperationException("You need to sign in and give consent to the app."); } var liveConnectClient = new LiveConnectClient(authResult.Session); string skyDriveFolder = await CreateDirectoryAsync(liveConnectClient, "PDF Me - Saved PDFs", "me/skydrive"); */ } catch (Exception ex) { Tracker myTracker = EasyTracker.GetTracker(); // Get a reference to tracker. myTracker.SendException(ex.Message, false); MessageDialog m = new MessageDialog(ex.ToString()); m.ShowAsync(); } }
private async void ReminderRegister() { const string title = "Are you there?"; const string content = "Click the button below if you are alright!"; var visual = new ToastVisual { TitleText = new ToastText { Text = title }, BodyTextLine1 = new ToastText { Text = content } }; var actions = new ToastActionsCustom { Buttons = { new ToastButton("Dismiss", new QueryString { {"action", "dismiss"} }.ToString()) { ActivationType = ToastActivationType.Background } } }; const int conversationId = 177777; var toastContent = new ToastContent { Visual = visual, Actions = actions, Scenario = ToastScenario.Reminder, Launch = new QueryString { {"action","viewConversation" }, {"conversationId", conversationId.ToString()} }.ToString() }; if (Time > DateTime.Now.TimeOfDay) { try { var scheduled = new ScheduledToastNotification(toastContent.GetXml(), new DateTimeOffset(DateTime.Today + Time)) {Id = "scheduledtoast"}; var timeDifference = Time - DateTime.Now.TimeOfDay; timeDifference = timeDifference.Add(new TimeSpan(0, 0, 15, 0)); const string taskName = "Reminder"; var taskBuilder = new BackgroundTaskBuilder(); taskBuilder.Name = taskName; taskBuilder.TaskEntryPoint = typeof (Reminder).FullName; taskBuilder.SetTrigger(new TimeTrigger(Convert.ToUInt32(timeDifference.Minutes.ToString()), true)); var backgroundAccessStatus = await BackgroundExecutionManager.RequestAccessAsync(); foreach (var task in BackgroundTaskRegistration.AllTasks.Where(task => task.Value.Name == taskName)) { task.Value.Unregister(true); } taskBuilder.Register(); ToastNotificationManager.CreateToastNotifier().AddToSchedule(scheduled); } catch (Exception e) { Debug.WriteLine(e); } } else { try { var scheduled = new ScheduledToastNotification(toastContent.GetXml(), new DateTimeOffset(DateTime.Today.AddDays(1) + Time)) {Id = "scheduledtoast"}; var timeDifference = Time.Add(new TimeSpan(1,0,0,0)) ; timeDifference = timeDifference.Add(new TimeSpan(0, 0, 15, 0)); const string taskName = "Reminder"; var taskBuilder = new BackgroundTaskBuilder(); taskBuilder.Name = taskName; taskBuilder.TaskEntryPoint = typeof (Reminder).FullName; taskBuilder.SetTrigger(new TimeTrigger(Convert.ToUInt32(timeDifference.Minutes.ToString()), true)); var backgroundAccessStatus = await BackgroundExecutionManager.RequestAccessAsync(); foreach (var task in BackgroundTaskRegistration.AllTasks.Where(task => task.Value.Name == taskName)) { task.Value.Unregister(true); } ToastNotificationManager.CreateToastNotifier().AddToSchedule(scheduled); taskBuilder.Register(); } catch (Exception e) { Debug.WriteLine(e); } } }
public void ShowToast(Models.FileInfo file, string message = "Success") { var image = "https://raw.githubusercontent.com/Windows-XAML/Template10/master/Assets/Template10.png"; if (file.Ref == null) { var content = new NotificationsExtensions.Toasts.ToastContent() { Launch = "", Visual = new NotificationsExtensions.Toasts.ToastVisual() { BindingGeneric = new ToastBindingGeneric() { AppLogoOverride = new ToastGenericAppLogo { HintCrop = ToastGenericAppLogoCrop.Circle, Source = image }, Children = { new AdaptiveText { Text = "File save cancelled." } }, Attribution = new ToastGenericAttributionText { Text = "User Cancelled." }, } }, Audio = new NotificationsExtensions.Toasts.ToastAudio() { Src = new Uri("ms-winsoundevent:Notification.IM") } }; var notification = new ToastNotification(content.GetXml()); ToastNotificationManager.CreateToastNotifier().Show(notification); } else { var content = new NotificationsExtensions.Toasts.ToastContent() { Launch = file.Ref.Path, Visual = new NotificationsExtensions.Toasts.ToastVisual() { BindingGeneric = new ToastBindingGeneric() { AppLogoOverride = new ToastGenericAppLogo { HintCrop = ToastGenericAppLogoCrop.Circle, Source = image }, Children = { new AdaptiveText { Text = file.Name } }, Attribution = new ToastGenericAttributionText { Text = message }, } }, Audio = new NotificationsExtensions.Toasts.ToastAudio() { Src = new Uri("ms-winsoundevent:Notification.IM") } }; var notification = new ToastNotification(content.GetXml()); ToastNotificationManager.CreateToastNotifier().Show(notification); } }
public static ToastContent CreateAlertToast(HeWeatherModel fetchresult, CitySettingsModel currentCityModel) { var lo = new ResourceLoader(); var action = new ToastActionsCustom(); var button = new ToastButton(lo.GetString("Known"), "Today_Alert_Dismiss"); button.ActivationType = ToastActivationType.Background; action.Buttons.Add(button); action.Buttons.Add(new ToastButtonDismiss(lo.GetString("Dismiss"))); var alarm = fetchresult.Alarms[0]; ToastContent t = new ToastContent() { Scenario = ToastScenario.Reminder, Launch = currentCityModel.Id, Actions = action, Visual = new ToastVisual() { TitleText = new ToastText() { Text = alarm.Title }, BodyTextLine1 = new ToastText() { Text = alarm.Text } } }; return t; }
private async static void ShowToast(int checkInId, string eventName) { // In a real app, these would be initialized with actual data string title = "Check-in completed!"; string content = "You checked-in to " + eventName; 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/StoreLogo.scale-100.png"; //int conversationId = 384928; // Construct the visuals of the toast ToastVisual 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.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); }
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())); }
/// <summary> /// Provides error handling code for Petrolhead /// </summary> /// <param name="sender">Object that threw the unhandled exception</param> /// <param name="e">Event args for the instance</param> private async void App_UnhandledException(object sender, UnhandledExceptionEventArgs e) { try { e.Handled = true; await DispatcherWrapper.Current().DispatchAsync(async () => { try { MessageDialog dialog = new MessageDialog("Sorry, but an error occurred that Petrolhead wasn't built to handle.", "Fatal Error"); if (e.Exception is FileNotFoundException) { Telemetry.TrackEvent("Exit-Dialog-Display-Canceled"); return; } dialog.Commands.Add(new UICommand("Exit", (command) => { Exit(); })); await dialog.ShowAsync(); } catch (Exception ex) { Telemetry.TrackException(ex); ToastContent content = new ToastContent() { Visual = new ToastVisual() { TitleText = new ToastText() { Text = "Fatal Error" }, BodyTextLine1 = new ToastText() { Text = "Petrolhead couldn't display a dialog to inform you about the problem, so it has closed." }, }, Scenario = ToastScenario.Reminder, }; ToastNotification toast = new ToastNotification(content.GetXml()); ToastNotificationManager.CreateToastNotifier().Show(toast); Exit(); } }); } catch (Exception ex) { Telemetry.TrackException(ex); } }
public static ToastContent CreateAlarmToast(string[] str, CitySettingsModel currentCityModel) { var lo = new ResourceLoader(); var action = new ToastActionsCustom(); var button = new ToastButton(lo.GetString("Known"), "Today_Alarm_Dismiss"); button.ActivationType = ToastActivationType.Background; action.Buttons.Add(button); action.Buttons.Add(new ToastButtonDismiss(lo.GetString("Okay"))); ToastContent t = new ToastContent() { Scenario = ToastScenario.Reminder, Launch = currentCityModel.Id, Actions = action, Visual = new ToastVisual() { TitleText = new ToastText() { Text = str[0] }, BodyTextLine1 = new ToastText() { Text = str[1] } } }; return t; }
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() { 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.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); }
public static async Task<XmlDocument> CreateToast(HeWeatherModel model, CitySettingsModel currentCity, SettingsModel settings, DateTime DueTime) { var glance = Glance.GenerateGlanceDescription(model, false, settings.Preferences.TemperatureParameter, DueTime); var ctos = new ConditiontoTextConverter(); var dueIndex = Array.FindIndex(model.DailyForecast, x => { return x.Date.Date == DueTime.Date; }); var uri = await settings.Immersive.GetCurrentBackgroundAsync(model.DailyForecast[dueIndex].Condition.DayCond, false); var loader = new ResourceLoader(); var toast = new ToastContent() { Scenario = ToastScenario.Default, ActivationType = ToastActivationType.Foreground, Duration = ToastDuration.Long, Launch = currentCity.Id, Visual = new ToastVisual() { TitleText = new ToastText() { Text = string.Format(loader.GetString("Today_Weather"), currentCity.City) }, BodyTextLine1 = new ToastText() { Text = ctos.Convert(model.DailyForecast[dueIndex].Condition.DayCond, null, null, null) + ", " + ((model.DailyForecast[dueIndex].HighTemp + model.DailyForecast[dueIndex].LowTemp) / 2).Actual(settings.Preferences.TemperatureParameter) }, BodyTextLine2 = new ToastText() { Text = glance }, } }; var xml = toast.GetXml(); var e = xml.CreateElement("image"); e.SetAttribute("placement", "hero"); e.SetAttribute("src", uri.AbsoluteUri); var b = xml.GetElementsByTagName("binding"); b.Item(0).AppendChild(e); return xml; }