Skip to content

Instantly share code, notes, and snippets.

View MartinZikmund's full-sized avatar
⌨️
Coding

Martin Zikmund MartinZikmund

⌨️
Coding
View GitHub Profile
public partial class BadgeUpdater
{
private const string BadgeNodeXPath = "/badge";
private const string ValueAttribute = "value";
internal BadgeUpdater()
{
InitPlatform();
}
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;
namespace Windows.UI.Notifications
{
public partial class BadgeNotification
{
public BadgeNotification(XmlDocument content)
{
Content = content ?? throw new ArgumentNullException(nameof(content));
}
public XmlDocument Content { get; }
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);
await navigator.setAppBadge(42); // Sets the app badge to 42
await navigator.clearAppBadge(); // Clears the app badge
<XamlControlsResources ControlsResourcesVersion="Version2" xmlns="using:Microsoft.UI.Xaml.Controls" />
<XamlControlsResources Version="Latest" xmlns="using:Microsoft.UI.Xaml.Controls" />
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);
public MainPage()
{
this.InitializeComponent();
_timer.Tick += OnTimerTick;
}
private void OnTimerTick(object sender, object e)
{
_gameState?.Tick();
RedrawBoard();
private readonly DispatcherTimer _timer = new DispatcherTimer()
{
Interval = TimeSpan.FromSeconds(1)
};
private void AutoPlayToggled()
{
if (AutoPlayToggleSwitch.IsOn)
{
_timer.Start();