Commit df93be14 by Sebastián Katzer

Support for attachments (Windows/AdaptiveImages)

parent ca759b41
......@@ -78,6 +78,11 @@ namespace LocalNotificationProxy.LocalNotification
}
};
foreach (var image in this.Options.ImageAttachments)
{
toast.Visual.BindingGeneric.Children.Add(image);
}
var xml = toast.GetXml();
var at = this.Options.TriggerDate;
ScheduledToastNotification notification;
......
......@@ -24,6 +24,8 @@ namespace LocalNotificationProxy.LocalNotification
using System;
using Microsoft.Toolkit.Uwp.Notifications;
using Windows.Data.Xml.Dom;
using System.Collections;
using System.Collections.Generic;
public sealed class Options
{
......@@ -74,6 +76,11 @@ namespace LocalNotificationProxy.LocalNotification
public string Data { get; set; }
/// <summary>
/// Gets or sets the notification attachments.
/// </summary>
public string[] Attachments { get; set; }
/// <summary>
/// Gets the date when to trigger the notification.
/// </summary>
internal DateTime TriggerDate
......@@ -249,6 +256,54 @@ namespace LocalNotificationProxy.LocalNotification
}
/// <summary>
/// Gets the parsed image attachments.
/// </summary>
internal List<AdaptiveImage> ImageAttachments
{
get
{
var images = new List<AdaptiveImage>();
if (this.Attachments == null)
{
return images;
}
foreach (string path in this.Attachments)
{
var image = new AdaptiveImage();
if (path.StartsWith("file:///") || path.StartsWith("http"))
{
image.Source = path;
}
else
if (path.StartsWith("file://"))
{
image.Source = path.Replace("file:/", "ms-appx:///www");
}
else
if (path.StartsWith("res://"))
{
image.Source = path.Replace("res://", "ms-appx:///images");
}
else
if (path.StartsWith("app://"))
{
image.Source = path.Replace("app:/", "ms-appdata://local");
}
if (image.Source != null)
{
images.Add(image);
}
}
return images;
}
}
/// <summary>
/// Deserializes the XML string into an instance of Options.
/// </summary>
/// <param name="identifier">The serialized instance of Options as an xml string.</param>
......
......@@ -35,6 +35,7 @@ exports._defaults = {
at: undefined,
actions: undefined,
actionGroupId: undefined,
attachments: []
};
// Listener
......@@ -58,7 +59,6 @@ exports.applyPlatformSpecificOptions = function () {
defaults.color = undefined;
break;
case 'iOS':
defaults.attachments = undefined;
defaults.region = undefined;
defaults.radius = undefined;
defaults.notifyOnEntry = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment