Commit ca759b41 by Sebastián Katzer

Add initial code for windows /WIP

parent 9fe3944c
/src/windows.old
/src/windows/**/.vs
/src/windows/**/bin
/src/windows/**/obj
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!--
* Apache 2.0 License
*
* Copyright (c) Sebastian Katzer 2017
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://opensource.org/licenses/Apache-2.0/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
-->
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-plugin-local-notifications"
......@@ -198,24 +219,18 @@
</platform> -->
<!-- windows -->
<!-- <platform name="windows">
<platform name="windows">
<config-file target="config.xml" parent="/*" >
<preference name="WindowsToastCapable" value="true" />
</config-file>
<js-module src="src/windows/LocalNotificationProxy.js" name="LocalNotification.Proxy" >
<merges target="" />
</js-module>
<js-module src="src/windows/LocalNotificationCore.js" name="LocalNotification.Proxy.Core" >
<merges target="" />
</js-module>
<framework src="src/windows/lib.UW/ARM/LocalNotificationProxy.winmd" target-dir="x86" arch="x86" custom="true"/>
<framework src="src/windows/lib.UW/ARM/LocalNotificationProxy.winmd" target-dir="x64" arch="x64" custom="true"/>
<framework src="src/windows/lib.UW/ARM/LocalNotificationProxy.winmd" target-dir="ARM" arch="ARM" custom="true"/>
<js-module src="src/windows/LocalNotificationUtil.js" name="LocalNotification.Proxy.Util" >
<js-module src="src/windows/LocalNotificationProxy.js" name="LocalNotification.Proxy" >
<merges target="" />
</js-module>
</platform> -->
</platform>
</plugin>
/*
* Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
* Apache 2.0 License
*
* @APPPLANT_LICENSE_HEADER_START@
* Copyright (c) Sebastian Katzer 2017
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
......@@ -17,8 +17,6 @@
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
package de.appplant.cordova.plugin.localnotification;
......
/*
* Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
* Apache 2.0 License
*
* @APPPLANT_LICENSE_HEADER_START@
* Copyright (c) Sebastian Katzer 2017
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
......@@ -17,8 +17,6 @@
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
package de.appplant.cordova.plugin.localnotification;
......
/*
* Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
* Apache 2.0 License
*
* @APPPLANT_LICENSE_HEADER_START@
* Copyright (c) Sebastian Katzer 2017
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
......@@ -17,8 +17,6 @@
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
package de.appplant.cordova.plugin.localnotification;
......@@ -224,7 +222,7 @@ public class LocalNotification extends CordovaPlugin {
//silently ignore the exception
//on some samsung devices there is a known bug where a 500 alarms limit can crash the app
//http://developer.samsung.com/forum/board/thread/view.do?boardName=General&messageId=280286&listLines=15&startId=zzzzz%7E&searchSubId=0000000001
}
}
}
......
/*
* Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
* Apache 2.0 License
*
* @APPPLANT_LICENSE_HEADER_START@
* Copyright (c) Sebastian Katzer 2017
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
......@@ -17,8 +17,6 @@
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
package de.appplant.cordova.plugin.localnotification;
......
/*
* Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
* Apache 2.0 License
*
* @APPPLANT_LICENSE_HEADER_START@
* Copyright (c) Sebastian Katzer 2017
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
......@@ -17,8 +17,6 @@
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
package de.appplant.cordova.plugin.notification;
......
/*
* Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
* Apache 2.0 License
*
* @APPPLANT_LICENSE_HEADER_START@
* Copyright (c) Sebastian Katzer 2017
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
......@@ -17,8 +17,6 @@
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
package de.appplant.cordova.plugin.notification;
......
/*
* Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
* Apache 2.0 License
*
* @APPPLANT_LICENSE_HEADER_START@
* Copyright (c) Sebastian Katzer 2017
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
......@@ -17,8 +17,6 @@
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
package de.appplant.cordova.plugin.notification;
......
/*
* Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
* Apache 2.0 License
*
* @APPPLANT_LICENSE_HEADER_START@
* Copyright (c) Sebastian Katzer 2017
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
......@@ -17,8 +17,6 @@
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
package de.appplant.cordova.plugin.notification;
......
/*
* Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
* Apache 2.0 License
*
* @APPPLANT_LICENSE_HEADER_START@
* Copyright (c) Sebastian Katzer 2017
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
......@@ -17,8 +17,6 @@
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
package de.appplant.cordova.plugin.notification;
......
/*
* Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
* Apache 2.0 License
*
* @APPPLANT_LICENSE_HEADER_START@
* Copyright (c) Sebastian Katzer 2017
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
......@@ -17,8 +17,6 @@
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
package de.appplant.cordova.plugin.notification;
......
/*
* Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
* Apache 2.0 License
*
* @APPPLANT_LICENSE_HEADER_START@
* Copyright (c) Sebastian Katzer 2017
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
......@@ -17,8 +17,6 @@
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
package de.appplant.cordova.plugin.notification;
......
/*
* Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
* Apache 2.0 License
*
* @APPPLANT_LICENSE_HEADER_START@
* Copyright (c) Sebastian Katzer 2017
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
......@@ -17,8 +17,6 @@
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
package de.appplant.cordova.plugin.notification;
......
/*
* Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
* Apache 2.0 License
*
* @APPPLANT_LICENSE_HEADER_START@
* Copyright (c) Sebastian Katzer 2017
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
......@@ -17,8 +17,6 @@
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
package de.appplant.cordova.plugin.notification;
......
/*
* Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
* Apache 2.0 License
*
* @APPPLANT_LICENSE_HEADER_START@
* Copyright (c) Sebastian Katzer 2017
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
......@@ -17,8 +17,6 @@
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
package de.appplant.cordova.plugin.notification;
......
/*
* Copyright (c) 2013-2015 by appPlant UG. All rights reserved.
* Apache 2.0 License
*
* @APPPLANT_LICENSE_HEADER_START@
* Copyright (c) Sebastian Katzer 2017
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
......@@ -17,8 +17,6 @@
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPPLANT_LICENSE_HEADER_END@
*/
package de.appplant.cordova.plugin.notification;
......
/*
* Apache 2.0 License
*
* Copyright (c) Sebastian Katzer 2017
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
......
/*
* Apache 2.0 License
*
* Copyright (c) Sebastian Katzer 2017
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
......@@ -612,11 +616,11 @@
if (!deviceready && [event isEqualToString:@"click"]) {
_launchDetails = @[notification.options.id, event];
}
if (![event isEqualToString:@"clear"]) {
[self fireEvent:@"clear" notification:notification];
}
if ([response isKindOfClass:UNTextInputNotificationResponse.class]) {
[data setObject:((UNTextInputNotificationResponse*) response).userText
forKey:@"text"];
......@@ -710,13 +714,13 @@
notiAsJSON = [request encodeToJSON];
[data setObject:request.options.id forKey:@"notification"];
}
dataAsData =
[NSJSONSerialization dataWithJSONObject:data options:0 error:NULL];
dataAsJSON =
[[NSString alloc] initWithData:dataAsData encoding:NSUTF8StringEncoding];
if (request) {
params = [NSString stringWithFormat:@"%@,%@", notiAsJSON, dataAsJSON];
} else {
......
/*
* Apache 2.0 License
*
* Copyright (c) Sebastian Katzer 2017
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
......
/*
* Apache 2.0 License
*
* Copyright (c) Sebastian Katzer 2017
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
......
/*
* Apache 2.0 License
*
* Copyright (c) Sebastian Katzer 2017
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
......
/*
* Apache 2.0 License
*
* Copyright (c) Sebastian Katzer 2017
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
......
/*
* Apache 2.0 License
*
* Copyright (c) Sebastian Katzer 2017
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
......
/*
* Apache 2.0 License
*
* Copyright (c) Sebastian Katzer 2017
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
......
/*
* Apache 2.0 License
*
* Copyright (c) Sebastian Katzer 2017
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
......
/*
* Apache 2.0 License
*
* Copyright (c) Sebastian Katzer 2017
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
......

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26430.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LocalNotificationProxy", "LocalNotificationProxy\LocalNotificationProxy.csproj", "{F5B32CBA-8DAB-43E5-AE4F-98B3B1281FF1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM = Debug|ARM
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM = Release|ARM
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F5B32CBA-8DAB-43E5-AE4F-98B3B1281FF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F5B32CBA-8DAB-43E5-AE4F-98B3B1281FF1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F5B32CBA-8DAB-43E5-AE4F-98B3B1281FF1}.Debug|ARM.ActiveCfg = Debug|ARM
{F5B32CBA-8DAB-43E5-AE4F-98B3B1281FF1}.Debug|ARM.Build.0 = Debug|ARM
{F5B32CBA-8DAB-43E5-AE4F-98B3B1281FF1}.Debug|x64.ActiveCfg = Debug|x64
{F5B32CBA-8DAB-43E5-AE4F-98B3B1281FF1}.Debug|x64.Build.0 = Debug|x64
{F5B32CBA-8DAB-43E5-AE4F-98B3B1281FF1}.Debug|x86.ActiveCfg = Debug|x86
{F5B32CBA-8DAB-43E5-AE4F-98B3B1281FF1}.Debug|x86.Build.0 = Debug|x86
{F5B32CBA-8DAB-43E5-AE4F-98B3B1281FF1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F5B32CBA-8DAB-43E5-AE4F-98B3B1281FF1}.Release|Any CPU.Build.0 = Release|Any CPU
{F5B32CBA-8DAB-43E5-AE4F-98B3B1281FF1}.Release|ARM.ActiveCfg = Release|ARM
{F5B32CBA-8DAB-43E5-AE4F-98B3B1281FF1}.Release|ARM.Build.0 = Release|ARM
{F5B32CBA-8DAB-43E5-AE4F-98B3B1281FF1}.Release|x64.ActiveCfg = Release|x64
{F5B32CBA-8DAB-43E5-AE4F-98B3B1281FF1}.Release|x64.Build.0 = Release|x64
{F5B32CBA-8DAB-43E5-AE4F-98B3B1281FF1}.Release|x86.ActiveCfg = Release|x86
{F5B32CBA-8DAB-43E5-AE4F-98B3B1281FF1}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
/*
* Apache 2.0 License
*
* Copyright (c) Sebastian Katzer 2017
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://opensource.org/licenses/Apache-2.0/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*/
namespace LocalNotificationProxy.LocalNotification
{
using Microsoft.Toolkit.Uwp.Notifications;
using Windows.UI.Notifications;
internal class Builder
{
/// <summary>
/// Notification properties
/// </summary>
private Options options;
/// <summary>
/// Initializes a new instance of the <see cref="Builder"/> class.
/// </summary>
/// <param name="options">Notification properties to set.</param>
internal Builder(Options options)
{
this.options = options;
}
/// <summary>
/// Gets options
/// </summary>
public Options Options { get => this.options; }
/// <summary>
/// Build a toast notification specified by the options.
/// </summary>
/// <returns>A fully configured toast notification instance.</returns>
public ScheduledToastNotification Build()
{
var toast = new ToastContent()
{
Launch = this.Options.Identifier,
Audio = this.Options.ToastAudio,
Visual = new ToastVisual()
{
BindingGeneric = new ToastBindingGeneric()
{
Children =
{
new AdaptiveText()
{
Text = this.Options.Title
},
new AdaptiveText()
{
Text = this.Options.Text
}
},
AppLogoOverride = this.Options.ToastLogo
}
}
};
var xml = toast.GetXml();
var at = this.Options.TriggerDate;
ScheduledToastNotification notification;
if (this.Options.IsRepeating())
{
var interval = this.Options.RepeatInterval;
notification = new ScheduledToastNotification(xml, at, interval, 5);
}
else
{
notification = new ScheduledToastNotification(xml, at);
}
notification.Id = this.Options.ID.ToString();
notification.Tag = notification.Id;
return notification;
}
}
}
/*
* Apache 2.0 License
*
* Copyright (c) Sebastian Katzer 2017
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://opensource.org/licenses/Apache-2.0/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*/
namespace LocalNotificationProxy
{
using System.Runtime.InteropServices.WindowsRuntime;
using LocalNotification;
using Windows.UI.Notifications;
using Windows.UI.WebUI;
public sealed class LocalNotificationProxy
{
/// <summary>
/// Check permission to schedule notifications.
/// </summary>
/// <returns>True if settings are enabled</returns>
public bool HasPermission()
{
NotificationSetting settings = ToastNotificationManager.CreateToastNotifier().Setting;
return settings == NotificationSetting.Enabled;
}
/// <summary>
/// Schedule notifications.
/// </summary>
/// <param name="notifications">List of key-value properties</param>
public void Schedule([ReadOnlyArray] Options[] notifications)
{
foreach (Options options in notifications)
{
ScheduledToastNotification notification = new Builder(options).Build();
ToastNotificationManager.CreateToastNotifier().AddToSchedule(notification);
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F5B32CBA-8DAB-43E5-AE4F-98B3B1281FF1}</ProjectGuid>
<OutputType>winmdobj</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>LocalNotificationProxy</RootNamespace>
<AssemblyName>LocalNotificationProxy</AssemblyName>
<DefaultLanguage>de-DE</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.15063.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.15063.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<AllowCrossPlatformRetargeting>false</AllowCrossPlatformRetargeting>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
<PlatformTarget>ARM</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\ARM\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<Optimize>false</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
<PlatformTarget>ARM</PlatformTarget>
<OutputPath>bin\ARM\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<PlatformTarget>x64</PlatformTarget>
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
</PropertyGroup>
<ItemGroup>
<Compile Include="LocalNotificationProxy.cs" />
<Compile Include="LocalNotification\Builder.cs" />
<Compile Include="LocalNotification\Options.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETCore">
<Version>5.0.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.NETCore.Portable.Compatibility">
<Version>1.0.1</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Microsoft.Toolkit.Uwp.Notifications.UWP\Microsoft.Toolkit.Uwp.Notifications.UWP.csproj">
<Project>{fb381278-f4ad-4703-a12a-c43ee0b231bd}</Project>
<Name>Microsoft.Toolkit.Uwp.Notifications.UWP</Name>
</ProjectReference>
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("LocalNotificationProxy")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LocalNotificationProxy")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: ComVisible(false)]
\ No newline at end of file
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System;
using System.Collections.Generic;
using Microsoft.Toolkit.Uwp.Notifications.Adaptive.Elements;
namespace Microsoft.Toolkit.Uwp.Notifications
{
/// <summary>
/// Groups semantically identify that the content in the group must either be displayed as a whole, or not displayed if it cannot fit. Groups also allow creating multiple columns. Supported on Tiles since RTM. Supported on Toasts since Anniversary Update.
/// </summary>
public sealed class AdaptiveGroup : ITileBindingContentAdaptiveChild, IAdaptiveChild, IToastBindingGenericChild
{
/// <summary>
/// The only valid children of groups are <see cref="AdaptiveSubgroup"/>. Each subgroup is displayed as a separate vertical column. Note that you must include at least one subgroup in your group, otherwise an <see cref="InvalidOperationException"/> will be thrown when you try to retrieve the XML for the notification.
/// </summary>
public IList<AdaptiveSubgroup> Children { get; private set; } = new List<AdaptiveSubgroup>();
internal Element_AdaptiveGroup ConvertToElement()
{
if (Children.Count == 0)
{
throw new InvalidOperationException("Groups must have at least one child subgroup. The Children property had zero items in it.");
}
Element_AdaptiveGroup group = new Element_AdaptiveGroup();
foreach (var subgroup in Children)
{
group.Children.Add(subgroup.ConvertToElement());
}
return group;
}
}
}
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System;
namespace Microsoft.Toolkit.Uwp.Notifications.Adaptive
{
internal static class AdaptiveHelper
{
internal static object ConvertToElement(object obj)
{
if (obj is AdaptiveText)
{
return (obj as AdaptiveText).ConvertToElement();
}
if (obj is AdaptiveImage)
{
return (obj as AdaptiveImage).ConvertToElement();
}
if (obj is AdaptiveGroup)
{
return (obj as AdaptiveGroup).ConvertToElement();
}
if (obj is AdaptiveSubgroup)
{
return (obj as AdaptiveSubgroup).ConvertToElement();
}
if (obj is AdaptiveProgressBar)
{
return (obj as AdaptiveProgressBar).ConvertToElement();
}
throw new NotImplementedException("Unknown object: " + obj.GetType());
}
}
}
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using Microsoft.Toolkit.Uwp.Notifications.Adaptive.Elements;
namespace Microsoft.Toolkit.Uwp.Notifications
{
/// <summary>
/// An inline image.
/// </summary>
public sealed class AdaptiveImage
: IBaseImage,
IToastBindingGenericChild,
ITileBindingContentAdaptiveChild,
IAdaptiveChild,
IAdaptiveSubgroupChild
{
/// <summary>
/// Control the desired cropping of the image. Supported on Tiles since RTM. Supported on Toast since Anniversary Update.
/// </summary>
public AdaptiveImageCrop HintCrop { get; set; }
/// <summary>
/// By default, images have an 8px margin around them. You can remove this margin by setting this property to true. Supported on Tiles since RTM. Supported on Toast since Anniversary Update.
/// </summary>
public bool? HintRemoveMargin { get; set; }
/// <summary>
/// The horizontal alignment of the image. For Toast, this is only supported when inside an <see cref="AdaptiveSubgroup"/>.
/// </summary>
public AdaptiveImageAlign HintAlign { get; set; }
private string _source;
/// <summary>
/// Required. The URI of the image. Can be from your application package, application data, or the internet. Internet images must be less than 200 KB in size.
/// </summary>
public string Source
{
get { return _source; }
set { BaseImageHelper.SetSource(ref _source, value); }
}
/// <summary>
/// A description of the image, for users of assistive technologies.
/// </summary>
public string AlternateText { get; set; }
/// <summary>
/// Set to true to allow Windows to append a query string to the image URI supplied in the Tile notification. Use this attribute if your server hosts images and can handle query strings, either by retrieving an image variant based on the query strings or by ignoring the query string and returning the image as specified without the query string. This query string specifies scale, contrast setting, and language.
/// </summary>
public bool? AddImageQuery { get; set; }
/// <summary>
/// Returns the image's source string.
/// </summary>
/// <returns>The image's source string.</returns>
public override string ToString()
{
if (Source == null)
{
return "Source is null";
}
return Source;
}
internal Element_AdaptiveImage ConvertToElement()
{
Element_AdaptiveImage image = BaseImageHelper.CreateBaseElement(this);
image.Crop = HintCrop;
image.RemoveMargin = HintRemoveMargin;
image.Align = HintAlign;
image.Placement = AdaptiveImagePlacement.Inline;
return image;
}
}
}
\ No newline at end of file
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
namespace Microsoft.Toolkit.Uwp.Notifications
{
/// <summary>
/// Specifies the horizontal alignment for an image.
/// </summary>
public enum AdaptiveImageAlign
{
/// <summary>
/// Default value, alignment behavior determined by renderer.
/// </summary>
Default,
/// <summary>
/// Image stretches to fill available width (and potentially available height too, depending on where the image is).
/// </summary>
[EnumString("stretch")]
Stretch,
/// <summary>
/// Align the image to the left, displaying the image at its native resolution.
/// </summary>
[EnumString("left")]
Left,
/// <summary>
/// Align the image in the center horizontally, displaying the image at its native resolution.
/// </summary>
[EnumString("center")]
Center,
/// <summary>
/// Align the image to the right, displaying the image at its native resolution.
/// </summary>
[EnumString("right")]
Right
}
/// <summary>
/// Specify the desired cropping of the image.
/// </summary>
public enum AdaptiveImageCrop
{
/// <summary>
/// Default value, cropping behavior determined by renderer.
/// </summary>
Default,
/// <summary>
/// Image is not cropped.
/// </summary>
[EnumString("none")]
None,
/// <summary>
/// Image is cropped to a circle shape.
/// </summary>
[EnumString("circle")]
Circle
}
}
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
#if WINRT
using System.Collections.Generic;
#endif
using System;
using Microsoft.Toolkit.Uwp.Notifications.Adaptive.Elements;
namespace Microsoft.Toolkit.Uwp.Notifications
{
/// <summary>
/// New in Creators Update: A progress bar. Only supported on toasts on Desktop, build 15007 or newer.
/// </summary>
public sealed class AdaptiveProgressBar : IToastBindingGenericChild
{
#if WINRT
/// <summary>
/// Gets a dictionary of the current data bindings, where you can assign new bindings.
/// </summary>
public IDictionary<AdaptiveProgressBarBindableProperty, string> Bindings { get; private set; } = new Dictionary<AdaptiveProgressBarBindableProperty, string>();
#endif
/// <summary>
/// Gets or sets an optional title string. Supports data binding.
/// </summary>
public
#if WINRT
string
#else
BindableString
#endif
Title { get; set; }
/// <summary>
/// Gets or sets the value of the progress bar. Supports data binding. Defaults to 0.
/// </summary>
public
#if WINRT
AdaptiveProgressBarValue
#else
BindableProgressBarValue
#endif
Value { get; set; } = AdaptiveProgressBarValue.FromValue(0);
/// <summary>
/// Gets or sets an optional string to be displayed instead of the default percentage string. If this isn't provided, something like "70%" will be displayed.
/// </summary>
public
#if WINRT
string
#else
BindableString
#endif
ValueStringOverride { get; set; }
/// <summary>
/// Required. Gets or sets a status string, which is displayed underneath the progress bar. This string should reflect the status of the operation, like "Downloading..." or "Installing..."
/// </summary>
public
#if WINRT
string
#else
BindableString
#endif
Status { get; set; }
internal Element_AdaptiveProgressBar ConvertToElement()
{
// If Value not provided, we use 0
var val = Value;
if (val == null)
{
val = AdaptiveProgressBarValue.FromValue(0);
}
var answer = new Element_AdaptiveProgressBar();
#if WINRT
answer.Title = XmlWriterHelper.GetBindingOrAbsoluteXmlValue(Bindings, AdaptiveProgressBarBindableProperty.Title, Title);
answer.Value = XmlWriterHelper.GetBindingOrAbsoluteXmlValue(Bindings, AdaptiveProgressBarBindableProperty.Value, val.ToXmlString());
answer.ValueStringOverride = XmlWriterHelper.GetBindingOrAbsoluteXmlValue(Bindings, AdaptiveProgressBarBindableProperty.ValueStringOverride, ValueStringOverride);
answer.Status = XmlWriterHelper.GetBindingOrAbsoluteXmlValue(Bindings, AdaptiveProgressBarBindableProperty.Status, Status);
#else
answer.Title = Title?.ToXmlString();
answer.Value = val.ToXmlString();
answer.ValueStringOverride = ValueStringOverride?.ToXmlString();
answer.Status = Status?.ToXmlString();
#endif
if (answer.Status == null)
{
throw new NullReferenceException("Status property is required.");
}
return answer;
}
}
}
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
namespace Microsoft.Toolkit.Uwp.Notifications
{
// Note that this code is only compiled for WinRT. It is not compiled in any of the other projects.
#if WINRT
/// <summary>
/// An enumeration of the properties that support data binding on <see cref="AdaptiveProgressBar"/> .
/// </summary>
public enum AdaptiveProgressBarBindableProperty
{
/// <summary>
/// An optional title string
/// </summary>
Title,
/// <summary>
/// The value of the progress bar.
/// </summary>
Value,
/// <summary>
/// An optional string to be displayed instead of the default percentage string. If this isn't provided, something like "70%" will be displayed.
/// </summary>
ValueStringOverride,
/// <summary>
/// An optional status string, which is displayed underneath the progress bar. If provided, this string should reflect the status of the download, like "Downloading..." or "Installing...".
/// </summary>
Status
}
#endif
}
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System;
namespace Microsoft.Toolkit.Uwp.Notifications
{
/// <summary>
/// A class that represents the progress bar's value.
/// </summary>
public sealed class AdaptiveProgressBarValue
{
/// <summary>
/// Gets or sets the value (0-1) representing the percent complete.
/// </summary>
public double Value { get; set; }
/// <summary>
/// Gets or sets whether the progress bar is indeterminate.
/// </summary>
public bool IsIndeterminate { get; set; }
/// <summary>
/// Private constructor
/// </summary>
private AdaptiveProgressBarValue()
{
}
internal string ToXmlString()
{
if (IsIndeterminate)
{
return "indeterminate";
}
return Value.ToString();
}
/// <summary>
/// Returns an indeterminate progress bar value.
/// </summary>
public static AdaptiveProgressBarValue Indeterminate
{
get
{
return new AdaptiveProgressBarValue()
{
IsIndeterminate = true
};
}
}
/// <summary>
/// Returns a progress bar value using the specified value (0-1) representing the percent complete.
/// </summary>
/// <param name="d">The value, 0-1, inclusive.</param>
/// <returns>A progress bar value.</returns>
public static AdaptiveProgressBarValue FromValue(double d)
{
if (d < 0 || d > 1)
{
throw new ArgumentOutOfRangeException("d", "Value must be between 0 and 1, inclusive.");
}
return new AdaptiveProgressBarValue()
{
Value = d
};
}
}
}
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System;
using System.Collections.Generic;
using Microsoft.Toolkit.Uwp.Notifications.Adaptive.Elements;
namespace Microsoft.Toolkit.Uwp.Notifications
{
/// <summary>
/// Subgroups are vertical columns that can contain text and images. Supported on Tiles since RTM. Supported on Toasts since Anniversary Update.
/// </summary>
public sealed class AdaptiveSubgroup
{
/// <summary>
/// <see cref="AdaptiveText"/> and <see cref="AdaptiveImage"/> are valid children of subgroups.
/// </summary>
public IList<IAdaptiveSubgroupChild> Children { get; private set; } = new List<IAdaptiveSubgroupChild>();
private int? _hintWeight;
/// <summary>
/// Control the width of this subgroup column by specifying the weight, relative to the other subgroups.
/// </summary>
public int? HintWeight
{
get
{
return _hintWeight;
}
set
{
Element_AdaptiveSubgroup.CheckWeight(value);
_hintWeight = value;
}
}
/// <summary>
/// Control the vertical alignment of this subgroup's content.
/// </summary>
public AdaptiveSubgroupTextStacking HintTextStacking { get; set; } = Element_AdaptiveSubgroup.DEFAULT_TEXT_STACKING;
internal Element_AdaptiveSubgroup ConvertToElement()
{
var subgroup = new Element_AdaptiveSubgroup()
{
Weight = HintWeight,
TextStacking = HintTextStacking
};
foreach (var child in Children)
{
subgroup.Children.Add(ConvertToSubgroupChildElement(child));
}
return subgroup;
}
private static IElement_AdaptiveSubgroupChild ConvertToSubgroupChildElement(IAdaptiveSubgroupChild child)
{
if (child is AdaptiveText)
{
return (child as AdaptiveText).ConvertToElement();
}
if (child is AdaptiveImage)
{
return (child as AdaptiveImage).ConvertToElement();
}
throw new NotImplementedException("Unknown child: " + child.GetType());
}
}
}
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
namespace Microsoft.Toolkit.Uwp.Notifications
{
/// <summary>
/// TextStacking specifies the vertical alignment of content.
/// </summary>
public enum AdaptiveSubgroupTextStacking
{
/// <summary>
/// Renderer automatically selects the default vertical alignment.
/// </summary>
Default,
/// <summary>
/// Vertical align to the top.
/// </summary>
[EnumString("top")]
Top,
/// <summary>
/// Vertical align to the center.
/// </summary>
[EnumString("center")]
Center,
/// <summary>
/// Vertical align to the bottom.
/// </summary>
[EnumString("bottom")]
Bottom
}
}
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
#if WINRT
using System.Collections.Generic;
#endif
using Microsoft.Toolkit.Uwp.Notifications.Adaptive.Elements;
namespace Microsoft.Toolkit.Uwp.Notifications
{
/// <summary>
/// An adaptive text element.
/// </summary>
public sealed class AdaptiveText
: IAdaptiveChild,
IAdaptiveSubgroupChild,
ITileBindingContentAdaptiveChild,
IToastBindingGenericChild
{
#if WINRT
/// <summary>
/// Gets a dictionary of the current data bindings, where you can assign new bindings.
/// </summary>
public IDictionary<AdaptiveTextBindableProperty, string> Bindings { get; private set; } = new Dictionary<AdaptiveTextBindableProperty, string>();
#endif
/// <summary>
/// The text to display. Data binding support added in Creators Update, only works for toast top-level text elements.
/// </summary>
public
#if WINRT
string
#else
BindableString
#endif
Text { get; set; }
/// <summary>
/// The target locale of the XML payload, specified as a BCP-47 language tags such as "en-US" or "fr-FR". The locale specified here overrides any other specified locale, such as that in binding or visual. If this value is a literal string, this attribute defaults to the user's UI language. If this value is a string reference, this attribute defaults to the locale chosen by Windows Runtime in resolving the string.
/// </summary>
public string Language { get; set; }
/// <summary>
/// The style controls the text's font size, weight, and opacity. Note that for Toast, the style will only take effect if the text is inside an <see cref="AdaptiveSubgroup"/>.
/// </summary>
public AdaptiveTextStyle HintStyle { get; set; }
/// <summary>
/// Set this to true to enable text wrapping. For Tiles, this is false by default. For Toasts, this is true on top-level text elements, and false inside an <see cref="AdaptiveSubgroup"/>. Note that for Toast, setting wrap will only take effect if the text is inside an <see cref="AdaptiveSubgroup"/> (you can use HintMaxLines = 1 to prevent top-level text elements from wrapping).
/// </summary>
public bool? HintWrap { get; set; }
private int? _hintMaxLines;
/// <summary>
/// The maximum number of lines the text element is allowed to display. For Tiles, this is infinity by default. For Toasts, top-level text elements will have varying max line amounts (and in the Anniversary Update you can change the max lines). Text on a Toast inside an <see cref="AdaptiveSubgroup"/> will behave identically to Tiles (default to infinity).
/// </summary>
public int? HintMaxLines
{
get
{
return _hintMaxLines;
}
set
{
if (value != null)
{
Element_AdaptiveText.CheckMaxLinesValue(value.Value);
}
_hintMaxLines = value;
}
}
private int? _hintMinLines;
/// <summary>
/// The minimum number of lines the text element must display. Note that for Toast, this property will only take effect if the text is inside an <see cref="AdaptiveSubgroup"/>.
/// </summary>
public int? HintMinLines
{
get
{
return _hintMinLines;
}
set
{
if (value != null)
{
Element_AdaptiveText.CheckMinLinesValue(value.Value);
}
_hintMinLines = value;
}
}
/// <summary>
/// The horizontal alignment of the text. Note that for Toast, this property will only take effect if the text is inside an <see cref="AdaptiveSubgroup"/>.
/// </summary>
public AdaptiveTextAlign HintAlign { get; set; }
internal Element_AdaptiveText ConvertToElement()
{
var answer = new Element_AdaptiveText()
{
Lang = Language,
Style = HintStyle,
Wrap = HintWrap,
MaxLines = HintMaxLines,
MinLines = HintMinLines,
Align = HintAlign
};
#if WINRT
answer.Text = XmlWriterHelper.GetBindingOrAbsoluteXmlValue(Bindings, AdaptiveTextBindableProperty.Text, Text);
#else
answer.Text = Text?.ToXmlString();
#endif
return answer;
}
/// <summary>
/// Returns the value of the Text property.
/// </summary>
/// <returns>The value of the Text property.</returns>
public override string ToString()
{
return Text;
}
}
}
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
namespace Microsoft.Toolkit.Uwp.Notifications
{
// Note that this code is only compiled for WinRT. It is not compiled in any of the other projects.
#if WINRT
/// <summary>
/// An enumeration of the properties that support data binding on <see cref="AdaptiveText"/> .
/// </summary>
public enum AdaptiveTextBindableProperty
{
/// <summary>
/// The text to display. Added in Creators Update only for toast top-level elements.
/// </summary>
Text
}
#endif
}
\ No newline at end of file
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
namespace Microsoft.Toolkit.Uwp.Notifications
{
/// <summary>
/// Text style controls font size, weight, and opacity.
/// </summary>
public enum AdaptiveTextStyle
{
/// <summary>
/// Style is determined by the renderer.
/// </summary>
Default,
/// <summary>
/// Default value. Paragraph font size, normal weight and opacity.
/// </summary>
[EnumString("caption")]
Caption,
/// <summary>
/// Same as Caption but with subtle opacity.
/// </summary>
[EnumString("captionSubtle")]
CaptionSubtle,
/// <summary>
/// H5 font size.
/// </summary>
[EnumString("body")]
Body,
/// <summary>
/// Same as Body but with subtle opacity.
/// </summary>
[EnumString("bodySubtle")]
BodySubtle,
/// <summary>
/// H5 font size, bold weight. Essentially the bold version of Body.
/// </summary>
[EnumString("base")]
Base,
/// <summary>
/// Same as Base but with subtle opacity.
/// </summary>
[EnumString("baseSubtle")]
BaseSubtle,
/// <summary>
/// H4 font size.
/// </summary>
[EnumString("subtitle")]
Subtitle,
/// <summary>
/// Same as Subtitle but with subtle opacity.
/// </summary>
[EnumString("subtitleSubtle")]
SubtitleSubtle,
/// <summary>
/// H3 font size.
/// </summary>
[EnumString("title")]
Title,
/// <summary>
/// Same as Title but with subtle opacity.
/// </summary>
[EnumString("titleSubtle")]
TitleSubtle,
/// <summary>
/// Same as Title but with top/bottom padding removed.
/// </summary>
[EnumString("titleNumeral")]
TitleNumeral,
/// <summary>
/// H2 font size.
/// </summary>
[EnumString("subheader")]
Subheader,
/// <summary>
/// Same as Subheader but with subtle opacity.
/// </summary>
[EnumString("subheaderSubtle")]
SubheaderSubtle,
/// <summary>
/// Same as Subheader but with top/bottom padding removed.
/// </summary>
[EnumString("subheaderNumeral")]
SubheaderNumeral,
/// <summary>
/// H1 font size.
/// </summary>
[EnumString("header")]
Header,
/// <summary>
/// Same as Header but with subtle opacity.
/// </summary>
[EnumString("headerSubtle")]
HeaderSubtle,
/// <summary>
/// Same as Header but with top/bottom padding removed.
/// </summary>
[EnumString("headerNumeral")]
HeaderNumeral
}
/// <summary>
/// Controls the horizontal alignment of text.
/// </summary>
public enum AdaptiveTextAlign
{
/// <summary>
/// Alignment is automatically determined by
/// </summary>
Default,
/// <summary>
/// The system automatically decides the alignment based on the language and culture.
/// </summary>
[EnumString("auto")]
Auto,
/// <summary>
/// Horizontally align the text to the left.
/// </summary>
[EnumString("left")]
Left,
/// <summary>
/// Horizontally align the text in the center.
/// </summary>
[EnumString("center")]
Center,
/// <summary>
/// Horizontally align the text to the right.
/// </summary>
[EnumString("right")]
Right
}
internal enum AdaptiveTextPlacement
{
/// <summary>
/// Default value
/// </summary>
Inline,
[EnumString("attribution")]
Attribution
}
}
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System;
using Microsoft.Toolkit.Uwp.Notifications.Adaptive.Elements;
namespace Microsoft.Toolkit.Uwp.Notifications
{
internal static class BaseImageHelper
{
internal static void SetSource(ref string destination, string value)
{
if (value == null)
{
throw new ArgumentNullException(nameof(value));
}
destination = value;
}
internal static Element_AdaptiveImage CreateBaseElement(IBaseImage curr)
{
if (curr.Source == null)
{
throw new NullReferenceException("Source property is required.");
}
return new Element_AdaptiveImage()
{
Src = curr.Source,
Alt = curr.AlternateText,
AddImageQuery = curr.AddImageQuery
};
}
}
}
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using Microsoft.Toolkit.Uwp.Notifications.Adaptive.Elements;
namespace Microsoft.Toolkit.Uwp.Notifications
{
internal class BaseTextHelper
{
internal static Element_AdaptiveText CreateBaseElement(IBaseText curr)
{
return new Element_AdaptiveText()
{
Text = curr.Text,
Lang = curr.Language
};
}
}
}
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
namespace Microsoft.Toolkit.Uwp.Notifications
{
// Note that this code is NOT compiled for WinRT.
// WinRT uses a different binding system since it doesn't support implicit type converters.
#if !WINRT
/// <summary>
/// A binding value for doubles.
/// </summary>
public sealed class BindableProgressBarValue
{
/// <summary>
/// Raw value is used for the implicit converter case, where dev provided a raw double. We store the raw value,
/// so that later on when generating the XML, we can provide this value rather than binding syntax.
/// </summary>
internal AdaptiveProgressBarValue RawValue { get; private set; }
internal bool RawIsIndeterminate { get; private set; }
/// <summary>
/// The name that maps to your binding data value.
/// </summary>
public string BindingName { get; set; }
/// <summary>
/// Initializes a new binding for a double value, with the required binding value name. Do NOT include surrounding {} brackets.
/// </summary>
/// <param name="bindingName">The name that maps to your binding data value.</param>
public BindableProgressBarValue(string bindingName)
{
BindingName = bindingName;
}
/// <summary>
/// Private constructor used by the implicit converter to assign the raw value.
/// </summary>
private BindableProgressBarValue()
{
}
internal string ToXmlString()
{
if (BindingName != null)
{
return "{" + BindingName + "}";
}
if (RawValue != null)
{
return RawValue.ToXmlString();
}
return null;
}
/// <summary>
/// Creates a <see cref="BindableProgressBarValue"/> that has a raw value assigned.
/// </summary>
/// <param name="v">The raw value</param>
public static implicit operator BindableProgressBarValue(AdaptiveProgressBarValue v)
{
return new BindableProgressBarValue()
{
RawValue = v
};
}
/// <summary>
/// Returns the raw value of the <see cref="BindableProgressBarValue"/>.
/// </summary>
/// <param name="b">The <see cref="BindableProgressBarValue"/> to obtain the raw value from.</param>
public static implicit operator AdaptiveProgressBarValue(BindableProgressBarValue b)
{
return b.RawValue;
}
/// <summary>
/// Creates an <see cref="BindableProgressBarValue"/> that has tbe raw double value.
/// </summary>
/// <param name="d">The raw value</param>
public static implicit operator BindableProgressBarValue(double d)
{
return AdaptiveProgressBarValue.FromValue(d);
}
}
#endif
}
\ No newline at end of file
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
namespace Microsoft.Toolkit.Uwp.Notifications
{
// Note that this code is NOT compiled for WinRT.
// WinRT uses a different binding system since it doesn't support implicit type converters.
#if !WINRT
/// <summary>
/// A binding value for strings.
/// </summary>
public sealed class BindableString
{
internal string RawValue { get; private set; }
/// <summary>
/// The name that maps to your binding data value.
/// </summary>
public string BindingName { get; set; }
/// <summary>
/// Initializes a new binding for a string value, with the required binding name. Do NOT include surrounding {} brackets.
/// </summary>
/// <param name="bindingName">The name that maps to your data binding value.</param>
public BindableString(string bindingName)
{
BindingName = bindingName;
}
/// <summary>
/// Private constructor used by the implicit converter to assign the raw value.
/// </summary>
private BindableString()
{
}
internal string ToXmlString()
{
if (BindingName != null)
{
return "{" + BindingName + "}";
}
return RawValue;
}
/// <summary>
/// Creates a <see cref="BindableString"/> that has a raw value assigned.
/// </summary>
/// <param name="d">The raw value</param>
public static implicit operator BindableString(string d)
{
return new BindableString()
{
RawValue = d
};
}
/// <summary>
/// Returns the raw value of the <see cref="BindableString"/>.
/// </summary>
/// <param name="b">The <see cref="BindableString"/> to obtain the raw value from.</param>
public static implicit operator string(BindableString b)
{
return b.RawValue;
}
}
#endif
}
\ No newline at end of file
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System.Collections.Generic;
namespace Microsoft.Toolkit.Uwp.Notifications.Adaptive.Elements
{
[NotificationXmlElement("group")]
internal sealed class Element_AdaptiveGroup : IElement_TileBindingChild, IElement_ToastBindingChild, IElementWithDescendants
{
public IList<Element_AdaptiveSubgroup> Children { get; private set; } = new List<Element_AdaptiveSubgroup>();
public IEnumerable<object> Descendants()
{
foreach (Element_AdaptiveSubgroup subgroup in Children)
{
// Return the subgroup
yield return subgroup;
// And also return its descendants
foreach (object descendant in subgroup.Descendants())
{
yield return descendant;
}
}
}
}
}
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
namespace Microsoft.Toolkit.Uwp.Notifications.Adaptive.Elements
{
[NotificationXmlElement("image")]
internal sealed class Element_AdaptiveImage : IElement_TileBindingChild, IElement_ToastBindingChild, IElement_AdaptiveSubgroupChild
{
internal const AdaptiveImagePlacement DEFAULT_PLACEMENT = AdaptiveImagePlacement.Inline;
internal const AdaptiveImageCrop DEFAULT_CROP = AdaptiveImageCrop.Default;
internal const AdaptiveImageAlign DEFAULT_ALIGN = AdaptiveImageAlign.Default;
[NotificationXmlAttribute("id")]
public int? Id { get; set; }
[NotificationXmlAttribute("src")]
public string Src { get; set; }
[NotificationXmlAttribute("alt")]
public string Alt { get; set; }
[NotificationXmlAttribute("addImageQuery")]
public bool? AddImageQuery { get; set; }
[NotificationXmlAttribute("placement", DEFAULT_PLACEMENT)]
public AdaptiveImagePlacement Placement { get; set; } = DEFAULT_PLACEMENT;
[NotificationXmlAttribute("hint-align", DEFAULT_ALIGN)]
public AdaptiveImageAlign Align { get; set; } = DEFAULT_ALIGN;
[NotificationXmlAttribute("hint-crop", DEFAULT_CROP)]
public AdaptiveImageCrop Crop { get; set; } = DEFAULT_CROP;
[NotificationXmlAttribute("hint-removeMargin")]
public bool? RemoveMargin { get; set; }
private int? _overlay;
[NotificationXmlAttribute("hint-overlay")]
public int? Overlay
{
get
{
return _overlay;
}
set
{
if (value != null)
{
Element_TileBinding.CheckOverlayValue(value.Value);
}
_overlay = value;
}
}
}
}
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
namespace Microsoft.Toolkit.Uwp.Notifications.Adaptive.Elements
{
internal enum AdaptiveImagePlacement
{
[EnumString("inline")]
Inline,
[EnumString("background")]
Background,
[EnumString("peek")]
Peek,
[EnumString("hero")]
Hero,
[EnumString("appLogoOverride")]
AppLogoOverride
}
}
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
namespace Microsoft.Toolkit.Uwp.Notifications.Adaptive.Elements
{
[NotificationXmlElement("progress")]
internal sealed class Element_AdaptiveProgressBar : IElement_ToastBindingChild
{
[NotificationXmlAttribute("value")]
public string Value { get; set; }
[NotificationXmlAttribute("title")]
public string Title { get; set; }
[NotificationXmlAttribute("valueStringOverride")]
public string ValueStringOverride { get; set; }
[NotificationXmlAttribute("status")]
public string Status { get; set; }
}
}
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System;
using System.Collections.Generic;
namespace Microsoft.Toolkit.Uwp.Notifications.Adaptive.Elements
{
[NotificationXmlElement("subgroup")]
internal sealed class Element_AdaptiveSubgroup : IElementWithDescendants
{
internal const AdaptiveSubgroupTextStacking DEFAULT_TEXT_STACKING = AdaptiveSubgroupTextStacking.Default;
[NotificationXmlAttribute("hint-textStacking", DEFAULT_TEXT_STACKING)]
public AdaptiveSubgroupTextStacking TextStacking { get; set; } = DEFAULT_TEXT_STACKING;
private int? _weight;
[NotificationXmlAttribute("hint-weight")]
public int? Weight
{
get
{
return _weight;
}
set
{
CheckWeight(value);
_weight = value;
}
}
internal static void CheckWeight(int? weight)
{
if (weight != null && weight.Value < 1)
{
throw new ArgumentOutOfRangeException("Weight must be between 1 and int.MaxValue, inclusive (or null)");
}
}
public IList<IElement_AdaptiveSubgroupChild> Children { get; private set; } = new List<IElement_AdaptiveSubgroupChild>();
public IEnumerable<object> Descendants()
{
foreach (IElement_AdaptiveSubgroupChild child in Children)
{
// Return each child (we know there's no further descendants)
yield return child;
}
}
}
internal interface IElement_AdaptiveSubgroupChild
{
}
}
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System;
namespace Microsoft.Toolkit.Uwp.Notifications.Adaptive.Elements
{
[NotificationXmlElement("text")]
internal sealed class Element_AdaptiveText : IElement_TileBindingChild, IElement_AdaptiveSubgroupChild, IElement_ToastBindingChild
{
internal const AdaptiveTextStyle DEFAULT_STYLE = AdaptiveTextStyle.Default;
internal const AdaptiveTextAlign DEFAULT_ALIGN = AdaptiveTextAlign.Default;
internal const AdaptiveTextPlacement DEFAULT_PLACEMENT = AdaptiveTextPlacement.Inline;
[NotificationXmlContent]
public string Text { get; set; }
[NotificationXmlAttribute("id")]
public int? Id { get; set; }
[NotificationXmlAttribute("lang")]
public string Lang { get; set; }
[NotificationXmlAttribute("hint-align", DEFAULT_ALIGN)]
public AdaptiveTextAlign Align { get; set; } = DEFAULT_ALIGN;
private int? _maxLines;
[NotificationXmlAttribute("hint-maxLines")]
public int? MaxLines
{
get
{
return _maxLines;
}
set
{
if (value != null)
{
CheckMaxLinesValue(value.Value);
}
_maxLines = value;
}
}
internal static void CheckMaxLinesValue(int value)
{
if (value < 1)
{
throw new ArgumentOutOfRangeException("MaxLines must be between 1 and int.MaxValue, inclusive.");
}
}
private int? _minLines;
[NotificationXmlAttribute("hint-minLines")]
public int? MinLines
{
get
{
return _minLines;
}
set
{
if (value != null)
{
CheckMinLinesValue(value.Value);
}
_minLines = value;
}
}
internal static void CheckMinLinesValue(int value)
{
if (value < 1)
{
throw new ArgumentOutOfRangeException("MinLines must be between 1 and int.MaxValue, inclusive.");
}
}
[NotificationXmlAttribute("hint-style", DEFAULT_STYLE)]
public AdaptiveTextStyle Style { get; set; } = DEFAULT_STYLE;
[NotificationXmlAttribute("hint-wrap")]
public bool? Wrap { get; set; }
[NotificationXmlAttribute("placement", DEFAULT_PLACEMENT)]
public AdaptiveTextPlacement Placement { get; set; } = DEFAULT_PLACEMENT;
}
}
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
namespace Microsoft.Toolkit.Uwp.Notifications
{
/// <summary>
/// Elements that can be direct children of adaptive content, including (<see cref="AdaptiveText"/>, <see cref="AdaptiveImage"/>, and <see cref="AdaptiveGroup"/>).
/// </summary>
public interface IAdaptiveChild
{
// Blank interface simply for compile-enforcing the child types in the list.
}
}
\ No newline at end of file
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
namespace Microsoft.Toolkit.Uwp.Notifications
{
/// <summary>
/// Elements that can be direct children of an <see cref="AdaptiveSubgroup"/>, including (<see cref="AdaptiveText"/> and <see cref="AdaptiveImage"/>).
/// </summary>
public interface IAdaptiveSubgroupChild
{
// Blank interface simply for compile-enforcing the child types in the list.
}
}
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
namespace Microsoft.Toolkit.Uwp.Notifications
{
/// <summary>
/// Contains the base properties that an image needs.
/// </summary>
public interface IBaseImage
{
/// <summary>
/// The URI of the image. Can be from your application package, application data, or the internet. Internet images must be less than 200 KB in size.
/// </summary>
string Source { get; set; }
/// <summary>
/// A description of the image, for users of assistive technologies.
/// </summary>
string AlternateText { get; set; }
/// <summary>
/// Set to true to allow Windows to append a query string to the image URI supplied in the Tile notification. Use this attribute if your server hosts images and can handle query strings, either by retrieving an image variant based on the query strings or by ignoring the query string and returning the image as specified without the query string. This query string specifies scale, contrast setting, and language.
/// </summary>
bool? AddImageQuery { get; set; }
}
}
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
namespace Microsoft.Toolkit.Uwp.Notifications
{
/// <summary>
/// Defines the basic properties of a text element.
/// </summary>
public interface IBaseText
{
/// <summary>
/// The text to display.
/// </summary>
string Text { get; set; }
/// <summary>
/// The target locale of the XML payload, specified as a BCP-47 language tags such as "en-US" or "fr-FR". The locale specified here overrides any other specified locale, such as that in binding or visual. If this value is a literal string, this attribute defaults to the user's UI language. If this value is a string reference, this attribute defaults to the locale chosen by Windows Runtime in resolving the string.
/// </summary>
string Language { get; set; }
}
}
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System;
#if WINDOWS_UWP
using Windows.Data.Xml.Dom;
#endif
namespace Microsoft.Toolkit.Uwp.Notifications
{
/// <summary>
/// Notification content object to display a glyph on a Tile's badge.
/// </summary>
public sealed class BadgeGlyphContent : INotificationContent
{
/// <summary>
/// Default constructor to create a glyph badge content object.
/// </summary>
public BadgeGlyphContent()
{
}
/// <summary>
/// Constructor to create a glyph badge content object with a glyph.
/// </summary>
/// <param name="glyph">The glyph to be displayed on the badge.</param>
public BadgeGlyphContent(BadgeGlyphValue glyph)
{
_glyph = glyph;
}
/// <summary>
/// The glyph to be displayed on the badge.
/// </summary>
public BadgeGlyphValue Glyph
{
get
{
return _glyph;
}
set
{
if (!Enum.IsDefined(typeof(BadgeGlyphValue), value))
{
throw new ArgumentOutOfRangeException(nameof(value));
}
_glyph = value;
}
}
/// <summary>
/// Retrieves the notification Xml content as a string.
/// </summary>
/// <returns>The notification Xml content as a string.</returns>
public string GetContent()
{
if (!Enum.IsDefined(typeof(BadgeGlyphValue), _glyph))
{
throw new NotificationContentValidationException("The badge glyph property was left unset.");
}
string glyphString = _glyph.ToString();
// lower case the first character of the enum value to match the Xml schema
glyphString = string.Format("{0}{1}", char.ToLowerInvariant(glyphString[0]), glyphString.Substring(1));
return string.Format("<badge value='{0}'/>", glyphString);
}
/// <summary>
/// Retrieves the notification XML content as a string.
/// </summary>
/// <returns>The notification XML content as a string.</returns>
public override string ToString()
{
return GetContent();
}
#if WINDOWS_UWP
/// <summary>
/// Retrieves the notification XML content as a WinRT Xml document.
/// </summary>
/// <returns>The notification XML content as a WinRT Xml document.</returns>
public XmlDocument GetXml()
{
XmlDocument xml = new XmlDocument();
xml.LoadXml(GetContent());
return xml;
}
#endif
private BadgeGlyphValue _glyph = (BadgeGlyphValue)(-1);
}
}
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
namespace Microsoft.Toolkit.Uwp.Notifications
{
/// <summary>
/// The types of glyphs that can be placed on a badge.
/// </summary>
public enum BadgeGlyphValue
{
/// <summary>
/// No glyph. If there is a numeric badge, or a glyph currently on the badge,
/// it will be removed.
/// </summary>
None = 0,
/// <summary>
/// A glyph representing application activity.
/// </summary>
Activity,
/// <summary>
/// A glyph representing an alert.
/// </summary>
Alert,
/// <summary>
/// A glyph representing an alarm.
/// </summary>
Alarm,
/// <summary>
/// A glyph representing availability status.
/// </summary>
Available,
/// <summary>
/// A glyph representing away status
/// </summary>
Away,
/// <summary>
/// A glyph representing busy status.
/// </summary>
Busy,
/// <summary>
/// A glyph representing that a new message is available.
/// </summary>
NewMessage,
/// <summary>
/// A glyph representing that media is paused.
/// </summary>
Paused,
/// <summary>
/// A glyph representing that media is playing.
/// </summary>
Playing,
/// <summary>
/// A glyph representing unavailable status.
/// </summary>
Unavailable,
/// <summary>
/// A glyph representing an error.
/// </summary>
Error,
/// <summary>
/// A glyph representing attention status.
/// </summary>
Attention
}
}
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
#if WINDOWS_UWP
using Windows.Data.Xml.Dom;
#endif
namespace Microsoft.Toolkit.Uwp.Notifications
{
/// <summary>
/// Notification content object to display a number on a Tile's badge.
/// </summary>
public sealed class BadgeNumericContent : INotificationContent
{
/// <summary>
/// Default constructor to create a numeric badge content object.
/// </summary>
public BadgeNumericContent()
{
}
/// <summary>
/// Constructor to create a numeric badge content object with a number.
/// </summary>
/// <param name="number">
/// The number that will appear on the badge. If the number is 0, the badge
/// will be removed.
/// </param>
public BadgeNumericContent(uint number)
{
_number = number;
}
/// <summary>
/// The number that will appear on the badge. If the number is 0, the badge
/// will be removed.
/// </summary>
public uint Number
{
get { return _number; }
set { _number = value; }
}
/// <summary>
/// Retrieves the notification Xml content as a string.
/// </summary>
/// <returns>The notification Xml content as a string.</returns>
public string GetContent()
{
return string.Format("<badge value='{0}'/>", _number);
}
/// <summary>
/// Retrieves the notification Xml content as a string.
/// </summary>
/// <returns>The notification Xml content as a string.</returns>
public override string ToString()
{
return GetContent();
}
#if WINDOWS_UWP
/// <summary>
/// Retrieves the notification Xml content as a WinRT Xml document.
/// </summary>
/// <returns>The notification Xml content as a WinRT Xml document.</returns>
public XmlDocument GetXml()
{
XmlDocument xml = new XmlDocument();
xml.LoadXml(GetContent());
return xml;
}
#endif
private uint _number = 0;
}
}
\ No newline at end of file
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System;
namespace Microsoft.Toolkit.Uwp.Notifications
{
internal static class ArgumentValidator
{
public static void SetProperty<T>(ref T property, T value, string propertyName, ArgumentValidatorOptions options)
{
if (options.HasFlag(ArgumentValidatorOptions.NotNull))
{
if (value == null)
{
throw new ArgumentNullException(propertyName);
}
}
property = value;
}
}
[Flags]
internal enum ArgumentValidatorOptions
{
NotNull
}
}
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System.IO;
using System.Text;
#if WINDOWS_UWP
using Windows.Data.Xml.Dom;
#endif
namespace Microsoft.Toolkit.Uwp.Notifications
{
internal abstract class BaseElement
{
/// <summary>
/// Retrieves the notification XML content as a string.
/// </summary>
/// <returns>The notification XML content as a string.</returns>
public string GetContent()
{
using (MemoryStream stream = new MemoryStream())
{
using (System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(stream, new System.Xml.XmlWriterSettings()
{
Encoding = Encoding.UTF8, // Use UTF-8 encoding to save space (it defaults to UTF-16 which is 2x the size)
Indent = false,
NewLineOnAttributes = false
}))
{
XmlWriterHelper.Write(writer, this);
}
stream.Position = 0;
using (StreamReader reader = new StreamReader(stream))
{
return reader.ReadToEnd();
}
}
}
#if WINDOWS_UWP
/// <summary>
/// Retrieves the notification XML content as a WinRT XML document.
/// </summary>
/// <returns>The notification XML content as a WinRT XML document.</returns>
public XmlDocument GetXml()
{
XmlDocument xml = new XmlDocument();
xml.LoadXml(GetContent());
return xml;
}
#endif
}
}
\ No newline at end of file
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System;
namespace Microsoft.Toolkit.Uwp.Notifications
{
internal sealed class EnumStringAttribute : Attribute
{
public string String { get; }
public EnumStringAttribute(string s)
{
if (s == null)
{
throw new ArgumentNullException(nameof(s));
}
String = s;
}
public override string ToString()
{
return String;
}
}
}
\ No newline at end of file
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
#if WINDOWS_UWP
using Windows.Data.Xml.Dom;
#endif
namespace Microsoft.Toolkit.Uwp.Notifications
{
/// <summary>
/// Base notification content interface to retrieve notification Xml as a string.
/// </summary>
public interface INotificationContent
{
/// <summary>
/// Retrieves the notification Xml content as a string.
/// </summary>
/// <returns>The notification Xml content as a string.</returns>
string GetContent();
#if WINDOWS_UWP
/// <summary>
/// Retrieves the notification Xml content as a WinRT Xml document.
/// </summary>
/// <returns>The notification Xml content as a WinRT Xml document.</returns>
XmlDocument GetXml();
#endif
}
}
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System;
using System.Collections;
using System.Collections.Generic;
#if WINDOWS_UWP
#endif
namespace Microsoft.Toolkit.Uwp.Notifications
{
internal sealed class LimitedList<T> : IList<T>
{
private List<T> _list;
public int Limit { get; private set; }
public LimitedList(int limit)
{
_list = new List<T>(limit);
Limit = limit;
}
public T this[int index]
{
get
{
return _list[index];
}
set
{
_list[index] = value;
}
}
public int Count
{
get
{
return _list.Count;
}
}
public bool IsReadOnly
{
get
{
return false;
}
}
public void Add(T item)
{
if (_list.Count >= Limit)
{
throw new Exception("This list is limited to " + Limit + " items. You cannot add more items.");
}
_list.Add(item);
}
public void Clear()
{
_list.Clear();
}
public bool Contains(T item)
{
return _list.Contains(item);
}
public void CopyTo(T[] array, int arrayIndex)
{
_list.CopyTo(array, arrayIndex);
}
public IEnumerator<T> GetEnumerator()
{
return _list.GetEnumerator();
}
public int IndexOf(T item)
{
return _list.IndexOf(item);
}
public void Insert(int index, T item)
{
_list.Insert(index, item);
}
public bool Remove(T item)
{
return _list.Remove(item);
}
public void RemoveAt(int index)
{
_list.RemoveAt(index);
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
internal interface IElementWithDescendants
{
IEnumerable<object> Descendants();
}
}
\ No newline at end of file
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System;
#if WINDOWS_UWP
#endif
namespace Microsoft.Toolkit.Uwp.Notifications
{
/// <summary>
/// Exception returned when invalid notification content is provided.
/// </summary>
internal sealed class NotificationContentValidationException : Exception
{
public NotificationContentValidationException(string message)
: base(message)
{
}
}
}
\ No newline at end of file
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System;
#if WINDOWS_UWP
#endif
namespace Microsoft.Toolkit.Uwp.Notifications
{
internal sealed class NotificationXmlAttributeAttribute : Attribute
{
public string Name { get; private set; }
public object DefaultValue { get; private set; }
public NotificationXmlAttributeAttribute(string name, object defaultValue = null)
{
Name = name;
DefaultValue = defaultValue;
}
}
}
\ No newline at end of file
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System;
#if WINDOWS_UWP
#endif
namespace Microsoft.Toolkit.Uwp.Notifications
{
/// <summary>
/// This attribute should be specified at most one time on an Element class. The property's value will be written as a string in the element's body.
/// </summary>
internal sealed class NotificationXmlContentAttribute : Attribute
{
}
}
\ No newline at end of file
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System;
#if WINDOWS_UWP
#endif
namespace Microsoft.Toolkit.Uwp.Notifications
{
internal sealed class NotificationXmlElementAttribute : Attribute
{
public string Name { get; private set; }
public NotificationXmlElementAttribute(string name)
{
if (string.IsNullOrWhiteSpace(name))
{
throw new ArgumentNullException("name cannot be null or whitespace");
}
Name = name;
}
}
}
\ No newline at end of file
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
#if WINDOWS_UWP
#endif
namespace Microsoft.Toolkit.Uwp.Notifications
{
internal static class XmlWriterHelper
{
public static void Write(System.Xml.XmlWriter writer, object element)
{
NotificationXmlElementAttribute elAttr = GetElementAttribute(element.GetType());
// If it isn't an element attribute, don't write anything
if (elAttr == null)
{
return;
}
writer.WriteStartElement(elAttr.Name);
IEnumerable<PropertyInfo> properties = GetProperties(element.GetType());
List<object> elements = new List<object>();
object content = null;
// Write the attributes first
foreach (PropertyInfo p in properties)
{
IEnumerable<Attribute> attributes = GetCustomAttributes(p);
NotificationXmlAttributeAttribute attr = attributes.OfType<NotificationXmlAttributeAttribute>().FirstOrDefault();
object propertyValue = GetPropertyValue(p, element);
// If it's an attribute
if (attr != null)
{
object defaultValue = attr.DefaultValue;
// If the value is not the default value (and it's not null) we'll write it
if (!object.Equals(propertyValue, defaultValue) && propertyValue != null)
{
writer.WriteAttributeString(attr.Name, PropertyValueToString(propertyValue));
}
}
// If it's a content attribute
else if (attributes.OfType<NotificationXmlContentAttribute>().Any())
{
content = propertyValue;
}
// Otherwise it's an element or collection of elements
else
{
if (propertyValue != null)
{
elements.Add(propertyValue);
}
}
}
// Then write children
foreach (object el in elements)
{
// If it's a collection of children
if (el is IEnumerable)
{
foreach (object child in el as IEnumerable)
{
Write(writer, child);
}
continue;
}
// Otherwise just write the single element
Write(writer, el);
}
// Then write any content if there is content
if (content != null)
{
string contentString = content.ToString();
if (!string.IsNullOrWhiteSpace(contentString))
{
writer.WriteString(contentString);
}
}
writer.WriteEndElement();
}
private static object GetPropertyValue(PropertyInfo propertyInfo, object obj)
{
#if NETFX_CORE
return propertyInfo.GetValue(obj);
#else
return propertyInfo.GetValue(obj, null);
#endif
}
private static string PropertyValueToString(object propertyValue)
{
Type type = propertyValue.GetType();
if (IsEnum(type))
{
EnumStringAttribute enumStringAttr = GetEnumStringAttribute(propertyValue as Enum);
if (enumStringAttr != null)
{
return enumStringAttr.String;
}
}
else if (propertyValue is bool)
{
if ((bool)propertyValue)
{
return "true";
}
return "false";
}
else if (propertyValue is DateTimeOffset?)
{
DateTimeOffset? dateTime = propertyValue as DateTimeOffset?;
if (dateTime.HasValue)
{
// ISO 8601 format
return System.Xml.XmlConvert.ToString(dateTime.Value);
}
else
{
return null;
}
}
return propertyValue.ToString();
}
private static EnumStringAttribute GetEnumStringAttribute(Enum enumValue)
{
#if NETFX_CORE
return enumValue.GetType().GetTypeInfo().GetDeclaredField(enumValue.ToString()).GetCustomAttribute<EnumStringAttribute>();
#else
MemberInfo[] memberInfo = enumValue.GetType().GetMember(enumValue.ToString());
if (memberInfo != null && memberInfo.Length > 0)
{
object[] attrs = memberInfo[0].GetCustomAttributes(typeof(EnumStringAttribute), false);
if (attrs != null && attrs.Length > 0)
return attrs[0] as EnumStringAttribute;
}
return null;
#endif
}
private static bool IsEnum(Type type)
{
#if NETFX_CORE
return type.GetTypeInfo().IsEnum;
#else
return type.IsEnum;
#endif
}
private static IEnumerable<PropertyInfo> GetProperties(Type type)
{
#if NETFX_CORE
return type.GetTypeInfo().DeclaredProperties;
#else
return type.GetProperties();
#endif
}
private static NotificationXmlElementAttribute GetElementAttribute(Type type)
{
return GetCustomAttributes(type).OfType<NotificationXmlElementAttribute>().FirstOrDefault();
}
private static IEnumerable<Attribute> GetCustomAttributes(Type type)
{
#if NETFX_CORE
return type.GetTypeInfo().GetCustomAttributes();
#else
return type.GetCustomAttributes(true).OfType<Attribute>();
#endif
}
private static IEnumerable<Attribute> GetCustomAttributes(PropertyInfo propertyInfo)
{
#if NETFX_CORE
return propertyInfo.GetCustomAttributes();
#else
return propertyInfo.GetCustomAttributes(true).OfType<Attribute>();
#endif
}
/// <summary>
/// Gets the provided binding value, if it exists. Otherwise, falls back to the absolute value.
/// </summary>
/// <typeparam name="T">The type of the enum of the class properties.</typeparam>
/// <param name="bindings">The collection of data-bound values.</param>
/// <param name="bindableProperty">The property to obtain.</param>
/// <param name="absoluteValue">The absolute value, if any.</param>
/// <returns>The provided binding value, if it exists. Otherwise, falls back to the absolute value.</returns>
internal static string GetBindingOrAbsoluteXmlValue<T>(IDictionary<T, string> bindings, T bindableProperty, string absoluteValue)
{
// If a binding is provided, use the binding value
string bindingValue;
if (bindings.TryGetValue(bindableProperty, out bindingValue))
{
return "{" + bindingValue + "}";
}
// Otherwise fallback to the absolute value
return absoluteValue;
}
}
}
\ No newline at end of file
@echo off
set files=..\Microsoft.Windows.Toolkit.Notifications.Portable\bin\Release\Microsoft.Windows.Toolkit.Notifications.dll
set files=%files% ..\Microsoft.Windows.Toolkit.Notifications.Portable\bin\Release\Microsoft.Windows.Toolkit.Notifications.pdb
set files=%files% ..\Microsoft.Windows.Toolkit.Notifications.Portable\bin\Release\Microsoft.Windows.Toolkit.Notifications.xml
set files=%files% ..\Microsoft.Windows.Toolkit.Notifications.WinRT\bin\Release\Microsoft.Windows.Toolkit.Notifications.winmd
set files=%files% ..\Microsoft.Windows.Toolkit.Notifications.WinRT\bin\Release\Microsoft.Windows.Toolkit.Notifications.pri
set files=%files% ..\Microsoft.Windows.Toolkit.Notifications.WinRT\bin\Release\Microsoft.Windows.Toolkit.Notifications.pdb
set files=%files% ..\Microsoft.Windows.Toolkit.Notifications.WinRT\bin\Release\Microsoft.Windows.Toolkit.Notifications.xml
set files=%files% ..\Microsoft.Windows.Toolkit.Notifications.NETStandard\bin\Release\Microsoft.Windows.Toolkit.Notifications.dll
set files=%files% ..\Microsoft.Windows.Toolkit.Notifications.NETStandard\bin\Release\Microsoft.Windows.Toolkit.Notifications.pdb
set files=%files% ..\Microsoft.Windows.Toolkit.Notifications.NETStandard\bin\Release\Microsoft.Windows.Toolkit.Notifications.xml
set files=%files% ..\Microsoft.Windows.Toolkit.Notifications.UWP\bin\Release\Microsoft.Windows.Toolkit.Notifications.dll
set files=%files% ..\Microsoft.Windows.Toolkit.Notifications.UWP\bin\Release\Microsoft.Windows.Toolkit.Notifications.pdb
set files=%files% ..\Microsoft.Windows.Toolkit.Notifications.UWP\bin\Release\Microsoft.Windows.Toolkit.Notifications.xml
FOR %%f IN (%files%) DO IF NOT EXIST %%f call :file_not_found %%f
echo Here are the current timestamps on the DLL's...
echo.
FOR %%f IN (%files%) DO ECHO %%~tf %%f
echo.
PAUSE
echo Welcome, let's create a new NuGet package for Notifications!
echo.
set /p version="Enter Version Number (ex. 10240.0.0): "
if not exist "NugetPackages" mkdir "NugetPackages"
"C:\Program Files (x86)\NuGet\nuget.exe" pack Microsoft.Windows.Toolkit.Notifications.nuspec -Version %version% -OutputDirectory "NugetPackages"
"C:\Program Files (x86)\NuGet\nuget.exe" pack Microsoft.Windows.Toolkit.Notifications.JavaScript.nuspec -Version %version% -OutputDirectory "NugetPackages"
PAUSE
explorer NugetPackages
exit
:file_not_found
echo File not found: %1
PAUSE
exit
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>8bacd7a9-b205-4adf-bda9-763b30a66576</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>Microsoft.Toolkit.Uwp.Notifications</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)Adaptive\AdaptiveGroup.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Adaptive\AdaptiveHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Adaptive\AdaptiveImage.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Adaptive\AdaptiveImageEnums.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Adaptive\AdaptiveProgressBar.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Adaptive\AdaptiveProgressBarBindableProperty.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Adaptive\AdaptiveProgressBarValue.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Adaptive\AdaptiveSubgroup.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Adaptive\AdaptiveSubgroupEnums.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Adaptive\AdaptiveText.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Adaptive\AdaptiveTextBindableProperty.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Adaptive\AdaptiveTextEnums.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Adaptive\BaseImageHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Adaptive\BaseTextHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Adaptive\BindableValues\BindableProgressBarValue.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Adaptive\BindableValues\BindableString.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Adaptive\Elements\Element_AdaptiveProgressBar.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Adaptive\IAdaptiveSubgroupChild.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Adaptive\Elements\Element_AdaptiveGroup.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Adaptive\Elements\Element_AdaptiveImage.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Adaptive\Elements\Element_AdaptiveImageEnums.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Adaptive\Elements\Element_AdaptiveSubgroup.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Adaptive\Elements\Element_AdaptiveText.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Adaptive\IAdaptiveChild.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Adaptive\IBaseImage.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Adaptive\IBaseText.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Badges\BadgeGlyphContent.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Badges\BadgeGlyphValue.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Badges\BadgeNumericContent.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Common\ArgumentValidator.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Common\BaseElement.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Common\INotificationContent.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Common\EnumStringAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Common\LimitedList{T}.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Common\NotificationContentValidationException.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Common\NotificationXmlAttributeAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Common\NotificationXmlContentAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Common\NotificationXmlElementAttribute.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Common\XmlWriterHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tiles\ITileBindingContentAdaptiveChild.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tiles\TileBackgroundImage.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tiles\TileBasicImage.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tiles\TileCommon.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tiles\Elements\TileElementsCommon.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tiles\Elements\Element_Tile.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tiles\Elements\Element_TileBinding.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tiles\Elements\Element_TileVisual.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tiles\TileImages.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tiles\SpecialTemplates\TileBindingContentContact.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tiles\SpecialTemplates\TileBindingContentIconic.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tiles\SpecialTemplates\TileBindingContentPeople.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tiles\SpecialTemplates\TileBindingContentPhotos.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tiles\TileBasicText.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tiles\TileBinding.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tiles\TileBindingContentAdaptive.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tiles\TileBranding.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tiles\TileContent.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tiles\TilePeekImage.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tiles\TileSizeToAdaptiveTemplateConverter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tiles\TileTemplateNameV3.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tiles\TileTextStacking.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tiles\TileVisual.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Toasts\Elements\Element_ToastHeader.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Toasts\Elements\IElement_ToastActivatable.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Toasts\ToastActivationOptions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Toasts\IToastBindingGenericChild.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Toasts\IToastButton.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Toasts\IToastInput.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Toasts\ToastActionsCustom.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Toasts\ToastActionsSnoozeAndDismiss.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Toasts\ToastButtonDismiss.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Toasts\ToastButtonSnooze.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Toasts\ToastCommon.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Toasts\Elements\Element_Toast.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Toasts\Elements\Element_ToastAction.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Toasts\Elements\Element_ToastActions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Toasts\Elements\Element_ToastAudio.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Toasts\Elements\Element_ToastBinding.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Toasts\Elements\Element_ToastImage.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Toasts\Elements\Element_ToastInput.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Toasts\Elements\Element_ToastSelection.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Toasts\Elements\Element_ToastText.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Toasts\Elements\Element_ToastVisual.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Toasts\IToastActions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Toasts\ToastAudio.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Toasts\ToastBindingGeneric.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Toasts\ToastButton.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Toasts\ToastContent.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Toasts\ToastContextMenuItem.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Toasts\ToastGenericAppLogo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Toasts\ToastGenericAppLogoEnums.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Toasts\ToastGenericAttributionText.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Toasts\ToastGenericHeroImage.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Toasts\ToastHeader.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Toasts\ToastSelectionBox.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Toasts\ToastSelectionBoxItem.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Toasts\ToastTextBox.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Toasts\ToastVisual.cs" />
</ItemGroup>
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)readme.md" />
</ItemGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>8bacd7a9-b205-4adf-bda9-763b30a66576</ProjectGuid>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
<PropertyGroup />
<Import Project="Microsoft.Toolkit.Uwp.Notifications.Shared.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
</Project>
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
namespace Microsoft.Toolkit.Uwp.Notifications
{
[NotificationXmlElement("tile")]
internal sealed class Element_Tile : BaseElement
{
public Element_TileVisual Visual { get; set; }
}
}
\ No newline at end of file
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System;
using System.Collections.Generic;
namespace Microsoft.Toolkit.Uwp.Notifications
{
[NotificationXmlElement("binding")]
internal sealed class Element_TileBinding : IElementWithDescendants
{
internal const TileBranding DEFAULT_BRANDING = TileBranding.Auto;
internal const TileTextStacking DEFAULT_TEXT_STACKING = TileTextStacking.Top;
internal const int DEFAULT_OVERLAY = 20;
public Element_TileBinding(TileTemplateNameV3 template)
{
Template = template;
}
[NotificationXmlAttribute("template")]
public TileTemplateNameV3 Template { get; private set; }
/// <summary>
/// Set to true to allow Windows to append a query string to the image URI supplied in the Tile notification. Use this attribute if your server hosts images and can handle query strings, either by retrieving an image variant based on the query strings or by ignoring the query string and returning the image as specified without the query string. This query string specifies scale, contrast setting, and language; for instance, a value of
///
/// "www.website.com/images/hello.png"
///
/// included in the notification becomes
///
/// "www.website.com/images/hello.png?ms-scale=100&amp;ms-contrast=standard&amp;ms-lang=en-us"
/// </summary>
[NotificationXmlAttribute("addImageQuery")]
public bool? AddImageQuery { get; set; }
/// <summary>
/// A default base URI that is combined with relative URIs in image source attributes.
/// </summary>
[NotificationXmlAttribute("baseUri")]
public Uri BaseUri { get; set; }
/// <summary>
/// The form that the Tile should use to display the app's brand.
/// </summary>
[NotificationXmlAttribute("branding", DEFAULT_BRANDING)]
public TileBranding Branding { get; set; } = DEFAULT_BRANDING;
/// <summary>
/// Set to a sender-defined string that uniquely identifies the content of the notification. This prevents duplicates in the situation where a large Tile template is displaying the last three wide Tile notifications.
///
/// Required: NO
/// </summary>
[NotificationXmlAttribute("contentId")]
public string ContentId { get; set; }
/// <summary>
/// An optional string to override the Tile's display name while showing this notification.
/// </summary>
[NotificationXmlAttribute("displayName")]
public string DisplayName { get; set; }
/// <summary>
/// The target locale of the XML payload, specified as a BCP-47 language tags such as "en-US" or "fr-FR". The locale specified here overrides that in visual, but can be overriden by that in text. If this value is a literal string, this attribute defaults to the user's UI language. If this value is a string reference, this attribute defaults to the locale chosen by Windows Runtime in resolving the string. See Remarks for when this value isn't specified.
/// </summary>
[NotificationXmlAttribute("lang")]
public string Language { get; set; }
[NotificationXmlAttribute("hint-lockDetailedStatus1")]
public string LockDetailedStatus1 { get; set; }
[NotificationXmlAttribute("hint-lockDetailedStatus2")]
public string LockDetailedStatus2 { get; set; }
[NotificationXmlAttribute("hint-lockDetailedStatus3")]
public string LockDetailedStatus3 { get; set; }
[NotificationXmlAttribute("arguments")]
public string Arguments { get; set; }
/// <summary>
/// Throws exception if value is invalid
/// </summary>
/// <param name="value">Overlay value (0-100)</param>
internal static void CheckOverlayValue(int value)
{
if (value < 0 || value > 100)
{
throw new ArgumentOutOfRangeException("Overlay must be between 0 and 100, inclusive.");
}
}
[NotificationXmlAttribute("hint-presentation")]
public TilePresentation? Presentation { get; set; }
[NotificationXmlAttribute("hint-textStacking", DEFAULT_TEXT_STACKING)]
public TileTextStacking TextStacking { get; set; } = DEFAULT_TEXT_STACKING;
public IList<IElement_TileBindingChild> Children { get; private set; } = new List<IElement_TileBindingChild>();
/// <summary>
/// Generates an enumerable collection of children and all those children's children
/// </summary>
/// <returns>Enumerable collection of children and all those children's children.</returns>
public IEnumerable<object> Descendants()
{
foreach (IElement_TileBindingChild child in Children)
{
// Return the child
yield return child;
// And if it has descendants, return the descendants
if (child is IElementWithDescendants)
{
foreach (object descendant in (child as IElementWithDescendants).Descendants())
{
yield return descendant;
}
}
}
}
}
internal interface IElement_TileBindingChild
{
}
}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
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