GetXml() public method

Retrieves the notification XML content as a WinRT XmlDocument, so that it can be used with a local toast notification's constructor on either Windows.UI.Notifications.ToastNotification or Windows.UI.Notifications.ScheduledToastNotification.
public GetXml ( ) : XmlDocument
return Windows.Data.Xml.Dom.XmlDocument
Example #1
0
        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);
        }
Example #2
0
        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);
        }
Example #3
0
        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 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);
        }
Example #6
0
        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);
    }
        private void DowloadFinish(StorageFile destinationFile)
        {
            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);
        }
        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);
                }
            }
            
        }
Example #11
0
        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 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()));
        }
Example #13
0
        public static void Do(string title, string b1, string b2)
        {
            ToastVisual visual = new ToastVisual()
            {
                TitleText = new ToastText()
                {
                    Text = title
                },
            };

            if (b1 != "")
            {
                visual.BodyTextLine1 = new ToastText()
                {
                    Text = b1
                };
            }

            if (b2 != "")
            {
                visual.BodyTextLine2 = new ToastText()
                {
                    Text = b2
                };
            }

            ToastContent toastContent = new ToastContent()
            {
                Visual = visual,
                Audio = null

            };

            var toast = new ToastNotification(toastContent.GetXml());

            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
 private void ShowNotification(ToastContent toast)
 {
     _notifier.Show(new ToastNotification(toast.GetXml()));
 }
Example #15
0
		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 static async void BackgroundProcessRegisterer()
        {
            const string taskName = "ActionCenterToastMaker";

            var backgroundAccessStatus = await BackgroundExecutionManager.RequestAccessAsync();

            if (backgroundAccessStatus != BackgroundAccessStatus.AllowedMayUseActiveRealTimeConnectivity &&
                backgroundAccessStatus != BackgroundAccessStatus.AllowedWithAlwaysOnRealTimeConnectivity) return;
            if (BackgroundTaskRegistration.AllTasks.Any(task => task.Value.Name == taskName))
            {
                return;
            }

            var taskBuilder = new BackgroundTaskBuilder();
            taskBuilder.Name = taskName;
            taskBuilder.TaskEntryPoint = typeof(BackgroundProcesses.ActionCenterToastMaker).FullName;
            taskBuilder.SetTrigger(new TimeTrigger(500, false));

            var register = taskBuilder.Register();

            //Create a new Toast immediately after user toggles the switch     
            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);


        }
Example #17
0
 private void Show(ToastContent content)
 {
     try
     {
         ToastNotificationManager.CreateToastNotifier().Show(new ToastNotification(content.GetXml()));
       
     }
     catch (Exception ex)
     {
         //yolo
     }
 }
Example #18
0
        void ShowToast(DetailPageViewModel detailPageViewModel)
        {
            var data = detailPageViewModel.Value;
            var image = "https://raw.githubusercontent.com/Windows-XAML/Template10/master/Assets/Template10.png";

            var content = new ToastContent()
            {
                Launch = data,
                Visual = new ToastVisual()
                {
                    TitleText = new ToastText()
                    {
                        Text = "Secondary tile pinned"
                    },

                    BodyTextLine1 = new ToastText()
                    {
                        Text = detailPageViewModel.Value
                    },

                    AppLogoOverride = new ToastAppLogo()
                    {
                        Crop = ToastImageCrop.Circle,
                        Source = new ToastImageSource(image)
                    }
                },
                Audio = new ToastAudio()
                {
                    Src = new Uri("ms-winsoundevent:Notification.IM")
                }
            };

            var notification = new ToastNotification(content.GetXml());
            var notifier = ToastNotificationManager.CreateToastNotifier();
            notifier.Show(notification);
        }
Example #19
0
 private void ShowToast(ToastContent content)
 {
     var now = DateTime.Now;
     //show only one exception every 5 sec (minimum value for toast notifications to be visible)
     if (_lastException == null || now - _lastException.Value > TimeSpan.FromSeconds(5))
     {
         _lastException = DateTime.Now;
         var notifier = ToastNotificationManager.CreateToastNotifier();
         var notification = new ToastNotification(content.GetXml());
         notifier.Show(notification);
     }
 }
Example #20
0
 private void Show(ToastContent content)
 {
     ToastNotificationManager.CreateToastNotifier().Show(new ToastNotification(content.GetXml()));
 }
Example #21
0
        public static void Do(Match fromWho, Message message_obj)
        {
            ToastVisual visual = new ToastVisual()
            {
                TitleText = new ToastText()
                {
                    Text = fromWho.person.name + " has sent you a message"
                },
            };

            string textForToast = "";

            if (message_obj.type == "gif")
            {
                textForToast = "Sent you a Giphy";
            }
            else
            {
                var t = message_obj.message;
                textForToast = t;
            }

            visual.BodyTextLine1 = new ToastText()
            {
                Text = textForToast
            };

            // Pass a payload as JSON to the Toast
            dynamic payload = new JObject();
            payload.source = typeof(NewMessageToast).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 Message", payload_json)
                        {
                            ActivationType = ToastActivationType.Foreground,
                        },
                        new ToastButtonDismiss()
                    }
                },
                Launch = payload_json
            };

            var toast = new ToastNotification(toastContent.GetXml());

            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
Example #22
0
        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);
            }
        }
        /// <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();
        }
Example #24
0
        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 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);
        }
Example #26
0
        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;
        }
Example #27
0
 private void ShowStillAliveToast()
 {
     var content = new ToastContent
     {
         Launch = "toastResponse",
         Visual = new ToastVisual
         {
             TitleText = new ToastText{Text = "Still alive!"},
             BodyTextLine1 = new ToastText{Text = DateTime.Now.ToString("G")},
         },
         Actions = new ToastActionsSnoozeAndDismiss()
     };
     var doc = content.GetXml();
     var toast = new ToastNotification(doc);
     var notifier = ToastNotificationManager.CreateToastNotifier();
     notifier.Show(toast);
 }
Example #28
0
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            BackgroundTaskDeferral _defferal = taskInstance.GetDeferral();
            var appdata = ApplicationData.Current.LocalSettings;
            if (!(bool) (appdata.Values["TileUpdates"] ?? false) && !(bool) (appdata.Values["UseToasts"] ?? false)) // if task isn't needed, kill it
            {
                _defferal.Complete();
                return;
            }

            PasswordVault vault = new PasswordVault();
            PasswordCredential cred;
            try
            {
                cred = vault.FindAllByResource("MYUW").First(); // Make sure this matches CredResName
            }
            catch
            {
                _defferal.Complete();
                return;
            }

            var connector = new MUConnector(cred);
            if (await connector.Login())
            {
                
                //double lastValue = (float)(appdata.Values["LastValue"] ?? -1); //shit's stored as a float...  avoids invalid cast

                float lastValue = -1;

                if (appdata.Values.ContainsKey("LastValue"))
                {
                    float? lv = appdata.Values["LastValue"] as float?; // stupid workarounds for float precision
                    lastValue = lv.Value;
                }
                var hfs = await connector.GetHfsData();
                var term = await connector.GetTermInfo();

                double average = hfs.resident_dining.balance / term.AdjustedDaysRemaining(LoadSavedDates());

                if ((bool)(appdata.Values["TileUpdates"] ?? false))
                {
                    var bindingContent = new TileBindingContentAdaptive();
                    var medBindingContent = new TileBindingContentAdaptive();
                    var items = bindingContent.Children;
                    var medItems = medBindingContent.Children;

                    medItems.Add(new TileText()
                    {
                        Text = $"{hfs.resident_dining.balance:C} remaining",
                        Style = TileTextStyle.Body
                    });

                    items.Add(new TileText()
                    {
                        Text = $"{hfs.resident_dining.balance:C} remaining",
                        Style = TileTextStyle.Subtitle
                    });

                    var line2 = new TileText()
                    {
                        Text = $"{term.AdjustedDaysRemaining(LoadSavedDates())} days",
                        Style = TileTextStyle.Caption
                    };

                    var line3 = new TileText()
                    {            
                        Text = $"${average:0.00} per day",
                        Style = TileTextStyle.Caption
                    };

                    items.Add(line2);
                    items.Add(line3);
                    medItems.Add(line2);
                    medItems.Add(line3);

                    var tileBinding = new TileBinding()
                    {
                        Content = bindingContent,
                        DisplayName = "FoodTile",
                        Branding = TileBranding.NameAndLogo
                    };

                    var medTileBinding = new TileBinding()
                    {
                        Content = medBindingContent,
                        DisplayName = "FoodTile",
                        Branding = TileBranding.NameAndLogo
                    };

                    var content = new TileContent()
                    {
                        Visual = new TileVisual
                        {
                            TileMedium = medTileBinding,
                            TileWide = tileBinding,
                            TileLarge = tileBinding
                        }
                    };

                    var note = new TileNotification(content.GetXml());
                    var updater = TileUpdateManager.CreateTileUpdaterForApplication();

                    updater.Update(note);
                }

                if (hfs.resident_dining.balance != lastValue)
                {
                    if ((bool)(appdata.Values["UseToasts"] ?? false))
                    {
                        var toastContent = new ToastContent()
                        {
                            Visual = new ToastVisual()
                            {
                                TitleText = new ToastText()
                                {
                                    Text = $"Dining Balance ${hfs.resident_dining.balance:0.00}"
                                },
                                BodyTextLine1 = new ToastText()
                                {
                                    Text = $"New daily average ${average:0.00}"
                                },
                                BodyTextLine2 = new ToastText()
                                {
                                    Text = $"{term.AdjustedDaysRemaining(LoadSavedDates())} days remaining in quarter"
                                }
                            }
                        };

                        var note = ToastNotificationManager.CreateToastNotifier();
                        var toast = new ToastNotification(toastContent.GetXml());
                        note.Show(toast);
                    }
                    appdata.Values["LastValue"] = hfs.resident_dining.balance;
                }
            }
            connector.Dispose();
            _defferal.Complete();
        }
Example #29
0
        /// <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);
            }
        }
Example #30
0
        private void DownloadStarted()
        {
            string title = "Download Started";
            int conversationId = 384928;
            string content = " Webpage is being converted to PDF...";
            ToastVisual visual = new ToastVisual()
            {
                TitleText = new ToastText()
                {
                    Text = title
                },

                BodyTextLine1 = new ToastText()
                {
                    Text = content
                }
            };
            ToastContent toastContent = new ToastContent()
            {
                Visual = visual,


                // Arguments when the user taps body of toast
                Launch = new QueryString()
{

{ "conversationId", conversationId.ToString() }

}.ToString()
            };
            var toast = new ToastNotification(toastContent.GetXml());
            toast.ExpirationTime = DateTime.Now.AddSeconds(5);
            ToastNotificationManager.CreateToastNotifier().Show(toast);
        }
        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);
        }
        //Een (eenmalige) pop up tonen om toestemming aan de gebruiker te vragen voor zijn locatie
        private async void LocatieToestemmingVragen()
        {
            try
            {
                //De pop up tonen en toestemming vragen
                var accessStatus = await Geolocator.RequestAccessAsync();

                //De mogelijke antwoorden overlopen
                switch (accessStatus)
                {
                    case GeolocationAccessStatus.Allowed: //De gebruiker heeft ons toegang gegeven

                        //Mag verdergaan en inloggen
                        this.EnableLogin = true;

                        //aanmaken Geolocator
                        Geolocator geolocator = new Geolocator();

                        //Inschrijven op de StatusChanged voor updates van de permissies voor locaties.
                        geolocator.StatusChanged += OnStatusChanged;
                        geolocator.PositionChanged += OnPositionChanged();

                        //Locatie opvragen
                        Geoposition pos = await geolocator.GetGeopositionAsync();
                        Debug.WriteLine("Positie opgevraagd, lat: " + pos.Coordinate.Point.Position.Latitude + " lon: " + pos.Coordinate.Point.Position.Longitude);

                        //Locatie opslaan als gebruikerslocatie
                        (App.Current as App).UserLocation = pos;

                        break;

                    case GeolocationAccessStatus.Denied: //De gebruiker heeft ons geen toegang gegeven.
                        Debug.WriteLine("Geen locatie: Toestemming geweigerd");

                        //We gaan een Toast tonen om te zeggen dat we de locatie nodig hebben.
                        //Aanmaken tekst voor in Toast
                        string title = "Locatie Nodig";
                        string content = "We krijgen geen toegang tot uw locatie, deze staat softwarematig uitgeschakeld of u geeft ons geen toegang.";

                        //De visuals van de Toast aanmaken
                        ToastVisual visual = new ToastVisual()
                        {
                            TitleText = new ToastText()
                            {
                                Text = title
                            },
                            BodyTextLine1 = new ToastText()
                            {
                                Text = content
                            },
                            AppLogoOverride = new ToastAppLogo()
                            {
                                Source = new ToastImageSource("../Assets/StoreLogo.png"),
                                Crop = ToastImageCrop.Circle
                            }
                        };

                        //De interacties met de toast aanmaken
                        ToastActionsCustom actions = new ToastActionsCustom()
                        {
                            Buttons =
                        {
                            new ToastButton("Geef Toestemming", new QueryString()
                            {
                                {"action", "openLocationServices" }
                            }.ToString())
                        }
                        };

                        //De final toast content aanmaken
                        ToastContent toastContent = new ToastContent()
                        {
                            Visual = visual,
                            Actions = actions,

                            //Argumenten wanneer de user de body van de toast aanklikt
                            Launch = new QueryString()
                        {
                            { "action", "openBobApp"}
                        }.ToString()
                        };

                        //De toast notification maken
                        var toast = new ToastNotification(toastContent.GetXml());
                        toast.ExpirationTime = DateTime.Now.AddDays(2);//Tijd totdat de notification vanzelf verdwijnt

                        //En uiteindelijk de toast tonen
                        ToastNotificationManager.CreateToastNotifier().Show(toast);

                        break;

                    case GeolocationAccessStatus.Unspecified: //Er is iets vreemds misgelopen
                        Debug.WriteLine("Geen locatie: Unspecified");
                        break;

                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error in LoginVM, LocatieToestemmingVragen: " + ex.Message);
            }
        }