-
Notifications
You must be signed in to change notification settings - Fork 7.9k
/
Copy pathScenario2_Notifications.xaml.cs
87 lines (75 loc) · 3.84 KB
/
Scenario2_Notifications.xaml.cs
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
using NotificationsExtensions;
using NotificationsExtensions.Badges;
using NotificationsExtensions.Tiles;
using Windows.Data.Xml.Dom;
using Windows.UI.Notifications;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace SDKTemplate
{
public sealed partial class Scenario2_Notifications : Page
{
MainPage rootPage = MainPage.Current;
public Scenario2_Notifications()
{
InitializeComponent();
}
private void ClearBadge_Click(object sender, RoutedEventArgs e)
{
BadgeUpdateManager.CreateBadgeUpdaterForApplication().Clear();
rootPage.NotifyUser("Badge notification cleared", NotifyType.StatusMessage);
}
private void SendBadge_Click(object sender, RoutedEventArgs e)
{
BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent(6);
BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(new BadgeNotification(badgeContent.GetXml()));
rootPage.NotifyUser("Badge notification sent", NotifyType.StatusMessage);
}
private void SendBadgeWithStringManipulation_Click(object sender, RoutedEventArgs e)
{
string badgeXmlString = "<badge value='6'/>";
XmlDocument badgeDOM = new XmlDocument();
badgeDOM.LoadXml(badgeXmlString);
BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(new BadgeNotification(badgeDOM));
rootPage.NotifyUser("Badge notification sent", NotifyType.StatusMessage);
}
private void SendTile_Click(object sender, RoutedEventArgs e)
{
var tileDOM = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150SmallImageAndText03);
tileDOM.SelectSingleNode("//image[@id=1]/@src").NodeValue = "'ms-appx:///Assets/tile-sdk.png";
tileDOM.SelectSingleNode("//text[@id=1]").InnerText = "This tile notification has an image, but it won't be displayed on the lock screen";
TileUpdateManager.CreateTileUpdaterForApplication().Update(new TileNotification(tileDOM));
rootPage.NotifyUser("Tile notification sent", NotifyType.StatusMessage);
}
private void SendTileWithStringManipulation_Click(object sender, RoutedEventArgs e)
{
string tileXmlString = "<tile>"
+ "<visual version='2'>"
+ "<binding template='TileWide310x150SmallImageAndText03' fallback='TileWideSmallImageAndText03'>"
+ "<image id='1' src='ms-appx:///Assets/tile-sdk.png'/>"
+ "<text id='1'>This tile notification has an image, but it won't be displayed on the lock screen</text>"
+ "</binding>"
+ "</visual>"
+ "</tile>";
XmlDocument tileDOM = new XmlDocument();
tileDOM.LoadXml(tileXmlString);
TileUpdateManager.CreateTileUpdaterForApplication().Update(new TileNotification(tileDOM));
rootPage.NotifyUser("Tile notification sent", NotifyType.StatusMessage);
}
private void ClearTile_Click(object sender, RoutedEventArgs e)
{
TileUpdateManager.CreateTileUpdaterForApplication().Clear();
rootPage.NotifyUser("Tile notification cleared", NotifyType.StatusMessage);
}
}
}