This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public partial class BadgeUpdater | |
{ | |
private const string BadgeNodeXPath = "/badge"; | |
private const string ValueAttribute = "value"; | |
internal BadgeUpdater() | |
{ | |
InitPlatform(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static partial class BadgeUpdateManager | |
{ | |
public static BadgeUpdater CreateBadgeUpdaterForApplication() => new BadgeUpdater(); | |
public static XmlDocument GetTemplateContent(BadgeTemplateType type) | |
{ | |
// Although UWP has two "template types", both return the same XML. | |
var xml = new XmlDocument(); | |
xml.LoadXml("<badge value=\"\" />"); | |
return xml; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Windows.UI.Notifications | |
{ | |
public partial class BadgeNotification | |
{ | |
public BadgeNotification(XmlDocument content) | |
{ | |
Content = content ?? throw new ArgumentNullException(nameof(content)); | |
} | |
public XmlDocument Content { get; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var badgeXml = BadgeUpdateManager.GetTemplateContent(BadgeTemplateType.BadgeNumber); | |
XmlElement badgeElement = badgeXml.SelectSingleNode("/badge") as XmlElement; | |
badgeElement.SetAttribute("value", BadgeTextBox.Text); | |
var badgeNotification = new BadgeNotification(badgeXml); | |
BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeNotification); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
await navigator.setAppBadge(42); // Sets the app badge to 42 | |
await navigator.clearAppBadge(); // Clears the app badge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<XamlControlsResources ControlsResourcesVersion="Version2" xmlns="using:Microsoft.UI.Xaml.Controls" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<XamlControlsResources Version="Latest" xmlns="using:Microsoft.UI.Xaml.Controls" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Image CreateCell() | |
{ | |
var cell = new Image(); | |
cell.Tapped += OnCellTapped; | |
return cell; | |
} | |
private void OnCellTapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e) | |
{ | |
var index = _cells.IndexOf((Image)sender); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public MainPage() | |
{ | |
this.InitializeComponent(); | |
_timer.Tick += OnTimerTick; | |
} | |
private void OnTimerTick(object sender, object e) | |
{ | |
_gameState?.Tick(); | |
RedrawBoard(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private readonly DispatcherTimer _timer = new DispatcherTimer() | |
{ | |
Interval = TimeSpan.FromSeconds(1) | |
}; | |
private void AutoPlayToggled() | |
{ | |
if (AutoPlayToggleSwitch.IsOn) | |
{ | |
_timer.Start(); |