Commit df93be14 by Sebastián Katzer

Support for attachments (Windows/AdaptiveImages)

parent ca759b41
...@@ -78,6 +78,11 @@ namespace LocalNotificationProxy.LocalNotification ...@@ -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 xml = toast.GetXml();
var at = this.Options.TriggerDate; var at = this.Options.TriggerDate;
ScheduledToastNotification notification; ScheduledToastNotification notification;
......
...@@ -24,6 +24,8 @@ namespace LocalNotificationProxy.LocalNotification ...@@ -24,6 +24,8 @@ namespace LocalNotificationProxy.LocalNotification
using System; using System;
using Microsoft.Toolkit.Uwp.Notifications; using Microsoft.Toolkit.Uwp.Notifications;
using Windows.Data.Xml.Dom; using Windows.Data.Xml.Dom;
using System.Collections;
using System.Collections.Generic;
public sealed class Options public sealed class Options
{ {
...@@ -74,6 +76,11 @@ namespace LocalNotificationProxy.LocalNotification ...@@ -74,6 +76,11 @@ namespace LocalNotificationProxy.LocalNotification
public string Data { get; set; } public string Data { get; set; }
/// <summary> /// <summary>
/// Gets or sets the notification attachments.
/// </summary>
public string[] Attachments { get; set; }
/// <summary>
/// Gets the date when to trigger the notification. /// Gets the date when to trigger the notification.
/// </summary> /// </summary>
internal DateTime TriggerDate internal DateTime TriggerDate
...@@ -249,6 +256,54 @@ namespace LocalNotificationProxy.LocalNotification ...@@ -249,6 +256,54 @@ namespace LocalNotificationProxy.LocalNotification
} }
/// <summary> /// <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. /// Deserializes the XML string into an instance of Options.
/// </summary> /// </summary>
/// <param name="identifier">The serialized instance of Options as an xml string.</param> /// <param name="identifier">The serialized instance of Options as an xml string.</param>
......
...@@ -35,6 +35,7 @@ exports._defaults = { ...@@ -35,6 +35,7 @@ exports._defaults = {
at: undefined, at: undefined,
actions: undefined, actions: undefined,
actionGroupId: undefined, actionGroupId: undefined,
attachments: []
}; };
// Listener // Listener
...@@ -58,7 +59,6 @@ exports.applyPlatformSpecificOptions = function () { ...@@ -58,7 +59,6 @@ exports.applyPlatformSpecificOptions = function () {
defaults.color = undefined; defaults.color = undefined;
break; break;
case 'iOS': case 'iOS':
defaults.attachments = undefined;
defaults.region = undefined; defaults.region = undefined;
defaults.radius = undefined; defaults.radius = undefined;
defaults.notifyOnEntry = true; 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