Notification.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Windows.Data.Xml.Dom;
  7. using Windows.UI.Notifications;
  8. namespace Breda_Tour
  9. {
  10. class Notification
  11. {
  12. public Notification(string title, string message)
  13. {
  14. sendNote(standardNotification(title, message));
  15. }
  16. public string standardNotification(string title, string message)
  17. {
  18. return $@"
  19. <toast activationType='foreground' launch='args'>
  20. <visual>
  21. <binding template='ToastGeneric'>
  22. <text>{ title }</text>
  23. <text>{ message }</text>
  24. </binding>
  25. </visual>
  26. </toast>";
  27. }
  28. public void sendNote(string content)
  29. {
  30. // Notificatie moet in een XML formaat aangeleverd worden
  31. XmlDocument doc = new XmlDocument();
  32. // Onze XAML code erin zetten
  33. doc.LoadXml(content);
  34. // Inladen in een toast notificatie (Standaard in Windows 10)
  35. ToastNotification notification = new ToastNotification(doc);
  36. // Toast Manager aanmaken, oproepen en bewaren
  37. ToastNotifier notifier = ToastNotificationManager.CreateToastNotifier();
  38. // Notificatie aanleveren aan manager, de manager toont vervolgens de notificatie
  39. notifier.Show(notification);
  40. }
  41. }
  42. }