Răsfoiți Sursa

- new Notificatiion(title, message). Easy.

BilelAvans 10 ani în urmă
părinte
comite
ea48c0b3d5

+ 1 - 0
Breda-Tour/Breda-Tour.csproj

@@ -124,6 +124,7 @@
     <Compile Include="MainPage.xaml.cs">
       <DependentUpon>MainPage.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Notification.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="RouteSelectScreen\RouteSelectPage.xaml.cs">
       <DependentUpon>RouteSelectPage.xaml</DependentUpon>

+ 47 - 0
Breda-Tour/Notification.cs

@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Windows.Data.Xml.Dom;
+using Windows.UI.Notifications;
+
+namespace Breda_Tour
+{
+    class Notification
+    {
+        public Notification(string title, string message)
+        {
+            sendNote(standardNotification(title, message));
+        }
+
+        public string standardNotification(string title, string message)
+        {
+            return $@"
+            <toast activationType='foreground' launch='args'>
+                <visual>
+                    <binding template='ToastGeneric'>
+                        <text>{ title }</text>
+                        <text>{ message }</text>
+                    </binding>
+                </visual>
+            </toast>";
+
+        }
+
+        public void sendNote(string content)
+        {
+
+            // Notificatie moet in een XML formaat aangeleverd worden
+            XmlDocument doc = new XmlDocument();
+            // Onze XAML code erin zetten
+            doc.LoadXml(content);
+            // Inladen in een toast notificatie (Standaard in Windows 10)
+            ToastNotification notification = new ToastNotification(doc);
+            // Toast Manager aanmaken, oproepen en bewaren
+            ToastNotifier notifier = ToastNotificationManager.CreateToastNotifier();
+            // Notificatie aanleveren aan manager, de manager toont vervolgens de notificatie
+            notifier.Show(notification);
+        }
+    }
+}

+ 1 - 0
Breda-Tour/SplashScreen/SplashPage.xaml.cs

@@ -30,6 +30,7 @@ namespace Breda_Tour.SplashScreen
         public SplashPage()
         {
             this.InitializeComponent();
+            new Notification("Hallo", "Test");
         }
 
         /// <author>Jannick van Ballegooijen</author>