-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathToastNotificationHelper.cs
More file actions
35 lines (30 loc) · 995 Bytes
/
Copy pathToastNotificationHelper.cs
File metadata and controls
35 lines (30 loc) · 995 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System.IO;
using System.Linq;
using Windows.UI.Notifications;
namespace SSC
{
public static class ToastNotificationHelper
{
public const string APP_DISPLAY_NAME = "Sui's Stream Companion App";
private static readonly ToastNotifier m_Notifier = ToastNotificationManager.CreateToastNotifier(APP_DISPLAY_NAME);
public static void DisplayNotification(string imagePath, string content, ToastTemplateType notificationType)
{
var template = ToastNotificationManager.GetTemplateContent(notificationType);
var image = template.GetElementsByTagName("image")?[0];
if(image != null)
{
var nodes = image.Attributes.FirstOrDefault(x => x.NodeName == "src");
if (nodes != null && File.Exists(imagePath))
{
nodes.NodeValue = imagePath.Replace('\\', '/');
}
}
var textNode = template.GetElementsByTagName("text")?[0];
if (textNode != null)
{
textNode.InnerText = content;
}
m_Notifier.Show(new ToastNotification(template));
}
}
}