diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile
index f09593147..6935449fd 100644
--- a/.devcontainer/Dockerfile
+++ b/.devcontainer/Dockerfile
@@ -1,8 +1,5 @@
-# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.208.0/containers/dotnet/.devcontainer/base.Dockerfile
-
-# [Choice] .NET version: 6.0, 5.0, 3.1, 6.0-bullseye, 5.0-bullseye, 3.1-bullseye, 6.0-focal, 5.0-focal, 3.1-focal, etc
-ARG VARIANT="8.0-bullseye-slim"
-FROM mcr.microsoft.com/vscode/devcontainers/dotnet:0-${VARIANT}
+# See https://github.com/devcontainers/images/tree/main/src/dotnet for image choices
+FROM mcr.microsoft.com/vscode/devcontainers/dotnet:9.0
# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
ARG NODE_VERSION="none"
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
index d21671858..f616c78fc 100644
--- a/.devcontainer/devcontainer.json
+++ b/.devcontainer/devcontainer.json
@@ -7,7 +7,7 @@
"args": {
// Update 'VARIANT' to pick a .NET Core version: 3.1, 5.0, 6.0
// Append -bullseye or -focal to pin to an OS version.
- "VARIANT": "6.0",
+ "VARIANT": "9.0",
// Options
"NODE_VERSION": "lts/*"
}
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index bc9dec043..9db0a33a8 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -17,9 +17,7 @@ on:
merge_group:
env:
- DOTNET_VERSION: ${{ '8.0.201' }}
- DOTNET_INSTALL_DIR: dotnet-install
- DOTNET_ROOT: dotnet-install
+ DOTNET_VERSION: ${{ '9.0.x' }}
ENABLE_DIAGNOSTICS: false
#COREHOST_TRACE: 1
MSBUILD_VERBOSITY: normal
@@ -31,7 +29,7 @@ env:
jobs:
# This workflow contains a single job called "Xaml-Style-Check"
Xaml-Style-Check:
- runs-on: windows-latest-large
+ runs-on: windows-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
diff --git a/Directory.Build.targets b/Directory.Build.targets
index 22dfa3191..77e29d5d4 100644
--- a/Directory.Build.targets
+++ b/Directory.Build.targets
@@ -1,7 +1,11 @@
+
+
+
+
-
+
diff --git a/Windows.Toolkit.Common.props b/Windows.Toolkit.Common.props
index 83f9ae093..773d2effe 100644
--- a/Windows.Toolkit.Common.props
+++ b/Windows.Toolkit.Common.props
@@ -29,8 +29,4 @@
true
true
-
-
-
-
diff --git a/components/AppServices/CommunityToolkit.AppServices.SourceGenerators/AppServiceGenerator.Helpers.cs b/components/AppServices/CommunityToolkit.AppServices.SourceGenerators/AppServiceGenerator.Helpers.cs
index 94c333763..ed86c952a 100644
--- a/components/AppServices/CommunityToolkit.AppServices.SourceGenerators/AppServiceGenerator.Helpers.cs
+++ b/components/AppServices/CommunityToolkit.AppServices.SourceGenerators/AppServiceGenerator.Helpers.cs
@@ -1,8 +1,9 @@
-// Licensed to the .NET Foundation under one or more agreements.
+// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.Diagnostics;
namespace CommunityToolkit.AppServices.SourceGenerators;
@@ -18,10 +19,27 @@ private static class Helpers
/// Gets whether the current target is a UWP application.
///
/// The input instance to inspect.
+ /// The analyzer options to use to get info on the target application.
/// Whether the current target is a UWP application.
- public static bool IsUwpTarget(Compilation compilation)
+ public static bool IsUwpTarget(Compilation compilation, AnalyzerConfigOptions analyzerOptions)
{
- return compilation.Options.OutputKind == OutputKind.WindowsRuntimeApplication;
+ // If the application type is a Windows Runtime application, then it's for sure a UWP app
+ if (compilation.Options.OutputKind == OutputKind.WindowsRuntimeApplication)
+ {
+ return true;
+ }
+
+ // Otherwise, the application is UWP if "UseUwpTools" is set
+ if (analyzerOptions.TryGetValue("build_property.UseUwpTools", out string? propertyValue))
+ {
+ if (bool.TryParse(propertyValue, out bool useUwpTools))
+ {
+ return true;
+ }
+ }
+
+ // The app is definitely not a UWP app
+ return false;
}
}
}
diff --git a/components/AppServices/CommunityToolkit.AppServices.SourceGenerators/AppServiceGenerator.cs b/components/AppServices/CommunityToolkit.AppServices.SourceGenerators/AppServiceGenerator.cs
index 466f313bc..f85e2a73b 100644
--- a/components/AppServices/CommunityToolkit.AppServices.SourceGenerators/AppServiceGenerator.cs
+++ b/components/AppServices/CommunityToolkit.AppServices.SourceGenerators/AppServiceGenerator.cs
@@ -24,13 +24,12 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
{
// Get all app service class implementations, and only enable this branch if the target is not a UWP app (the component)
IncrementalValuesProvider<(HierarchyInfo Hierarchy, AppServiceInfo Info)> appServiceComponentInfo =
- context.SyntaxProvider
- .CreateSyntaxProvider(
+ context.CreateSyntaxProviderWithOptions(
static (node, _) => node is ClassDeclarationSyntax classDeclaration && classDeclaration.HasOrPotentiallyHasBaseTypes(),
static (context, token) =>
{
// Only retrieve host info if the target is not a UWP application
- if (Helpers.IsUwpTarget(context.SemanticModel.Compilation))
+ if (Helpers.IsUwpTarget(context.SemanticModel.Compilation, context.GlobalOptions))
{
return default;
}
@@ -80,14 +79,13 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
// Gather all interfaces, and only enable this branch if the target is a UWP app (the host)
IncrementalValuesProvider<(HierarchyInfo Hierarchy, AppServiceInfo Info)> appServiceHostInfo =
- context.SyntaxProvider
- .ForAttributeWithMetadataName(
+ context.ForAttributeWithMetadataNameAndOptions(
"CommunityToolkit.AppServices.AppServiceAttribute",
static (node, _) => node is InterfaceDeclarationSyntax,
static (context, token) =>
{
// Only retrieve host info if the target is a UWP application
- if (!Helpers.IsUwpTarget(context.SemanticModel.Compilation))
+ if (!Helpers.IsUwpTarget(context.SemanticModel.Compilation, context.GlobalOptions))
{
return default;
}
diff --git a/components/AppServices/CommunityToolkit.AppServices.SourceGenerators/Extensions/GeneratorAttributeSyntaxContextWithOptions.cs b/components/AppServices/CommunityToolkit.AppServices.SourceGenerators/Extensions/GeneratorAttributeSyntaxContextWithOptions.cs
new file mode 100644
index 000000000..7f7596e01
--- /dev/null
+++ b/components/AppServices/CommunityToolkit.AppServices.SourceGenerators/Extensions/GeneratorAttributeSyntaxContextWithOptions.cs
@@ -0,0 +1,34 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Collections.Immutable;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.Diagnostics;
+
+namespace CommunityToolkit.AppServices.SourceGenerators.Extensions;
+
+///
+///
+///
+/// The original value.
+/// The original value.
+internal readonly struct GeneratorAttributeSyntaxContextWithOptions(
+ GeneratorAttributeSyntaxContext syntaxContext,
+ AnalyzerConfigOptions globalOptions)
+{
+ ///
+ public SyntaxNode TargetNode { get; } = syntaxContext.TargetNode;
+
+ ///
+ public ISymbol TargetSymbol { get; } = syntaxContext.TargetSymbol;
+
+ ///
+ public SemanticModel SemanticModel { get; } = syntaxContext.SemanticModel;
+
+ ///
+ public ImmutableArray Attributes { get; } = syntaxContext.Attributes;
+
+ ///
+ public AnalyzerConfigOptions GlobalOptions { get; } = globalOptions;
+}
diff --git a/components/AppServices/CommunityToolkit.AppServices.SourceGenerators/Extensions/GeneratorSyntaxContextWithOptions.cs b/components/AppServices/CommunityToolkit.AppServices.SourceGenerators/Extensions/GeneratorSyntaxContextWithOptions.cs
new file mode 100644
index 000000000..141087948
--- /dev/null
+++ b/components/AppServices/CommunityToolkit.AppServices.SourceGenerators/Extensions/GeneratorSyntaxContextWithOptions.cs
@@ -0,0 +1,27 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.Diagnostics;
+
+namespace CommunityToolkit.AppServices.SourceGenerators.Extensions;
+
+///
+///
+///
+/// The original value.
+/// The original value.
+internal readonly struct GeneratorSyntaxContextWithOptions(
+ GeneratorSyntaxContext syntaxContext,
+ AnalyzerConfigOptions globalOptions)
+{
+ ///
+ public SyntaxNode Node { get; } = syntaxContext.Node;
+
+ ///
+ public SemanticModel SemanticModel { get; } = syntaxContext.SemanticModel;
+
+ ///
+ public AnalyzerConfigOptions GlobalOptions { get; } = globalOptions;
+}
diff --git a/components/AppServices/CommunityToolkit.AppServices.SourceGenerators/Extensions/IncrementalGeneratorInitializationContextExtensions.cs b/components/AppServices/CommunityToolkit.AppServices.SourceGenerators/Extensions/IncrementalGeneratorInitializationContextExtensions.cs
new file mode 100644
index 000000000..d8e900d9b
--- /dev/null
+++ b/components/AppServices/CommunityToolkit.AppServices.SourceGenerators/Extensions/IncrementalGeneratorInitializationContextExtensions.cs
@@ -0,0 +1,59 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Threading;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.Diagnostics;
+
+namespace CommunityToolkit.AppServices.SourceGenerators.Extensions;
+
+///
+/// Extension methods for .
+///
+internal static class IncrementalGeneratorInitializationContextExtensions
+{
+ ///
+ public static IncrementalValuesProvider ForAttributeWithMetadataNameAndOptions(
+ this IncrementalGeneratorInitializationContext context,
+ string fullyQualifiedMetadataName,
+ Func predicate,
+ Func transform)
+ {
+ // Invoke 'ForAttributeWithMetadataName' normally, but just return the context directly
+ IncrementalValuesProvider syntaxContext = context.SyntaxProvider.ForAttributeWithMetadataName(
+ fullyQualifiedMetadataName,
+ predicate,
+ static (context, token) => context);
+
+ // Do the same for the analyzer config options
+ IncrementalValueProvider configOptions = context.AnalyzerConfigOptionsProvider.Select(static (provider, token) => provider.GlobalOptions);
+
+ // Merge the two and invoke the provided transform on these two values. Neither value
+ // is equatable, meaning the pipeline will always re-run until this point. This is
+ // intentional: we don't want any symbols or other expensive objects to be kept alive
+ // across incremental steps, especially if they could cause entire compilations to be
+ // rooted, which would significantly increase memory use and introduce more GC pauses.
+ // In this specific case, flowing non equatable values in a pipeline is therefore fine.
+ return syntaxContext.Combine(configOptions).Select((input, token) => transform(new GeneratorAttributeSyntaxContextWithOptions(input.Left, input.Right), token));
+ }
+
+ ///
+ public static IncrementalValuesProvider CreateSyntaxProviderWithOptions(
+ this IncrementalGeneratorInitializationContext context,
+ Func predicate,
+ Func transform)
+ {
+ // Invoke 'ForAttributeWithMetadataName' normally, but just return the context directly
+ IncrementalValuesProvider syntaxContext = context.SyntaxProvider.CreateSyntaxProvider(
+ predicate,
+ static (context, token) => context);
+
+ // Do the same for the analyzer config options
+ IncrementalValueProvider configOptions = context.AnalyzerConfigOptionsProvider.Select(static (provider, token) => provider.GlobalOptions);
+
+ // Merge the two and invoke the provided transform, like the extension above
+ return syntaxContext.Combine(configOptions).Select((input, token) => transform(new GeneratorSyntaxContextWithOptions(input.Left, input.Right), token));
+ }
+}
diff --git a/components/AppServices/src/AppServiceComponent.cs b/components/AppServices/src/AppServiceComponent.cs
index 3a61892ca..2692f96fe 100644
--- a/components/AppServices/src/AppServiceComponent.cs
+++ b/components/AppServices/src/AppServiceComponent.cs
@@ -14,7 +14,7 @@
using System.Diagnostics.CodeAnalysis;
using CommunityToolkit.AppServices.Helpers;
-#pragma warning disable CA2213, CA1063
+#pragma warning disable CA2213, CA1063, CsWinRT1028
namespace CommunityToolkit.AppServices;
@@ -462,7 +462,7 @@ private async void Connection_RequestReceived(AppServiceConnection sender, AppSe
try
{
// Try to get the registered endpoint with the command name, and invoke it
- if (_endpoints.TryGetValue(commandStr, out Func> endpoint))
+ if (_endpoints.TryGetValue(commandStr, out Func>? endpoint) && endpoint is {})
{
response = await endpoint(new AppServiceParameters(this, sender, parameters));
}
diff --git a/components/AppServices/src/AppServiceHost.cs b/components/AppServices/src/AppServiceHost.cs
index a3558338d..28cb0b727 100644
--- a/components/AppServices/src/AppServiceHost.cs
+++ b/components/AppServices/src/AppServiceHost.cs
@@ -75,7 +75,7 @@ protected AppServiceHost(string appServiceName)
private static bool CanUseAppServiceFunctionality { get; } = AnalyticsInfo.VersionInfo.DeviceFamily == "Windows.Desktop" && ApiInformation.IsApiContractPresent("Windows.ApplicationModel.FullTrustAppContract", 1, 0);
///
- /// Handles the app service activation when is invoked.
+ /// Handles the app service activation when is invoked.
///
/// The args for the background activation.
/// Whether this activation was an app service connection that could be handled by this host.
@@ -204,9 +204,9 @@ private void AppServiceConnection_RequestReceived(AppServiceConnection sender, A
if (args.Request.Message.TryGetValue(ProgressKey, out object? progressKey) &&
args.Request.Message.TryGetValue(ProgressValue, out object? progressValue) &&
progressKey is Guid id &&
- _progressTrackers.TryGetValue(id, out IProgress progress))
+ _progressTrackers.TryGetValue(id, out IProgress? progress))
{
- progress.Report(progressValue);
+ progress?.Report(progressValue);
}
}
diff --git a/components/AppServices/src/CommunityToolkit.AppServices.csproj b/components/AppServices/src/CommunityToolkit.AppServices.csproj
index dcab9109a..cf4e183b4 100644
--- a/components/AppServices/src/CommunityToolkit.AppServices.csproj
+++ b/components/AppServices/src/CommunityToolkit.AppServices.csproj
@@ -29,15 +29,15 @@
-
+
Windows Desktop Extensions for the UWP
-
-
+
+
@@ -49,13 +49,11 @@
-
-
-
-
+
+
-
+
diff --git a/components/AppServices/src/CommunityToolkit.AppServices.targets b/components/AppServices/src/CommunityToolkit.Labs.AppServices.targets
similarity index 95%
rename from components/AppServices/src/CommunityToolkit.AppServices.targets
rename to components/AppServices/src/CommunityToolkit.Labs.AppServices.targets
index 78089e0a2..21ddc5cf2 100644
--- a/components/AppServices/src/CommunityToolkit.AppServices.targets
+++ b/components/AppServices/src/CommunityToolkit.Labs.AppServices.targets
@@ -1,5 +1,10 @@
+
+
+
+
+
diff --git a/components/CanvasView/src/CanvasView.cs b/components/CanvasView/src/CanvasView.cs
index 72f13bd36..2268159ca 100644
--- a/components/CanvasView/src/CanvasView.cs
+++ b/components/CanvasView/src/CanvasView.cs
@@ -2,6 +2,9 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if NET8_0_OR_GREATER
+using System.Diagnostics.CodeAnalysis;
+#endif
using CommunityToolkit.Labs.WinUI.CanvasViewInternal;
using CommunityToolkit.WinUI.Helpers;
@@ -59,6 +62,9 @@ protected override void ClearContainerForItemOverride(DependencyObject element,
}
}
+#if NET8_0_OR_GREATER
+ [UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "These use of 'SetBindingExpressionValue' might be fine (we should revisit this later)")]
+#endif
private void ContentPresenter_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
{
// Move the rectangle.
diff --git a/components/CanvasView/src/Dependencies.props b/components/CanvasView/src/Dependencies.props
index a52b7ba47..04027d391 100644
--- a/components/CanvasView/src/Dependencies.props
+++ b/components/CanvasView/src/Dependencies.props
@@ -11,21 +11,21 @@
-
+
-
+
-
+
-
+
diff --git a/components/CanvasView/src/FrameworkElementExtensions.cs b/components/CanvasView/src/FrameworkElementExtensions.cs
index 4619b4977..ad70d1122 100644
--- a/components/CanvasView/src/FrameworkElementExtensions.cs
+++ b/components/CanvasView/src/FrameworkElementExtensions.cs
@@ -2,6 +2,10 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+#if NET8_0_OR_GREATER
+using System.Diagnostics.CodeAnalysis;
+#endif
+
namespace CommunityToolkit.Labs.WinUI.CanvasViewInternal;
public static partial class FrameworkElementExtensions
@@ -16,6 +20,9 @@ public static partial class FrameworkElementExtensions
/// The with the property to update.
/// The to update the underlying bound value of.
/// The new value to update the bound property to.
+#if NET8_0_OR_GREATER
+ [RequiresUnreferencedCode("This method accesses properties of binding expressions in a trim-unsafe way.")]
+#endif
public static void SetBindingExpressionValue(this FrameworkElement fe, DependencyProperty property, object value)
{
var subBinding = fe.GetBindingExpression(property);
diff --git a/components/DataTable/samples/Dependencies.props b/components/DataTable/samples/Dependencies.props
index 86bd9e0c5..83b846be8 100644
--- a/components/DataTable/samples/Dependencies.props
+++ b/components/DataTable/samples/Dependencies.props
@@ -11,14 +11,14 @@
-
-
+
+
-
-
+
+
diff --git a/components/DataTable/src/Dependencies.props b/components/DataTable/src/Dependencies.props
index f58250e21..eb8a0bf0f 100644
--- a/components/DataTable/src/Dependencies.props
+++ b/components/DataTable/src/Dependencies.props
@@ -14,15 +14,15 @@
-
-
-
+
+
+
-
-
-
+
+
+
diff --git a/components/Notifications/src/Adaptive/AdaptiveGroup.cs b/components/Notifications/src/Adaptive/AdaptiveGroup.cs
index e4f6310cc..889019282 100644
--- a/components/Notifications/src/Adaptive/AdaptiveGroup.cs
+++ b/components/Notifications/src/Adaptive/AdaptiveGroup.cs
@@ -6,36 +6,35 @@
using System.Collections.Generic;
using CommunityToolkit.Notifications.Adaptive.Elements;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// 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.
+///
+public sealed class AdaptiveGroup : ITileBindingContentAdaptiveChild, IAdaptiveChild, IToastBindingGenericChild
{
///
- /// 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.
+ /// Gets the only valid children of groups are .
+ /// Each subgroup is displayed as a separate vertical column. Note that you must
+ /// include at least one subgroup in your group, otherwise an
+ /// will be thrown when you try to retrieve the XML for the notification.
///
- public sealed class AdaptiveGroup : ITileBindingContentAdaptiveChild, IAdaptiveChild, IToastBindingGenericChild
- {
- ///
- /// Gets the only valid children of groups are .
- /// Each subgroup is displayed as a separate vertical column. Note that you must
- /// include at least one subgroup in your group, otherwise an
- /// will be thrown when you try to retrieve the XML for the notification.
- ///
- public IList Children { get; private set; } = new List();
+ public IList Children { get; private set; } = new List();
- internal Element_AdaptiveGroup ConvertToElement()
+ internal Element_AdaptiveGroup ConvertToElement()
+ {
+ if (Children.Count == 0)
{
- 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();
+ throw new InvalidOperationException("Groups must have at least one child subgroup. The Children property had zero items in it.");
+ }
- foreach (var subgroup in Children)
- {
- group.Children.Add(subgroup.ConvertToElement());
- }
+ Element_AdaptiveGroup group = new Element_AdaptiveGroup();
- return group;
+ foreach (var subgroup in Children)
+ {
+ group.Children.Add(subgroup.ConvertToElement());
}
+
+ return group;
}
}
\ No newline at end of file
diff --git a/components/Notifications/src/Adaptive/AdaptiveHelper.cs b/components/Notifications/src/Adaptive/AdaptiveHelper.cs
index 67b4db649..03d8f26a0 100644
--- a/components/Notifications/src/Adaptive/AdaptiveHelper.cs
+++ b/components/Notifications/src/Adaptive/AdaptiveHelper.cs
@@ -4,38 +4,37 @@
using System;
-namespace CommunityToolkit.Notifications.Adaptive
+namespace CommunityToolkit.Notifications.Adaptive;
+
+internal static class AdaptiveHelper
{
- internal static class AdaptiveHelper
+ internal static object ConvertToElement(object obj)
{
- 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)
{
- 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());
+ 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());
}
}
\ No newline at end of file
diff --git a/components/Notifications/src/Adaptive/AdaptiveImage.cs b/components/Notifications/src/Adaptive/AdaptiveImage.cs
index 2a5a756f2..7d8687ffb 100644
--- a/components/Notifications/src/Adaptive/AdaptiveImage.cs
+++ b/components/Notifications/src/Adaptive/AdaptiveImage.cs
@@ -4,89 +4,88 @@
using CommunityToolkit.Notifications.Adaptive.Elements;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// An inline image.
+///
+public sealed class AdaptiveImage
+ : IBaseImage,
+ IToastBindingGenericChild,
+ ITileBindingContentAdaptiveChild,
+ IAdaptiveChild,
+ IAdaptiveSubgroupChild
{
///
- /// An inline image.
+ /// Gets or sets the desired cropping of the image.
+ /// Supported on Tiles since RTM. Supported on Toast since Anniversary Update.
///
- public sealed class AdaptiveImage
- : IBaseImage,
- IToastBindingGenericChild,
- ITileBindingContentAdaptiveChild,
- IAdaptiveChild,
- IAdaptiveSubgroupChild
- {
- ///
- /// Gets or sets the desired cropping of the image.
- /// Supported on Tiles since RTM. Supported on Toast since Anniversary Update.
- ///
- public AdaptiveImageCrop HintCrop { get; set; }
+ public AdaptiveImageCrop HintCrop { get; set; }
- ///
- /// Gets or sets a value whether a margin is removed. 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.
- ///
- public bool? HintRemoveMargin { get; set; }
+ ///
+ /// Gets or sets a value whether a margin is removed. 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.
+ ///
+ public bool? HintRemoveMargin { get; set; }
- ///
- /// Gets or sets the horizontal alignment of the image.
- /// For Toast, this is only supported when inside an .
- ///
- public AdaptiveImageAlign HintAlign { get; set; }
+ ///
+ /// Gets or sets the horizontal alignment of the image.
+ /// For Toast, this is only supported when inside an .
+ ///
+ public AdaptiveImageAlign HintAlign { get; set; }
- private string _source;
+ private string _source;
- ///
- /// Gets or sets the URI of the image (Required).
- /// Can be from your application package, application data, or the internet.
- /// Internet images must be less than 200 KB in size.
- ///
- public string Source
- {
- get { return _source; }
- set { BaseImageHelper.SetSource(ref _source, value); }
- }
+ ///
+ /// Gets or sets the URI of the image (Required).
+ /// Can be from your application package, application data, or the internet.
+ /// Internet images must be less than 200 KB in size.
+ ///
+ public string Source
+ {
+ get { return _source; }
+ set { BaseImageHelper.SetSource(ref _source, value); }
+ }
- ///
- /// Gets or sets a description of the image, for users of assistive technologies.
- ///
- public string AlternateText { get; set; }
+ ///
+ /// Gets or sets a description of the image, for users of assistive technologies.
+ ///
+ public string AlternateText { get; set; }
- ///
- /// Gets or sets 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.
- ///
- public bool? AddImageQuery { get; set; }
+ ///
+ /// Gets or sets 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.
+ ///
+ public bool? AddImageQuery { get; set; }
- ///
- /// Returns the image's source string.
- ///
- /// The image's source string.
- public override string ToString()
+ ///
+ /// Returns the image's source string.
+ ///
+ /// The image's source string.
+ public override string ToString()
+ {
+ if (Source == null)
{
- if (Source == null)
- {
- return "Source is null";
- }
-
- return Source;
+ return "Source is null";
}
- internal Element_AdaptiveImage ConvertToElement()
- {
- Element_AdaptiveImage image = BaseImageHelper.CreateBaseElement(this);
+ return Source;
+ }
- image.Crop = HintCrop;
- image.RemoveMargin = HintRemoveMargin;
- image.Align = HintAlign;
- image.Placement = AdaptiveImagePlacement.Inline;
+ internal Element_AdaptiveImage ConvertToElement()
+ {
+ Element_AdaptiveImage image = BaseImageHelper.CreateBaseElement(this);
- return image;
- }
+ image.Crop = HintCrop;
+ image.RemoveMargin = HintRemoveMargin;
+ image.Align = HintAlign;
+ image.Placement = AdaptiveImagePlacement.Inline;
+
+ return image;
}
}
\ No newline at end of file
diff --git a/components/Notifications/src/Adaptive/AdaptiveImageEnums.cs b/components/Notifications/src/Adaptive/AdaptiveImageEnums.cs
index 498471c97..2e2f44d14 100644
--- a/components/Notifications/src/Adaptive/AdaptiveImageEnums.cs
+++ b/components/Notifications/src/Adaptive/AdaptiveImageEnums.cs
@@ -2,57 +2,56 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// Specifies the horizontal alignment for an image.
+///
+public enum AdaptiveImageAlign
+{
+ ///
+ /// Default value, alignment behavior determined by renderer.
+ ///
+ Default,
+
+ ///
+ /// Image stretches to fill available width (and potentially available height too, depending on where the image is).
+ ///
+ Stretch,
+
+ ///
+ /// Align the image to the left, displaying the image at its native resolution.
+ ///
+ Left,
+
+ ///
+ /// Align the image in the center horizontally, displaying the image at its native resolution.
+ ///
+ Center,
+
+ ///
+ /// Align the image to the right, displaying the image at its native resolution.
+ ///
+ Right
+}
+
+///
+/// Specify the desired cropping of the image.
+///
+public enum AdaptiveImageCrop
{
///
- /// Specifies the horizontal alignment for an image.
- ///
- public enum AdaptiveImageAlign
- {
- ///
- /// Default value, alignment behavior determined by renderer.
- ///
- Default,
-
- ///
- /// Image stretches to fill available width (and potentially available height too, depending on where the image is).
- ///
- Stretch,
-
- ///
- /// Align the image to the left, displaying the image at its native resolution.
- ///
- Left,
-
- ///
- /// Align the image in the center horizontally, displaying the image at its native resolution.
- ///
- Center,
-
- ///
- /// Align the image to the right, displaying the image at its native resolution.
- ///
- Right
- }
-
- ///
- /// Specify the desired cropping of the image.
- ///
- public enum AdaptiveImageCrop
- {
- ///
- /// Default value, cropping behavior determined by renderer.
- ///
- Default,
-
- ///
- /// Image is not cropped.
- ///
- None,
-
- ///
- /// Image is cropped to a circle shape.
- ///
- Circle
- }
+ /// Default value, cropping behavior determined by renderer.
+ ///
+ Default,
+
+ ///
+ /// Image is not cropped.
+ ///
+ None,
+
+ ///
+ /// Image is cropped to a circle shape.
+ ///
+ Circle
}
\ No newline at end of file
diff --git a/components/Notifications/src/Adaptive/AdaptiveProgressBar.cs b/components/Notifications/src/Adaptive/AdaptiveProgressBar.cs
index 7f39bbceb..bb1e174f8 100644
--- a/components/Notifications/src/Adaptive/AdaptiveProgressBar.cs
+++ b/components/Notifications/src/Adaptive/AdaptiveProgressBar.cs
@@ -9,55 +9,54 @@
using BindableProgressBarValue = CommunityToolkit.Notifications.BindableProgressBarValue;
using BindableString = CommunityToolkit.Notifications.BindableString;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// New in Creators Update: A progress bar. Only supported on toasts on Desktop, build 15007 or newer.
+///
+public sealed class AdaptiveProgressBar : IToastBindingGenericChild
{
///
- /// New in Creators Update: A progress bar. Only supported on toasts on Desktop, build 15007 or newer.
+ /// Gets or sets an optional title string. Supports data binding.
///
- public sealed class AdaptiveProgressBar : IToastBindingGenericChild
+ public BindableString Title { get; set; }
+
+ ///
+ /// Gets or sets the value of the progress bar. Supports data binding. Defaults to 0.
+ ///
+ public BindableProgressBarValue Value { get; set; } = AdaptiveProgressBarValue.FromValue(0);
+
+ ///
+ /// 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.
+ ///
+ public BindableString ValueStringOverride { get; set; }
+
+ ///
+ /// Gets or sets a status string (Required), which is displayed underneath the progress bar. This string should reflect the status of the operation, like "Downloading..." or "Installing..."
+ ///
+ public BindableString Status { get; set; }
+
+ internal Element_AdaptiveProgressBar ConvertToElement()
{
- ///
- /// Gets or sets an optional title string. Supports data binding.
- ///
- public BindableString Title { get; set; }
-
- ///
- /// Gets or sets the value of the progress bar. Supports data binding. Defaults to 0.
- ///
- public BindableProgressBarValue Value { get; set; } = AdaptiveProgressBarValue.FromValue(0);
-
- ///
- /// 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.
- ///
- public BindableString ValueStringOverride { get; set; }
-
- ///
- /// Gets or sets a status string (Required), which is displayed underneath the progress bar. This string should reflect the status of the operation, like "Downloading..." or "Installing..."
- ///
- public BindableString 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();
+
+ answer.Title = Title?.ToXmlString();
+ answer.Value = val.ToXmlString();
+ answer.ValueStringOverride = ValueStringOverride?.ToXmlString();
+ answer.Status = Status?.ToXmlString();
+
+ if (answer.Status == null)
{
- // If Value not provided, we use 0
- var val = Value;
- if (val == null)
- {
- val = AdaptiveProgressBarValue.FromValue(0);
- }
-
- var answer = new Element_AdaptiveProgressBar();
-
- answer.Title = Title?.ToXmlString();
- answer.Value = val.ToXmlString();
- answer.ValueStringOverride = ValueStringOverride?.ToXmlString();
- answer.Status = Status?.ToXmlString();
-
- if (answer.Status == null)
- {
- throw new NullReferenceException("Status property is required.");
- }
-
- return answer;
+ throw new NullReferenceException("Status property is required.");
}
+
+ return answer;
}
}
diff --git a/components/Notifications/src/Adaptive/AdaptiveProgressBarValue.cs b/components/Notifications/src/Adaptive/AdaptiveProgressBarValue.cs
index a6e6880cd..9390bcef3 100644
--- a/components/Notifications/src/Adaptive/AdaptiveProgressBarValue.cs
+++ b/components/Notifications/src/Adaptive/AdaptiveProgressBarValue.cs
@@ -4,93 +4,92 @@
using System;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// A class that represents the progress bar's value.
+///
+public sealed class AdaptiveProgressBarValue
{
///
- /// A class that represents the progress bar's value.
+ /// Gets or sets the property name to bind to.
///
- public sealed class AdaptiveProgressBarValue
- {
- ///
- /// Gets or sets the property name to bind to.
- ///
- public string BindingName { get; set; }
+ public string BindingName { get; set; }
- ///
- /// Gets or sets the value (0-1) representing the percent complete.
- ///
- public double Value { get; set; }
+ ///
+ /// Gets or sets the value (0-1) representing the percent complete.
+ ///
+ public double Value { get; set; }
- ///
- /// Gets or sets a value indicating whether the progress bar is indeterminate.
- ///
- public bool IsIndeterminate { get; set; }
+ ///
+ /// Gets or sets a value indicating whether the progress bar is indeterminate.
+ ///
+ public bool IsIndeterminate { get; set; }
- ///
- /// Initializes a new instance of the class.
- ///
- private AdaptiveProgressBarValue()
- {
- }
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ private AdaptiveProgressBarValue()
+ {
+ }
- internal string ToXmlString()
+ internal string ToXmlString()
+ {
+ if (IsIndeterminate)
{
- if (IsIndeterminate)
- {
- return "indeterminate";
- }
-
- if (BindingName != null)
- {
- return "{" + BindingName + "}";
- }
-
- return Value.ToString();
+ return "indeterminate";
}
- ///
- /// Gets an indeterminate progress bar value.
- ///
- public static AdaptiveProgressBarValue Indeterminate
+ if (BindingName != null)
{
- get
- {
- return new AdaptiveProgressBarValue()
- {
- IsIndeterminate = true
- };
- }
+ return "{" + BindingName + "}";
}
- ///
- /// Returns a progress bar value using the specified value (0-1) representing the percent complete.
- ///
- /// The value, 0-1, inclusive.
- /// A progress bar value.
- public static AdaptiveProgressBarValue FromValue(double d)
- {
- if (d < 0 || d > 1)
- {
- throw new ArgumentOutOfRangeException("d", "Value must be between 0 and 1, inclusive.");
- }
+ return Value.ToString();
+ }
+ ///
+ /// Gets an indeterminate progress bar value.
+ ///
+ public static AdaptiveProgressBarValue Indeterminate
+ {
+ get
+ {
return new AdaptiveProgressBarValue()
{
- Value = d
+ IsIndeterminate = true
};
}
+ }
- ///
- /// Returns a progress bar value using the specified binding name.
- ///
- /// The property to bind to.
- /// A progress bar value.
- public static AdaptiveProgressBarValue FromBinding(string bindingName)
+ ///
+ /// Returns a progress bar value using the specified value (0-1) representing the percent complete.
+ ///
+ /// The value, 0-1, inclusive.
+ /// A progress bar value.
+ public static AdaptiveProgressBarValue FromValue(double d)
+ {
+ if (d < 0 || d > 1)
{
- return new AdaptiveProgressBarValue()
- {
- BindingName = bindingName
- };
+ throw new ArgumentOutOfRangeException("d", "Value must be between 0 and 1, inclusive.");
}
+
+ return new AdaptiveProgressBarValue()
+ {
+ Value = d
+ };
+ }
+
+ ///
+ /// Returns a progress bar value using the specified binding name.
+ ///
+ /// The property to bind to.
+ /// A progress bar value.
+ public static AdaptiveProgressBarValue FromBinding(string bindingName)
+ {
+ return new AdaptiveProgressBarValue()
+ {
+ BindingName = bindingName
+ };
}
}
\ No newline at end of file
diff --git a/components/Notifications/src/Adaptive/AdaptiveSubgroup.cs b/components/Notifications/src/Adaptive/AdaptiveSubgroup.cs
index 9a136c843..7db375bb6 100644
--- a/components/Notifications/src/Adaptive/AdaptiveSubgroup.cs
+++ b/components/Notifications/src/Adaptive/AdaptiveSubgroup.cs
@@ -6,72 +6,71 @@
using System.Collections.Generic;
using CommunityToolkit.Notifications.Adaptive.Elements;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// Subgroups are vertical columns that can contain text and images. Supported on Tiles since RTM. Supported on Toasts since Anniversary Update.
+///
+public sealed class AdaptiveSubgroup
{
///
- /// Subgroups are vertical columns that can contain text and images. Supported on Tiles since RTM. Supported on Toasts since Anniversary Update.
+ /// Gets a list of Children. and are valid children of subgroups.
///
- public sealed class AdaptiveSubgroup
- {
- ///
- /// Gets a list of Children. and are valid children of subgroups.
- ///
- public IList Children { get; private set; } = new List();
+ public IList Children { get; private set; } = new List();
- private int? _hintWeight;
+ private int? _hintWeight;
- ///
- /// Gets or sets the width of this subgroup column by specifying the weight, relative to the other subgroups.
- ///
- public int? HintWeight
+ ///
+ /// Gets or sets the width of this subgroup column by specifying the weight, relative to the other subgroups.
+ ///
+ public int? HintWeight
+ {
+ get
{
- get
- {
- return _hintWeight;
- }
+ return _hintWeight;
+ }
- set
- {
- Element_AdaptiveSubgroup.CheckWeight(value);
+ set
+ {
+ Element_AdaptiveSubgroup.CheckWeight(value);
- _hintWeight = value;
- }
+ _hintWeight = value;
}
+ }
+
+ ///
+ /// Gets or sets the vertical alignment of this subgroup's content.
+ ///
+ public AdaptiveSubgroupTextStacking HintTextStacking { get; set; } = Element_AdaptiveSubgroup.DEFAULT_TEXT_STACKING;
- ///
- /// Gets or sets the vertical alignment of this subgroup's content.
- ///
- public AdaptiveSubgroupTextStacking HintTextStacking { get; set; } = Element_AdaptiveSubgroup.DEFAULT_TEXT_STACKING;
+ internal Element_AdaptiveSubgroup ConvertToElement()
+ {
+ var subgroup = new Element_AdaptiveSubgroup()
+ {
+ Weight = HintWeight,
+ TextStacking = HintTextStacking
+ };
- internal Element_AdaptiveSubgroup ConvertToElement()
+ foreach (var child in Children)
{
- var subgroup = new Element_AdaptiveSubgroup()
- {
- Weight = HintWeight,
- TextStacking = HintTextStacking
- };
+ subgroup.Children.Add(ConvertToSubgroupChildElement(child));
+ }
- foreach (var child in Children)
- {
- subgroup.Children.Add(ConvertToSubgroupChildElement(child));
- }
+ return subgroup;
+ }
- return subgroup;
+ private static IElement_AdaptiveSubgroupChild ConvertToSubgroupChildElement(IAdaptiveSubgroupChild child)
+ {
+ if (child is AdaptiveText)
+ {
+ return (child as AdaptiveText).ConvertToElement();
}
- private static IElement_AdaptiveSubgroupChild ConvertToSubgroupChildElement(IAdaptiveSubgroupChild child)
+ if (child is AdaptiveImage)
{
- 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());
+ return (child as AdaptiveImage).ConvertToElement();
}
+
+ throw new NotImplementedException("Unknown child: " + child.GetType());
}
}
\ No newline at end of file
diff --git a/components/Notifications/src/Adaptive/AdaptiveSubgroupEnums.cs b/components/Notifications/src/Adaptive/AdaptiveSubgroupEnums.cs
index ce41b799c..d4d603b82 100644
--- a/components/Notifications/src/Adaptive/AdaptiveSubgroupEnums.cs
+++ b/components/Notifications/src/Adaptive/AdaptiveSubgroupEnums.cs
@@ -2,31 +2,30 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// TextStacking specifies the vertical alignment of content.
+///
+public enum AdaptiveSubgroupTextStacking
{
///
- /// TextStacking specifies the vertical alignment of content.
+ /// Renderer automatically selects the default vertical alignment.
///
- public enum AdaptiveSubgroupTextStacking
- {
- ///
- /// Renderer automatically selects the default vertical alignment.
- ///
- Default,
+ Default,
- ///
- /// Vertical align to the top.
- ///
- Top,
+ ///
+ /// Vertical align to the top.
+ ///
+ Top,
- ///
- /// Vertical align to the center.
- ///
- Center,
+ ///
+ /// Vertical align to the center.
+ ///
+ Center,
- ///
- /// Vertical align to the bottom.
- ///
- Bottom
- }
+ ///
+ /// Vertical align to the bottom.
+ ///
+ Bottom
}
\ No newline at end of file
diff --git a/components/Notifications/src/Adaptive/AdaptiveText.cs b/components/Notifications/src/Adaptive/AdaptiveText.cs
index 68775c9c0..6aa4df70b 100644
--- a/components/Notifications/src/Adaptive/AdaptiveText.cs
+++ b/components/Notifications/src/Adaptive/AdaptiveText.cs
@@ -8,126 +8,125 @@
using CommunityToolkit.Notifications.Adaptive.Elements;
using BindableString = CommunityToolkit.Notifications.BindableString;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// An adaptive text element.
+///
+public sealed class AdaptiveText
+ : IAdaptiveChild,
+ IAdaptiveSubgroupChild,
+ ITileBindingContentAdaptiveChild,
+ IToastBindingGenericChild
{
///
- /// An adaptive text element.
+ /// Gets or sets the text to display. Data binding support added in Creators Update,
+ /// only works for toast top-level text elements.
///
- public sealed class AdaptiveText
- : IAdaptiveChild,
- IAdaptiveSubgroupChild,
- ITileBindingContentAdaptiveChild,
- IToastBindingGenericChild
+ public BindableString Text { get; set; }
+
+ ///
+ /// Gets or sets 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.
+ ///
+ public string Language { get; set; }
+
+ ///
+ /// Gets or sets the style that 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 .
+ ///
+ public AdaptiveTextStyle HintStyle { get; set; }
+
+ ///
+ /// Gets or sets a value whether text wrapping is enabled. For Tiles, this is false by default.
+ /// For Toasts, this is true on top-level text elements, and false inside an .
+ /// Note that for Toast, setting wrap will only take effect if the text is inside an
+ /// (you can use HintMaxLines = 1 to prevent top-level text elements from wrapping).
+ ///
+ public bool? HintWrap { get; set; }
+
+ private int? _hintMaxLines;
+
+ ///
+ /// Gets or sets 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 will behave identically to Tiles (default to infinity).
+ ///
+ public int? HintMaxLines
{
- ///
- /// Gets or sets the text to display. Data binding support added in Creators Update,
- /// only works for toast top-level text elements.
- ///
- public BindableString Text { get; set; }
-
- ///
- /// Gets or sets 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.
- ///
- public string Language { get; set; }
-
- ///
- /// Gets or sets the style that 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 .
- ///
- public AdaptiveTextStyle HintStyle { get; set; }
-
- ///
- /// Gets or sets a value whether text wrapping is enabled. For Tiles, this is false by default.
- /// For Toasts, this is true on top-level text elements, and false inside an .
- /// Note that for Toast, setting wrap will only take effect if the text is inside an
- /// (you can use HintMaxLines = 1 to prevent top-level text elements from wrapping).
- ///
- public bool? HintWrap { get; set; }
-
- private int? _hintMaxLines;
-
- ///
- /// Gets or sets 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 will behave identically to Tiles (default to infinity).
- ///
- public int? HintMaxLines
+ get
{
- get
- {
- return _hintMaxLines;
- }
+ return _hintMaxLines;
+ }
- set
+ set
+ {
+ if (value != null)
{
- if (value != null)
- {
- Element_AdaptiveText.CheckMaxLinesValue(value.Value);
- }
-
- _hintMaxLines = value;
+ Element_AdaptiveText.CheckMaxLinesValue(value.Value);
}
+
+ _hintMaxLines = value;
}
+ }
- private int? _hintMinLines;
+ private int? _hintMinLines;
- ///
- /// Gets or sets 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 .
- ///
- public int? HintMinLines
+ ///
+ /// Gets or sets 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 .
+ ///
+ public int? HintMinLines
+ {
+ get
{
- get
- {
- return _hintMinLines;
- }
+ return _hintMinLines;
+ }
- set
+ set
+ {
+ if (value != null)
{
- if (value != null)
- {
- Element_AdaptiveText.CheckMinLinesValue(value.Value);
- }
-
- _hintMinLines = value;
+ Element_AdaptiveText.CheckMinLinesValue(value.Value);
}
+
+ _hintMinLines = value;
}
+ }
- ///
- /// Gets or sets the horizontal alignment of the text. Note that for Toast, this property will
- /// only take effect if the text is inside an .
- ///
- public AdaptiveTextAlign HintAlign { get; set; }
+ ///
+ /// Gets or sets the horizontal alignment of the text. Note that for Toast, this property will
+ /// only take effect if the text is inside an .
+ ///
+ public AdaptiveTextAlign HintAlign { get; set; }
- internal Element_AdaptiveText ConvertToElement()
+ internal Element_AdaptiveText ConvertToElement()
+ {
+ var answer = new Element_AdaptiveText()
{
- var answer = new Element_AdaptiveText()
- {
- Lang = Language,
- Style = HintStyle,
- Wrap = HintWrap,
- MaxLines = HintMaxLines,
- MinLines = HintMinLines,
- Align = HintAlign
- };
+ Lang = Language,
+ Style = HintStyle,
+ Wrap = HintWrap,
+ MaxLines = HintMaxLines,
+ MinLines = HintMinLines,
+ Align = HintAlign
+ };
- answer.Text = Text?.ToXmlString();
+ answer.Text = Text?.ToXmlString();
- return answer;
- }
+ return answer;
+ }
- ///
- /// Returns the value of the Text property.
- ///
- /// The value of the Text property.
- public override string ToString()
- {
- return Text;
- }
+ ///
+ /// Returns the value of the Text property.
+ ///
+ /// The value of the Text property.
+ public override string ToString()
+ {
+ return Text;
}
}
diff --git a/components/Notifications/src/Adaptive/AdaptiveTextEnums.cs b/components/Notifications/src/Adaptive/AdaptiveTextEnums.cs
index 60eb0d72e..4634f925f 100644
--- a/components/Notifications/src/Adaptive/AdaptiveTextEnums.cs
+++ b/components/Notifications/src/Adaptive/AdaptiveTextEnums.cs
@@ -2,141 +2,140 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// Text style controls font size, weight, and opacity.
+///
+public enum AdaptiveTextStyle
{
///
- /// Text style controls font size, weight, and opacity.
- ///
- public enum AdaptiveTextStyle
- {
- ///
- /// Style is determined by the renderer.
- ///
- Default,
-
- ///
- /// Default value. Paragraph font size, normal weight and opacity.
- ///
- Caption,
-
- ///
- /// Same as Caption but with subtle opacity.
- ///
- CaptionSubtle,
-
- ///
- /// H5 font size.
- ///
- Body,
-
- ///
- /// Same as Body but with subtle opacity.
- ///
- BodySubtle,
-
- ///
- /// H5 font size, bold weight. Essentially the bold version of Body.
- ///
- Base,
-
- ///
- /// Same as Base but with subtle opacity.
- ///
- BaseSubtle,
-
- ///
- /// H4 font size.
- ///
- Subtitle,
-
- ///
- /// Same as Subtitle but with subtle opacity.
- ///
- SubtitleSubtle,
-
- ///
- /// H3 font size.
- ///
- Title,
-
- ///
- /// Same as Title but with subtle opacity.
- ///
- TitleSubtle,
-
- ///
- /// Same as Title but with top/bottom padding removed.
- ///
- TitleNumeral,
-
- ///
- /// H2 font size.
- ///
- Subheader,
-
- ///
- /// Same as Subheader but with subtle opacity.
- ///
- SubheaderSubtle,
-
- ///
- /// Same as Subheader but with top/bottom padding removed.
- ///
- SubheaderNumeral,
-
- ///
- /// H1 font size.
- ///
- Header,
-
- ///
- /// Same as Header but with subtle opacity.
- ///
- HeaderSubtle,
-
- ///
- /// Same as Header but with top/bottom padding removed.
- ///
- HeaderNumeral
- }
-
- ///
- /// Controls the horizontal alignment of text.
- ///
- public enum AdaptiveTextAlign
- {
- ///
- /// Alignment is automatically determined by
- ///
- Default,
-
- ///
- /// The system automatically decides the alignment based on the language and culture.
- ///
- Auto,
-
- ///
- /// Horizontally align the text to the left.
- ///
- Left,
-
- ///
- /// Horizontally align the text in the center.
- ///
- Center,
-
- ///
- /// Horizontally align the text to the right.
- ///
- Right
- }
-
- internal enum AdaptiveTextPlacement
- {
- ///
- /// Default value
- ///
- Inline,
- Attribution
- }
+ /// Style is determined by the renderer.
+ ///
+ Default,
+
+ ///
+ /// Default value. Paragraph font size, normal weight and opacity.
+ ///
+ Caption,
+
+ ///
+ /// Same as Caption but with subtle opacity.
+ ///
+ CaptionSubtle,
+
+ ///
+ /// H5 font size.
+ ///
+ Body,
+
+ ///
+ /// Same as Body but with subtle opacity.
+ ///
+ BodySubtle,
+
+ ///
+ /// H5 font size, bold weight. Essentially the bold version of Body.
+ ///
+ Base,
+
+ ///
+ /// Same as Base but with subtle opacity.
+ ///
+ BaseSubtle,
+
+ ///
+ /// H4 font size.
+ ///
+ Subtitle,
+
+ ///
+ /// Same as Subtitle but with subtle opacity.
+ ///
+ SubtitleSubtle,
+
+ ///
+ /// H3 font size.
+ ///
+ Title,
+
+ ///
+ /// Same as Title but with subtle opacity.
+ ///
+ TitleSubtle,
+
+ ///
+ /// Same as Title but with top/bottom padding removed.
+ ///
+ TitleNumeral,
+
+ ///
+ /// H2 font size.
+ ///
+ Subheader,
+
+ ///
+ /// Same as Subheader but with subtle opacity.
+ ///
+ SubheaderSubtle,
+
+ ///
+ /// Same as Subheader but with top/bottom padding removed.
+ ///
+ SubheaderNumeral,
+
+ ///
+ /// H1 font size.
+ ///
+ Header,
+
+ ///
+ /// Same as Header but with subtle opacity.
+ ///
+ HeaderSubtle,
+
+ ///
+ /// Same as Header but with top/bottom padding removed.
+ ///
+ HeaderNumeral
+}
+
+///
+/// Controls the horizontal alignment of text.
+///
+public enum AdaptiveTextAlign
+{
+ ///
+ /// Alignment is automatically determined by
+ ///
+ Default,
+
+ ///
+ /// The system automatically decides the alignment based on the language and culture.
+ ///
+ Auto,
+
+ ///
+ /// Horizontally align the text to the left.
+ ///
+ Left,
+
+ ///
+ /// Horizontally align the text in the center.
+ ///
+ Center,
+
+ ///
+ /// Horizontally align the text to the right.
+ ///
+ Right
+}
+
+internal enum AdaptiveTextPlacement
+{
+ ///
+ /// Default value
+ ///
+ Inline,
+ Attribution
}
\ No newline at end of file
diff --git a/components/Notifications/src/Adaptive/BaseImageHelper.cs b/components/Notifications/src/Adaptive/BaseImageHelper.cs
index 778aedbb1..a12e8a248 100644
--- a/components/Notifications/src/Adaptive/BaseImageHelper.cs
+++ b/components/Notifications/src/Adaptive/BaseImageHelper.cs
@@ -5,33 +5,32 @@
using System;
using CommunityToolkit.Notifications.Adaptive.Elements;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+internal static class BaseImageHelper
{
- internal static class BaseImageHelper
+ internal static void SetSource(ref string destination, string value)
{
- internal static void SetSource(ref string destination, string value)
+ if (value == null)
{
- if (value == null)
- {
- throw new ArgumentNullException(nameof(value));
- }
-
- destination = value;
+ throw new ArgumentNullException(nameof(value));
}
- internal static Element_AdaptiveImage CreateBaseElement(IBaseImage current)
- {
- if (current.Source == null)
- {
- throw new NullReferenceException("Source property is required.");
- }
+ destination = value;
+ }
- return new Element_AdaptiveImage()
- {
- Src = current.Source,
- Alt = current.AlternateText,
- AddImageQuery = current.AddImageQuery
- };
+ internal static Element_AdaptiveImage CreateBaseElement(IBaseImage current)
+ {
+ if (current.Source == null)
+ {
+ throw new NullReferenceException("Source property is required.");
}
+
+ return new Element_AdaptiveImage()
+ {
+ Src = current.Source,
+ Alt = current.AlternateText,
+ AddImageQuery = current.AddImageQuery
+ };
}
}
\ No newline at end of file
diff --git a/components/Notifications/src/Adaptive/BaseTextHelper.cs b/components/Notifications/src/Adaptive/BaseTextHelper.cs
index a65f43d93..64ef2ca90 100644
--- a/components/Notifications/src/Adaptive/BaseTextHelper.cs
+++ b/components/Notifications/src/Adaptive/BaseTextHelper.cs
@@ -4,17 +4,16 @@
using CommunityToolkit.Notifications.Adaptive.Elements;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+internal class BaseTextHelper
{
- internal class BaseTextHelper
+ internal static Element_AdaptiveText CreateBaseElement(IBaseText current)
{
- internal static Element_AdaptiveText CreateBaseElement(IBaseText current)
+ return new Element_AdaptiveText()
{
- return new Element_AdaptiveText()
- {
- Text = current.Text,
- Lang = current.Language
- };
- }
+ Text = current.Text,
+ Lang = current.Language
+ };
}
}
\ No newline at end of file
diff --git a/components/Notifications/src/Adaptive/BindableValues/BindableProgressBarValue.cs b/components/Notifications/src/Adaptive/BindableValues/BindableProgressBarValue.cs
index 1e84cb3f9..895368950 100644
--- a/components/Notifications/src/Adaptive/BindableValues/BindableProgressBarValue.cs
+++ b/components/Notifications/src/Adaptive/BindableValues/BindableProgressBarValue.cs
@@ -2,87 +2,86 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// A binding value for doubles.
+///
+public sealed class BindableProgressBarValue
{
///
- /// A binding value for doubles.
+ /// Gets raw value 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.
///
- public sealed class BindableProgressBarValue
- {
- ///
- /// Gets raw value 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.
- ///
- internal AdaptiveProgressBarValue RawValue { get; private set; }
+ internal AdaptiveProgressBarValue RawValue { get; private set; }
- internal bool RawIsIndeterminate { get; private set; }
+ internal bool RawIsIndeterminate { get; private set; }
- ///
- /// Gets or sets the name that maps to your binding data value.
- ///
- public string BindingName { get; set; }
+ ///
+ /// Gets or sets the name that maps to your binding data value.
+ ///
+ public string BindingName { get; set; }
- ///
- /// Initializes a new instance of the class.
- /// A new binding for a double value, with the required binding value name. Do NOT include surrounding {} brackets.
- ///
- /// The name that maps to your binding data value.
- public BindableProgressBarValue(string bindingName)
- {
- BindingName = bindingName;
- }
+ ///
+ /// Initializes a new instance of the class.
+ /// A new binding for a double value, with the required binding value name. Do NOT include surrounding {} brackets.
+ ///
+ /// The name that maps to your binding data value.
+ public BindableProgressBarValue(string bindingName)
+ {
+ BindingName = bindingName;
+ }
- ///
- /// Initializes a new instance of the class.
- /// Private constructor used by the implicit converter to assign the raw value.
- ///
- private BindableProgressBarValue()
- {
- }
+ ///
+ /// Initializes a new instance of the class.
+ /// Private constructor used by the implicit converter to assign the raw value.
+ ///
+ private BindableProgressBarValue()
+ {
+ }
- internal string ToXmlString()
+ internal string ToXmlString()
+ {
+ if (BindingName != null)
{
- if (BindingName != null)
- {
- return "{" + BindingName + "}";
- }
-
- if (RawValue != null)
- {
- return RawValue.ToXmlString();
- }
-
- return null;
+ return "{" + BindingName + "}";
}
- ///
- /// Creates a that has a raw value assigned.
- ///
- /// The raw value
- public static implicit operator BindableProgressBarValue(AdaptiveProgressBarValue v)
+ if (RawValue != null)
{
- return new BindableProgressBarValue()
- {
- RawValue = v
- };
+ return RawValue.ToXmlString();
}
- ///
- /// Returns the raw value of the .
- ///
- /// The to obtain the raw value from.
- public static implicit operator AdaptiveProgressBarValue(BindableProgressBarValue b)
- {
- return b.RawValue;
- }
+ return null;
+ }
- ///
- /// Creates an that has the raw double value.
- ///
- /// The raw value
- public static implicit operator BindableProgressBarValue(double d)
+ ///
+ /// Creates a that has a raw value assigned.
+ ///
+ /// The raw value
+ public static implicit operator BindableProgressBarValue(AdaptiveProgressBarValue v)
+ {
+ return new BindableProgressBarValue()
{
- return AdaptiveProgressBarValue.FromValue(d);
- }
+ RawValue = v
+ };
+ }
+
+ ///
+ /// Returns the raw value of the .
+ ///
+ /// The to obtain the raw value from.
+ public static implicit operator AdaptiveProgressBarValue(BindableProgressBarValue b)
+ {
+ return b.RawValue;
+ }
+
+ ///
+ /// Creates an that has the raw double value.
+ ///
+ /// The raw value
+ public static implicit operator BindableProgressBarValue(double d)
+ {
+ return AdaptiveProgressBarValue.FromValue(d);
}
}
diff --git a/components/Notifications/src/Adaptive/BindableValues/BindableString.cs b/components/Notifications/src/Adaptive/BindableValues/BindableString.cs
index 97849d70e..ad48f116f 100644
--- a/components/Notifications/src/Adaptive/BindableValues/BindableString.cs
+++ b/components/Notifications/src/Adaptive/BindableValues/BindableString.cs
@@ -2,67 +2,66 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// A binding value for strings.
+///
+public sealed class BindableString
{
+ internal string RawValue { get; private set; }
+
///
- /// A binding value for strings.
+ /// Gets or sets the name that maps to your binding data value.
///
- public sealed class BindableString
- {
- internal string RawValue { get; private set; }
+ public string BindingName { get; set; }
- ///
- /// Gets or sets the name that maps to your binding data value.
- ///
- public string BindingName { get; set; }
+ ///
+ /// Initializes a new instance of the class.
+ /// A new binding for a string value, with the required binding name. Do NOT include surrounding {} brackets.
+ ///
+ /// The name that maps to your data binding value.
+ public BindableString(string bindingName)
+ {
+ BindingName = bindingName;
+ }
- ///
- /// Initializes a new instance of the class.
- /// A new binding for a string value, with the required binding name. Do NOT include surrounding {} brackets.
- ///
- /// The name that maps to your data binding value.
- public BindableString(string bindingName)
- {
- BindingName = bindingName;
- }
+ ///
+ /// Initializes a new instance of the class.
+ /// Private constructor used by the implicit converter to assign the raw value.
+ ///
+ private BindableString()
+ {
+ }
- ///
- /// Initializes a new instance of the class.
- /// Private constructor used by the implicit converter to assign the raw value.
- ///
- private BindableString()
+ internal string ToXmlString()
+ {
+ if (BindingName != null)
{
+ return "{" + BindingName + "}";
}
- internal string ToXmlString()
- {
- if (BindingName != null)
- {
- return "{" + BindingName + "}";
- }
-
- return RawValue;
- }
+ return RawValue;
+ }
- ///
- /// Creates a that has a raw value assigned.
- ///
- /// The raw value
- public static implicit operator BindableString(string d)
+ ///
+ /// Creates a that has a raw value assigned.
+ ///
+ /// The raw value
+ public static implicit operator BindableString(string d)
+ {
+ return new BindableString()
{
- return new BindableString()
- {
- RawValue = d
- };
- }
+ RawValue = d
+ };
+ }
- ///
- /// Returns the raw value of the .
- ///
- /// The to obtain the raw value from.
- public static implicit operator string(BindableString b)
- {
- return b.RawValue;
- }
+ ///
+ /// Returns the raw value of the .
+ ///
+ /// The to obtain the raw value from.
+ public static implicit operator string(BindableString b)
+ {
+ return b.RawValue;
}
}
diff --git a/components/Notifications/src/Adaptive/Elements/Element_AdaptiveGroup.cs b/components/Notifications/src/Adaptive/Elements/Element_AdaptiveGroup.cs
index 339ca0a03..974d687a8 100644
--- a/components/Notifications/src/Adaptive/Elements/Element_AdaptiveGroup.cs
+++ b/components/Notifications/src/Adaptive/Elements/Element_AdaptiveGroup.cs
@@ -4,31 +4,30 @@
using System.Collections.Generic;
-namespace CommunityToolkit.Notifications.Adaptive.Elements
+namespace CommunityToolkit.Notifications.Adaptive.Elements;
+
+internal sealed class Element_AdaptiveGroup : IElement_TileBindingChild, IElement_ToastBindingChild, IElementWithDescendants, IHaveXmlName, IHaveXmlChildren
{
- internal sealed class Element_AdaptiveGroup : IElement_TileBindingChild, IElement_ToastBindingChild, IElementWithDescendants, IHaveXmlName, IHaveXmlChildren
- {
- public IList Children { get; private set; } = new List();
+ public IList Children { get; private set; } = new List();
- public IEnumerable Descendants()
+ public IEnumerable Descendants()
+ {
+ foreach (Element_AdaptiveSubgroup subgroup in Children)
{
- foreach (Element_AdaptiveSubgroup subgroup in Children)
- {
- // Return the subgroup
- yield return subgroup;
+ // Return the subgroup
+ yield return subgroup;
- // And also return its descendants
- foreach (object descendant in subgroup.Descendants())
- {
- yield return descendant;
- }
+ // And also return its descendants
+ foreach (object descendant in subgroup.Descendants())
+ {
+ yield return descendant;
}
}
+ }
- ///
- string IHaveXmlName.Name => "group";
+ ///
+ string IHaveXmlName.Name => "group";
- ///
- IEnumerable IHaveXmlChildren.Children => Children;
- }
+ ///
+ IEnumerable IHaveXmlChildren.Children => Children;
}
\ No newline at end of file
diff --git a/components/Notifications/src/Adaptive/Elements/Element_AdaptiveImage.cs b/components/Notifications/src/Adaptive/Elements/Element_AdaptiveImage.cs
index 3ffe0b0f5..337a02817 100644
--- a/components/Notifications/src/Adaptive/Elements/Element_AdaptiveImage.cs
+++ b/components/Notifications/src/Adaptive/Elements/Element_AdaptiveImage.cs
@@ -4,90 +4,89 @@
using System.Collections.Generic;
-namespace CommunityToolkit.Notifications.Adaptive.Elements
+namespace CommunityToolkit.Notifications.Adaptive.Elements;
+
+internal sealed class Element_AdaptiveImage : IElement_TileBindingChild, IElement_ToastBindingChild, IElement_AdaptiveSubgroupChild, IHaveXmlName, IHaveXmlNamedProperties
{
- internal sealed class Element_AdaptiveImage : IElement_TileBindingChild, IElement_ToastBindingChild, IElement_AdaptiveSubgroupChild, IHaveXmlName, IHaveXmlNamedProperties
- {
- internal const AdaptiveImagePlacement DEFAULT_PLACEMENT = AdaptiveImagePlacement.Inline;
- internal const AdaptiveImageCrop DEFAULT_CROP = AdaptiveImageCrop.Default;
- internal const AdaptiveImageAlign DEFAULT_ALIGN = AdaptiveImageAlign.Default;
+ internal const AdaptiveImagePlacement DEFAULT_PLACEMENT = AdaptiveImagePlacement.Inline;
+ internal const AdaptiveImageCrop DEFAULT_CROP = AdaptiveImageCrop.Default;
+ internal const AdaptiveImageAlign DEFAULT_ALIGN = AdaptiveImageAlign.Default;
- public int? Id { get; set; }
+ public int? Id { get; set; }
- public string Src { get; set; }
+ public string Src { get; set; }
- public string Alt { get; set; }
+ public string Alt { get; set; }
- public bool? AddImageQuery { get; set; }
+ public bool? AddImageQuery { get; set; }
- public AdaptiveImagePlacement Placement { get; set; } = DEFAULT_PLACEMENT;
+ public AdaptiveImagePlacement Placement { get; set; } = DEFAULT_PLACEMENT;
- public AdaptiveImageAlign Align { get; set; } = DEFAULT_ALIGN;
+ public AdaptiveImageAlign Align { get; set; } = DEFAULT_ALIGN;
- public AdaptiveImageCrop Crop { get; set; } = DEFAULT_CROP;
+ public AdaptiveImageCrop Crop { get; set; } = DEFAULT_CROP;
- public bool? RemoveMargin { get; set; }
+ public bool? RemoveMargin { get; set; }
- private int? _overlay;
+ private int? _overlay;
- public int? Overlay
+ public int? Overlay
+ {
+ get
{
- get
- {
- return _overlay;
- }
+ return _overlay;
+ }
- set
+ set
+ {
+ if (value != null)
{
- if (value != null)
- {
- Element_TileBinding.CheckOverlayValue(value.Value);
- }
-
- _overlay = value;
+ Element_TileBinding.CheckOverlayValue(value.Value);
}
- }
- public string SpriteSheetSrc { get; set; }
+ _overlay = value;
+ }
+ }
- public uint? SpriteSheetHeight { get; set; }
+ public string SpriteSheetSrc { get; set; }
- public uint? SpriteSheetFps { get; set; }
+ public uint? SpriteSheetHeight { get; set; }
- public uint? SpriteSheetStartingFrame { get; set; }
+ public uint? SpriteSheetFps { get; set; }
- ///
- string IHaveXmlName.Name => "image";
+ public uint? SpriteSheetStartingFrame { get; set; }
- ///
- IEnumerable> IHaveXmlNamedProperties.EnumerateNamedProperties()
- {
- yield return new("id", Id);
- yield return new("src", Src);
- yield return new("alt", Alt);
- yield return new("addImageQuery", AddImageQuery);
+ ///
+ string IHaveXmlName.Name => "image";
- if (Placement != DEFAULT_PLACEMENT)
- {
- yield return new("placement", Placement.ToPascalCaseString());
- }
+ ///
+ IEnumerable> IHaveXmlNamedProperties.EnumerateNamedProperties()
+ {
+ yield return new("id", Id);
+ yield return new("src", Src);
+ yield return new("alt", Alt);
+ yield return new("addImageQuery", AddImageQuery);
- if (Align != DEFAULT_ALIGN)
- {
- yield return new("hint-align", Align.ToPascalCaseString());
- }
+ if (Placement != DEFAULT_PLACEMENT)
+ {
+ yield return new("placement", Placement.ToPascalCaseString());
+ }
- if (Crop != DEFAULT_CROP)
- {
- yield return new("hint-crop", Crop.ToPascalCaseString());
- }
+ if (Align != DEFAULT_ALIGN)
+ {
+ yield return new("hint-align", Align.ToPascalCaseString());
+ }
- yield return new("hint-removeMargin", RemoveMargin);
- yield return new("hint-overlay", Overlay);
- yield return new("spritesheet-src", SpriteSheetSrc);
- yield return new("spritesheet-height", SpriteSheetHeight);
- yield return new("spritesheet-fps", SpriteSheetFps);
- yield return new("spritesheet-startingFrame", SpriteSheetStartingFrame);
+ if (Crop != DEFAULT_CROP)
+ {
+ yield return new("hint-crop", Crop.ToPascalCaseString());
}
+
+ yield return new("hint-removeMargin", RemoveMargin);
+ yield return new("hint-overlay", Overlay);
+ yield return new("spritesheet-src", SpriteSheetSrc);
+ yield return new("spritesheet-height", SpriteSheetHeight);
+ yield return new("spritesheet-fps", SpriteSheetFps);
+ yield return new("spritesheet-startingFrame", SpriteSheetStartingFrame);
}
}
\ No newline at end of file
diff --git a/components/Notifications/src/Adaptive/Elements/Element_AdaptiveImageEnums.cs b/components/Notifications/src/Adaptive/Elements/Element_AdaptiveImageEnums.cs
index e817f880c..6ea77275c 100644
--- a/components/Notifications/src/Adaptive/Elements/Element_AdaptiveImageEnums.cs
+++ b/components/Notifications/src/Adaptive/Elements/Element_AdaptiveImageEnums.cs
@@ -2,14 +2,13 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-namespace CommunityToolkit.Notifications.Adaptive.Elements
+namespace CommunityToolkit.Notifications.Adaptive.Elements;
+
+internal enum AdaptiveImagePlacement
{
- internal enum AdaptiveImagePlacement
- {
- Inline,
- Background,
- Peek,
- Hero,
- AppLogoOverride
- }
+ Inline,
+ Background,
+ Peek,
+ Hero,
+ AppLogoOverride
}
\ No newline at end of file
diff --git a/components/Notifications/src/Adaptive/Elements/Element_AdaptiveProgressBar.cs b/components/Notifications/src/Adaptive/Elements/Element_AdaptiveProgressBar.cs
index d26e96ee4..4a5da6a19 100644
--- a/components/Notifications/src/Adaptive/Elements/Element_AdaptiveProgressBar.cs
+++ b/components/Notifications/src/Adaptive/Elements/Element_AdaptiveProgressBar.cs
@@ -4,28 +4,27 @@
using System.Collections.Generic;
-namespace CommunityToolkit.Notifications.Adaptive.Elements
+namespace CommunityToolkit.Notifications.Adaptive.Elements;
+
+internal sealed class Element_AdaptiveProgressBar : IElement_ToastBindingChild, IHaveXmlName, IHaveXmlNamedProperties
{
- internal sealed class Element_AdaptiveProgressBar : IElement_ToastBindingChild, IHaveXmlName, IHaveXmlNamedProperties
- {
- public string Value { get; set; }
+ public string Value { get; set; }
- public string Title { get; set; }
+ public string Title { get; set; }
- public string ValueStringOverride { get; set; }
+ public string ValueStringOverride { get; set; }
- public string Status { get; set; }
+ public string Status { get; set; }
- ///
- string IHaveXmlName.Name => "progress";
+ ///
+ string IHaveXmlName.Name => "progress";
- ///
- IEnumerable> IHaveXmlNamedProperties.EnumerateNamedProperties()
- {
- yield return new("value", Value);
- yield return new("title", Title);
- yield return new("valueStringOverride", ValueStringOverride);
- yield return new("status", Status);
- }
+ ///
+ IEnumerable> IHaveXmlNamedProperties.EnumerateNamedProperties()
+ {
+ yield return new("value", Value);
+ yield return new("title", Title);
+ yield return new("valueStringOverride", ValueStringOverride);
+ yield return new("status", Status);
}
}
\ No newline at end of file
diff --git a/components/Notifications/src/Adaptive/Elements/Element_AdaptiveSubgroup.cs b/components/Notifications/src/Adaptive/Elements/Element_AdaptiveSubgroup.cs
index be3a0953c..2d85be283 100644
--- a/components/Notifications/src/Adaptive/Elements/Element_AdaptiveSubgroup.cs
+++ b/components/Notifications/src/Adaptive/Elements/Element_AdaptiveSubgroup.cs
@@ -5,69 +5,68 @@
using System;
using System.Collections.Generic;
-namespace CommunityToolkit.Notifications.Adaptive.Elements
+namespace CommunityToolkit.Notifications.Adaptive.Elements;
+
+internal sealed class Element_AdaptiveSubgroup : IElementWithDescendants, IHaveXmlName, IHaveXmlNamedProperties, IHaveXmlChildren
{
- internal sealed class Element_AdaptiveSubgroup : IElementWithDescendants, IHaveXmlName, IHaveXmlNamedProperties, IHaveXmlChildren
- {
- internal const AdaptiveSubgroupTextStacking DEFAULT_TEXT_STACKING = AdaptiveSubgroupTextStacking.Default;
+ internal const AdaptiveSubgroupTextStacking DEFAULT_TEXT_STACKING = AdaptiveSubgroupTextStacking.Default;
- public AdaptiveSubgroupTextStacking TextStacking { get; set; } = DEFAULT_TEXT_STACKING;
+ public AdaptiveSubgroupTextStacking TextStacking { get; set; } = DEFAULT_TEXT_STACKING;
- private int? _weight;
+ private int? _weight;
- public int? Weight
+ public int? Weight
+ {
+ get
{
- get
- {
- return _weight;
- }
+ return _weight;
+ }
- set
- {
- CheckWeight(value);
+ set
+ {
+ CheckWeight(value);
- _weight = value;
- }
+ _weight = value;
}
+ }
- internal static void CheckWeight(int? weight)
+ internal static void CheckWeight(int? weight)
+ {
+ if (weight != null && weight.Value < 1)
{
- if (weight != null && weight.Value < 1)
- {
- throw new ArgumentOutOfRangeException("Weight must be between 1 and int.MaxValue, inclusive (or null)");
- }
+ throw new ArgumentOutOfRangeException("Weight must be between 1 and int.MaxValue, inclusive (or null)");
}
+ }
- public IList Children { get; private set; } = new List();
+ public IList Children { get; private set; } = new List();
- public IEnumerable Descendants()
+ public IEnumerable Descendants()
+ {
+ foreach (IElement_AdaptiveSubgroupChild child in Children)
{
- foreach (IElement_AdaptiveSubgroupChild child in Children)
- {
- // Return each child (we know there's no further descendants)
- yield return child;
- }
+ // Return each child (we know there's no further descendants)
+ yield return child;
}
+ }
- ///
- string IHaveXmlName.Name => "subgroup";
+ ///
+ string IHaveXmlName.Name => "subgroup";
- ///
- IEnumerable IHaveXmlChildren.Children => Children;
+ ///
+ IEnumerable IHaveXmlChildren.Children => Children;
- ///
- IEnumerable> IHaveXmlNamedProperties.EnumerateNamedProperties()
+ ///
+ IEnumerable> IHaveXmlNamedProperties.EnumerateNamedProperties()
+ {
+ if (TextStacking != DEFAULT_TEXT_STACKING)
{
- if (TextStacking != DEFAULT_TEXT_STACKING)
- {
- yield return new("hint-textStacking", TextStacking.ToPascalCaseString());
- }
-
- yield return new("hint-weight", Weight);
+ yield return new("hint-textStacking", TextStacking.ToPascalCaseString());
}
- }
- internal interface IElement_AdaptiveSubgroupChild
- {
+ yield return new("hint-weight", Weight);
}
+}
+
+internal interface IElement_AdaptiveSubgroupChild
+{
}
\ No newline at end of file
diff --git a/components/Notifications/src/Adaptive/Elements/Element_AdaptiveText.cs b/components/Notifications/src/Adaptive/Elements/Element_AdaptiveText.cs
index 4b87fe9cb..f689d8080 100644
--- a/components/Notifications/src/Adaptive/Elements/Element_AdaptiveText.cs
+++ b/components/Notifications/src/Adaptive/Elements/Element_AdaptiveText.cs
@@ -5,112 +5,111 @@
using System;
using System.Collections.Generic;
-namespace CommunityToolkit.Notifications.Adaptive.Elements
+namespace CommunityToolkit.Notifications.Adaptive.Elements;
+
+internal sealed class Element_AdaptiveText : IElement_TileBindingChild, IElement_AdaptiveSubgroupChild, IElement_ToastBindingChild, IHaveXmlName, IHaveXmlNamedProperties, IHaveXmlText
{
- internal sealed class Element_AdaptiveText : IElement_TileBindingChild, IElement_AdaptiveSubgroupChild, IElement_ToastBindingChild, IHaveXmlName, IHaveXmlNamedProperties, IHaveXmlText
- {
- internal const AdaptiveTextStyle DEFAULT_STYLE = AdaptiveTextStyle.Default;
- internal const AdaptiveTextAlign DEFAULT_ALIGN = AdaptiveTextAlign.Default;
- internal const AdaptiveTextPlacement DEFAULT_PLACEMENT = AdaptiveTextPlacement.Inline;
+ internal const AdaptiveTextStyle DEFAULT_STYLE = AdaptiveTextStyle.Default;
+ internal const AdaptiveTextAlign DEFAULT_ALIGN = AdaptiveTextAlign.Default;
+ internal const AdaptiveTextPlacement DEFAULT_PLACEMENT = AdaptiveTextPlacement.Inline;
- public string Text { get; set; }
+ public string Text { get; set; }
- public int? Id { get; set; }
+ public int? Id { get; set; }
- public string Lang { get; set; }
+ public string Lang { get; set; }
- public AdaptiveTextAlign Align { get; set; } = DEFAULT_ALIGN;
+ public AdaptiveTextAlign Align { get; set; } = DEFAULT_ALIGN;
- private int? _maxLines;
+ private int? _maxLines;
- public int? MaxLines
+ public int? MaxLines
+ {
+ get
{
- get
- {
- return _maxLines;
- }
+ return _maxLines;
+ }
- set
+ set
+ {
+ if (value != null)
{
- if (value != null)
- {
- CheckMaxLinesValue(value.Value);
- }
-
- _maxLines = value;
+ CheckMaxLinesValue(value.Value);
}
+
+ _maxLines = value;
}
+ }
- internal static void CheckMaxLinesValue(int value)
+ internal static void CheckMaxLinesValue(int value)
+ {
+ if (value < 1)
{
- if (value < 1)
- {
- throw new ArgumentOutOfRangeException("MaxLines must be between 1 and int.MaxValue, inclusive.");
- }
+ throw new ArgumentOutOfRangeException("MaxLines must be between 1 and int.MaxValue, inclusive.");
}
+ }
- private int? _minLines;
+ private int? _minLines;
- public int? MinLines
+ public int? MinLines
+ {
+ get
{
- get
- {
- return _minLines;
- }
+ return _minLines;
+ }
- set
+ set
+ {
+ if (value != null)
{
- if (value != null)
- {
- CheckMinLinesValue(value.Value);
- }
-
- _minLines = value;
+ CheckMinLinesValue(value.Value);
}
+
+ _minLines = value;
}
+ }
- internal static void CheckMinLinesValue(int value)
+ internal static void CheckMinLinesValue(int value)
+ {
+ if (value < 1)
{
- if (value < 1)
- {
- throw new ArgumentOutOfRangeException("MinLines must be between 1 and int.MaxValue, inclusive.");
- }
+ throw new ArgumentOutOfRangeException("MinLines must be between 1 and int.MaxValue, inclusive.");
}
+ }
- public AdaptiveTextStyle Style { get; set; } = DEFAULT_STYLE;
+ public AdaptiveTextStyle Style { get; set; } = DEFAULT_STYLE;
- public bool? Wrap { get; set; }
+ public bool? Wrap { get; set; }
- public AdaptiveTextPlacement Placement { get; set; } = DEFAULT_PLACEMENT;
+ public AdaptiveTextPlacement Placement { get; set; } = DEFAULT_PLACEMENT;
- ///
- string IHaveXmlName.Name => "text";
+ ///
+ string IHaveXmlName.Name => "text";
- ///
- IEnumerable> IHaveXmlNamedProperties.EnumerateNamedProperties()
- {
- yield return new("id", Id);
- yield return new("lang", Lang);
+ ///
+ IEnumerable> IHaveXmlNamedProperties.EnumerateNamedProperties()
+ {
+ yield return new("id", Id);
+ yield return new("lang", Lang);
- if (Align != DEFAULT_ALIGN)
- {
- yield return new("hint-align", Align.ToPascalCaseString());
- }
+ if (Align != DEFAULT_ALIGN)
+ {
+ yield return new("hint-align", Align.ToPascalCaseString());
+ }
- yield return new("hint-maxLines", MaxLines);
- yield return new("hint-minLines", MinLines);
+ yield return new("hint-maxLines", MaxLines);
+ yield return new("hint-minLines", MinLines);
- if (Style != DEFAULT_STYLE)
- {
- yield return new("hint-style", Style.ToPascalCaseString());
- }
+ if (Style != DEFAULT_STYLE)
+ {
+ yield return new("hint-style", Style.ToPascalCaseString());
+ }
- yield return new("hint-wrap", Wrap);
+ yield return new("hint-wrap", Wrap);
- if (Placement != DEFAULT_PLACEMENT)
- {
- yield return new("placement", Placement.ToPascalCaseString());
- }
+ if (Placement != DEFAULT_PLACEMENT)
+ {
+ yield return new("placement", Placement.ToPascalCaseString());
}
}
}
\ No newline at end of file
diff --git a/components/Notifications/src/Adaptive/IAdaptiveChild.cs b/components/Notifications/src/Adaptive/IAdaptiveChild.cs
index 1c345e518..c78e9fd6d 100644
--- a/components/Notifications/src/Adaptive/IAdaptiveChild.cs
+++ b/components/Notifications/src/Adaptive/IAdaptiveChild.cs
@@ -2,13 +2,12 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// Elements that can be direct children of adaptive content, including ( , , and ).
+///
+public interface IAdaptiveChild
{
- ///
- /// Elements that can be direct children of adaptive content, including ( , , and ).
- ///
- public interface IAdaptiveChild
- {
- // Blank interface simply for compile-enforcing the child types in the list.
- }
+ // Blank interface simply for compile-enforcing the child types in the list.
}
\ No newline at end of file
diff --git a/components/Notifications/src/Adaptive/IAdaptiveSubgroupChild.cs b/components/Notifications/src/Adaptive/IAdaptiveSubgroupChild.cs
index 9d257f032..c58dc6ea1 100644
--- a/components/Notifications/src/Adaptive/IAdaptiveSubgroupChild.cs
+++ b/components/Notifications/src/Adaptive/IAdaptiveSubgroupChild.cs
@@ -2,13 +2,12 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// Elements that can be direct children of an , including ( and ).
+///
+public interface IAdaptiveSubgroupChild
{
- ///
- /// Elements that can be direct children of an , including ( and ).
- ///
- public interface IAdaptiveSubgroupChild
- {
- // Blank interface simply for compile-enforcing the child types in the list.
- }
+ // Blank interface simply for compile-enforcing the child types in the list.
}
\ No newline at end of file
diff --git a/components/Notifications/src/Adaptive/IBaseImage.cs b/components/Notifications/src/Adaptive/IBaseImage.cs
index c20127153..0a48ed73f 100644
--- a/components/Notifications/src/Adaptive/IBaseImage.cs
+++ b/components/Notifications/src/Adaptive/IBaseImage.cs
@@ -2,26 +2,25 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// Contains the base properties that an image needs.
+///
+public interface IBaseImage
{
///
- /// Contains the base properties that an image needs.
+ /// Gets or sets 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.
///
- public interface IBaseImage
- {
- ///
- /// Gets or sets 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.
- ///
- string Source { get; set; }
+ string Source { get; set; }
- ///
- /// Gets or sets a description of the image, for users of assistive technologies.
- ///
- string AlternateText { get; set; }
+ ///
+ /// Gets or sets a description of the image, for users of assistive technologies.
+ ///
+ string AlternateText { get; set; }
- ///
- /// Gets or sets a value whether Windows should 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.
- ///
- bool? AddImageQuery { get; set; }
- }
+ ///
+ /// Gets or sets a value whether Windows should 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.
+ ///
+ bool? AddImageQuery { get; set; }
}
\ No newline at end of file
diff --git a/components/Notifications/src/Adaptive/IBaseText.cs b/components/Notifications/src/Adaptive/IBaseText.cs
index 38eb7bab4..b674a3737 100644
--- a/components/Notifications/src/Adaptive/IBaseText.cs
+++ b/components/Notifications/src/Adaptive/IBaseText.cs
@@ -2,21 +2,20 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// Defines the basic properties of a text element.
+///
+public interface IBaseText
{
///
- /// Defines the basic properties of a text element.
+ /// Gets or sets the text to display.
///
- public interface IBaseText
- {
- ///
- /// Gets or sets the text to display.
- ///
- string Text { get; set; }
+ string Text { get; set; }
- ///
- /// Gets or sets 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.
- ///
- string Language { get; set; }
- }
+ ///
+ /// Gets or sets 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.
+ ///
+ string Language { get; set; }
}
\ No newline at end of file
diff --git a/components/Notifications/src/Badges/BadgeGlyphContent.cs b/components/Notifications/src/Badges/BadgeGlyphContent.cs
index 5d02da2fd..51724d717 100644
--- a/components/Notifications/src/Badges/BadgeGlyphContent.cs
+++ b/components/Notifications/src/Badges/BadgeGlyphContent.cs
@@ -5,90 +5,89 @@
using System;
using Windows.Data.Xml.Dom;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// Notification content object to display a glyph on a Tile's badge.
+///
+public sealed class BadgeGlyphContent : INotificationContent
{
///
- /// Notification content object to display a glyph on a Tile's badge.
+ /// Initializes a new instance of the class.
+ /// Default constructor to create a glyph badge content object.
///
- public sealed class BadgeGlyphContent : INotificationContent
+ public BadgeGlyphContent()
{
- ///
- /// Initializes a new instance of the class.
- /// Default constructor to create a glyph badge content object.
- ///
- public BadgeGlyphContent()
- {
- }
+ }
- ///
- /// Initializes a new instance of the class.
- /// Constructor to create a glyph badge content object with a glyph.
- ///
- /// The glyph to be displayed on the badge.
- public BadgeGlyphContent(BadgeGlyphValue glyph)
- {
- _glyph = glyph;
- }
+ ///
+ /// Initializes a new instance of the class.
+ /// Constructor to create a glyph badge content object with a glyph.
+ ///
+ /// The glyph to be displayed on the badge.
+ public BadgeGlyphContent(BadgeGlyphValue glyph)
+ {
+ _glyph = glyph;
+ }
- ///
- /// Gets or sets the glyph to be displayed on the badge.
- ///
- public BadgeGlyphValue Glyph
+ ///
+ /// Gets or sets the glyph to be displayed on the badge.
+ ///
+ public BadgeGlyphValue Glyph
+ {
+ get
{
- get
- {
- return _glyph;
- }
-
- set
- {
- if (!Enum.IsDefined(typeof(BadgeGlyphValue), value))
- {
- throw new ArgumentOutOfRangeException(nameof(value));
- }
-
- _glyph = value;
- }
+ return _glyph;
}
- ///
- /// Retrieves the notification Xml content as a string.
- ///
- /// The notification Xml content as a string.
- public string GetContent()
+ set
{
- if (!Enum.IsDefined(typeof(BadgeGlyphValue), _glyph))
+ if (!Enum.IsDefined(typeof(BadgeGlyphValue), value))
{
- throw new NotificationContentValidationException("The badge glyph property was left unset.");
+ throw new ArgumentOutOfRangeException(nameof(value));
}
- 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(" ", glyphString);
+ _glyph = value;
}
+ }
- ///
- /// Retrieves the notification XML content as a string.
- ///
- /// The notification XML content as a string.
- public override string ToString()
+ ///
+ /// Retrieves the notification Xml content as a string.
+ ///
+ /// The notification Xml content as a string.
+ public string GetContent()
+ {
+ if (!Enum.IsDefined(typeof(BadgeGlyphValue), _glyph))
{
- return GetContent();
+ throw new NotificationContentValidationException("The badge glyph property was left unset.");
}
- ///
- /// Retrieves the notification XML content as a WinRT Xml document.
- ///
- /// The notification XML content as a WinRT Xml document.
- public XmlDocument GetXml()
- {
- XmlDocument xml = new XmlDocument();
- xml.LoadXml(GetContent());
- return xml;
- }
+ 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(" ", glyphString);
+ }
- private BadgeGlyphValue _glyph = (BadgeGlyphValue)(-1);
+ ///
+ /// Retrieves the notification XML content as a string.
+ ///
+ /// The notification XML content as a string.
+ public override string ToString()
+ {
+ return GetContent();
}
+
+ ///
+ /// Retrieves the notification XML content as a WinRT Xml document.
+ ///
+ /// The notification XML content as a WinRT Xml document.
+ public XmlDocument GetXml()
+ {
+ XmlDocument xml = new XmlDocument();
+ xml.LoadXml(GetContent());
+ return xml;
+ }
+
+ private BadgeGlyphValue _glyph = (BadgeGlyphValue)(-1);
}
diff --git a/components/Notifications/src/Badges/BadgeGlyphValue.cs b/components/Notifications/src/Badges/BadgeGlyphValue.cs
index 17bcb61b8..28f8b3f41 100644
--- a/components/Notifications/src/Badges/BadgeGlyphValue.cs
+++ b/components/Notifications/src/Badges/BadgeGlyphValue.cs
@@ -2,77 +2,76 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// The types of glyphs that can be placed on a badge.
+///
+public enum BadgeGlyphValue
{
///
- /// The types of glyphs that can be placed on a badge.
+ /// No glyph. If there is a numeric badge, or a glyph currently on the badge,
+ /// it will be removed.
///
- public enum BadgeGlyphValue
- {
- ///
- /// No glyph. If there is a numeric badge, or a glyph currently on the badge,
- /// it will be removed.
- ///
- None = 0,
+ None = 0,
- ///
- /// A glyph representing application activity.
- ///
- Activity,
+ ///
+ /// A glyph representing application activity.
+ ///
+ Activity,
- ///
- /// A glyph representing an alert.
- ///
- Alert,
+ ///
+ /// A glyph representing an alert.
+ ///
+ Alert,
- ///
- /// A glyph representing an alarm.
- ///
- Alarm,
+ ///
+ /// A glyph representing an alarm.
+ ///
+ Alarm,
- ///
- /// A glyph representing availability status.
- ///
- Available,
+ ///
+ /// A glyph representing availability status.
+ ///
+ Available,
- ///
- /// A glyph representing away status
- ///
- Away,
+ ///
+ /// A glyph representing away status
+ ///
+ Away,
- ///
- /// A glyph representing busy status.
- ///
- Busy,
+ ///
+ /// A glyph representing busy status.
+ ///
+ Busy,
- ///
- /// A glyph representing that a new message is available.
- ///
- NewMessage,
+ ///
+ /// A glyph representing that a new message is available.
+ ///
+ NewMessage,
- ///
- /// A glyph representing that media is paused.
- ///
- Paused,
+ ///
+ /// A glyph representing that media is paused.
+ ///
+ Paused,
- ///
- /// A glyph representing that media is playing.
- ///
- Playing,
+ ///
+ /// A glyph representing that media is playing.
+ ///
+ Playing,
- ///
- /// A glyph representing unavailable status.
- ///
- Unavailable,
+ ///
+ /// A glyph representing unavailable status.
+ ///
+ Unavailable,
- ///
- /// A glyph representing an error.
- ///
- Error,
+ ///
+ /// A glyph representing an error.
+ ///
+ Error,
- ///
- /// A glyph representing attention status.
- ///
- Attention
- }
+ ///
+ /// A glyph representing attention status.
+ ///
+ Attention
}
\ No newline at end of file
diff --git a/components/Notifications/src/Badges/BadgeNumericContent.cs b/components/Notifications/src/Badges/BadgeNumericContent.cs
index c3cda912b..97c540e62 100644
--- a/components/Notifications/src/Badges/BadgeNumericContent.cs
+++ b/components/Notifications/src/Badges/BadgeNumericContent.cs
@@ -4,73 +4,72 @@
using Windows.Data.Xml.Dom;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// Notification content object to display a number on a Tile's badge.
+///
+public sealed class BadgeNumericContent : INotificationContent
{
///
- /// Notification content object to display a number on a Tile's badge.
+ /// Initializes a new instance of the class.
+ /// Default constructor to create a numeric badge content object.
///
- public sealed class BadgeNumericContent : INotificationContent
+ public BadgeNumericContent()
{
- ///
- /// Initializes a new instance of the class.
- /// Default constructor to create a numeric badge content object.
- ///
- public BadgeNumericContent()
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- /// Constructor to create a numeric badge content object with a number.
- ///
- ///
- /// The number that will appear on the badge. If the number is 0, the badge
- /// will be removed.
- ///
- public BadgeNumericContent(uint number)
- {
- _number = number;
- }
+ }
- ///
- /// Gets or sets the number that will appear on the badge. If the number is 0, the badge
- /// will be removed.
- ///
- public uint Number
- {
- get { return _number; }
- set { _number = value; }
- }
+ ///
+ /// Initializes a new instance of the class.
+ /// Constructor to create a numeric badge content object with a number.
+ ///
+ ///
+ /// The number that will appear on the badge. If the number is 0, the badge
+ /// will be removed.
+ ///
+ public BadgeNumericContent(uint number)
+ {
+ _number = number;
+ }
- ///
- /// Retrieves the notification Xml content as a string.
- ///
- /// The notification Xml content as a string.
- public string GetContent()
- {
- return string.Format(" ", _number);
- }
+ ///
+ /// Gets or sets the number that will appear on the badge. If the number is 0, the badge
+ /// will be removed.
+ ///
+ public uint Number
+ {
+ get { return _number; }
+ set { _number = value; }
+ }
- ///
- /// Retrieves the notification Xml content as a string.
- ///
- /// The notification Xml content as a string.
- public override string ToString()
- {
- return GetContent();
- }
+ ///
+ /// Retrieves the notification Xml content as a string.
+ ///
+ /// The notification Xml content as a string.
+ public string GetContent()
+ {
+ return string.Format(" ", _number);
+ }
- ///
- /// Retrieves the notification Xml content as a WinRT Xml document.
- ///
- /// The notification Xml content as a WinRT Xml document.
- public XmlDocument GetXml()
- {
- XmlDocument xml = new XmlDocument();
- xml.LoadXml(GetContent());
- return xml;
- }
+ ///
+ /// Retrieves the notification Xml content as a string.
+ ///
+ /// The notification Xml content as a string.
+ public override string ToString()
+ {
+ return GetContent();
+ }
- private uint _number = 0;
+ ///
+ /// Retrieves the notification Xml content as a WinRT Xml document.
+ ///
+ /// The notification Xml content as a WinRT Xml document.
+ public XmlDocument GetXml()
+ {
+ XmlDocument xml = new XmlDocument();
+ xml.LoadXml(GetContent());
+ return xml;
}
+
+ private uint _number = 0;
}
diff --git a/components/Notifications/src/Common/ArgumentValidator.cs b/components/Notifications/src/Common/ArgumentValidator.cs
index c1f9c4d82..d9a15ed0d 100644
--- a/components/Notifications/src/Common/ArgumentValidator.cs
+++ b/components/Notifications/src/Common/ArgumentValidator.cs
@@ -4,27 +4,26 @@
using System;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+internal static class ArgumentValidator
{
- internal static class ArgumentValidator
+ public static void SetProperty(ref T property, T value, string propertyName, ArgumentValidatorOptions options)
{
- public static void SetProperty(ref T property, T value, string propertyName, ArgumentValidatorOptions options)
+ if (options.HasFlag(ArgumentValidatorOptions.NotNull))
{
- if (options.HasFlag(ArgumentValidatorOptions.NotNull))
+ if (value == null)
{
- if (value == null)
- {
- throw new ArgumentNullException(propertyName);
- }
+ throw new ArgumentNullException(propertyName);
}
-
- property = value;
}
- }
- [Flags]
- internal enum ArgumentValidatorOptions
- {
- NotNull
+ property = value;
}
+}
+
+[Flags]
+internal enum ArgumentValidatorOptions
+{
+ NotNull
}
\ No newline at end of file
diff --git a/components/Notifications/src/Common/BaseElement.cs b/components/Notifications/src/Common/BaseElement.cs
index 809eca5c1..0b0db4be6 100644
--- a/components/Notifications/src/Common/BaseElement.cs
+++ b/components/Notifications/src/Common/BaseElement.cs
@@ -7,46 +7,45 @@
using Windows.Data.Xml.Dom;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+internal abstract class BaseElement
{
- internal abstract class BaseElement
+ ///
+ /// Retrieves the notification XML content as a string.
+ ///
+ /// The notification XML content as a string.
+ public string GetContent()
{
- ///
- /// Retrieves the notification XML content as a string.
- ///
- /// The notification XML content as a string.
- public string GetContent()
+ using (MemoryStream stream = new MemoryStream())
{
- 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
+ }))
{
- 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);
- }
+ XmlWriterHelper.Write(writer, this);
+ }
- stream.Position = 0;
+ stream.Position = 0;
- using (StreamReader reader = new StreamReader(stream))
- {
- return reader.ReadToEnd();
- }
+ using (StreamReader reader = new StreamReader(stream))
+ {
+ return reader.ReadToEnd();
}
}
+ }
- ///
- /// Retrieves the notification XML content as a WinRT XML document.
- ///
- /// The notification XML content as a WinRT XML document.
- public XmlDocument GetXml()
- {
- XmlDocument xml = new XmlDocument();
- xml.LoadXml(GetContent());
- return xml;
- }
+ ///
+ /// Retrieves the notification XML content as a WinRT XML document.
+ ///
+ /// The notification XML content as a WinRT XML document.
+ public XmlDocument GetXml()
+ {
+ XmlDocument xml = new XmlDocument();
+ xml.LoadXml(GetContent());
+ return xml;
}
}
diff --git a/components/Notifications/src/Common/EnumFormatter.cs b/components/Notifications/src/Common/EnumFormatter.cs
index 117a98a4f..bd7b8c08c 100644
--- a/components/Notifications/src/Common/EnumFormatter.cs
+++ b/components/Notifications/src/Common/EnumFormatter.cs
@@ -6,52 +6,51 @@
#nullable enable
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// A helper class that can be used to format values.
+///
+internal static class EnumFormatter
{
///
- /// A helper class that can be used to format values.
+ /// Returns a representation of an enum value with pascal casing.
///
- internal static class EnumFormatter
+ /// The type to format.
+ /// The value to format.
+ /// The pascal case representation of .
+ public static string? ToPascalCaseString(this T? value)
+ where T : unmanaged, Enum
{
- ///
- /// Returns a representation of an enum value with pascal casing.
- ///
- /// The type to format.
- /// The value to format.
- /// The pascal case representation of .
- public static string? ToPascalCaseString(this T? value)
- where T : unmanaged, Enum
+ if (value is null)
{
- if (value is null)
- {
- return null;
- }
-
- return ToPascalCaseString(value.Value);
+ return null;
}
- ///
- /// Returns a representation of an enum value with pascal casing.
- ///
- /// The type to format.
- /// The value to format.
- /// The pascal case representation of .
- public static string? ToPascalCaseString(this T value)
- where T : unmanaged, Enum
- {
- string? text = value.ToString();
+ return ToPascalCaseString(value.Value);
+ }
- if (text is null or { Length: 0 })
- {
- return text;
- }
+ ///
+ /// Returns a representation of an enum value with pascal casing.
+ ///
+ /// The type to format.
+ /// The value to format.
+ /// The pascal case representation of .
+ public static string? ToPascalCaseString(this T value)
+ where T : unmanaged, Enum
+ {
+ string? text = value.ToString();
- if (text is { Length: 1 })
- {
- return text.ToLowerInvariant();
- }
+ if (text is null or { Length: 0 })
+ {
+ return text;
+ }
- return $"{char.ToLowerInvariant(text[0])}{text.Substring(1)}";
+ if (text is { Length: 1 })
+ {
+ return text.ToLowerInvariant();
}
+
+ return $"{char.ToLowerInvariant(text[0])}{text.Substring(1)}";
}
}
\ No newline at end of file
diff --git a/components/Notifications/src/Common/INotificationContent.cs b/components/Notifications/src/Common/INotificationContent.cs
index d84afe4a3..c4ccc84e6 100644
--- a/components/Notifications/src/Common/INotificationContent.cs
+++ b/components/Notifications/src/Common/INotificationContent.cs
@@ -4,23 +4,22 @@
using Windows.Data.Xml.Dom;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// Base notification content interface to retrieve notification Xml as a string.
+///
+public interface INotificationContent
{
///
- /// Base notification content interface to retrieve notification Xml as a string.
+ /// Retrieves the notification Xml content as a string.
///
- public interface INotificationContent
- {
- ///
- /// Retrieves the notification Xml content as a string.
- ///
- /// The notification Xml content as a string.
- string GetContent();
+ /// The notification Xml content as a string.
+ string GetContent();
- ///
- /// Retrieves the notification Xml content as a WinRT Xml document.
- ///
- /// The notification Xml content as a WinRT Xml document.
- XmlDocument GetXml();
- }
+ ///
+ /// Retrieves the notification Xml content as a WinRT Xml document.
+ ///
+ /// The notification Xml content as a WinRT Xml document.
+ XmlDocument GetXml();
}
diff --git a/components/Notifications/src/Common/LimitedList{T}.cs b/components/Notifications/src/Common/LimitedList{T}.cs
index 5ff4ac43b..6e2162199 100644
--- a/components/Notifications/src/Common/LimitedList{T}.cs
+++ b/components/Notifications/src/Common/LimitedList{T}.cs
@@ -6,108 +6,107 @@
using System.Collections;
using System.Collections.Generic;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+internal sealed class LimitedList : IList
{
- internal sealed class LimitedList : IList
- {
- private List _list;
+ private List _list;
- public int Limit { get; private set; }
+ public int Limit { get; private set; }
- public LimitedList(int limit)
- {
- _list = new List(limit);
+ public LimitedList(int limit)
+ {
+ _list = new List(limit);
- Limit = limit;
- }
+ Limit = limit;
+ }
- public T this[int index]
+ public T this[int index]
+ {
+ get
{
- get
- {
- return _list[index];
- }
-
- set
- {
- _list[index] = value;
- }
+ return _list[index];
}
- public int Count
+ set
{
- get
- {
- return _list.Count;
- }
+ _list[index] = value;
}
+ }
- public bool IsReadOnly
+ public int Count
+ {
+ get
{
- get
- {
- return false;
- }
+ return _list.Count;
}
+ }
- public void Add(T item)
+ public bool IsReadOnly
+ {
+ get
{
- if (_list.Count >= Limit)
- {
- throw new Exception("This list is limited to " + Limit + " items. You cannot add more items.");
- }
-
- _list.Add(item);
+ return false;
}
+ }
- public void Clear()
+ public void Add(T item)
+ {
+ if (_list.Count >= Limit)
{
- _list.Clear();
+ throw new Exception("This list is limited to " + Limit + " items. You cannot add more items.");
}
- public bool Contains(T item)
- {
- return _list.Contains(item);
- }
+ _list.Add(item);
+ }
- public void CopyTo(T[] array, int arrayIndex)
- {
- _list.CopyTo(array, arrayIndex);
- }
+ public void Clear()
+ {
+ _list.Clear();
+ }
- public IEnumerator GetEnumerator()
- {
- return _list.GetEnumerator();
- }
+ public bool Contains(T item)
+ {
+ return _list.Contains(item);
+ }
- public int IndexOf(T item)
- {
- return _list.IndexOf(item);
- }
+ public void CopyTo(T[] array, int arrayIndex)
+ {
+ _list.CopyTo(array, arrayIndex);
+ }
- public void Insert(int index, T item)
- {
- _list.Insert(index, item);
- }
+ public IEnumerator GetEnumerator()
+ {
+ return _list.GetEnumerator();
+ }
- public bool Remove(T item)
- {
- return _list.Remove(item);
- }
+ public int IndexOf(T item)
+ {
+ return _list.IndexOf(item);
+ }
- public void RemoveAt(int index)
- {
- _list.RemoveAt(index);
- }
+ public void Insert(int index, T item)
+ {
+ _list.Insert(index, item);
+ }
- IEnumerator IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
+ public bool Remove(T item)
+ {
+ return _list.Remove(item);
}
- internal interface IElementWithDescendants
+ public void RemoveAt(int index)
{
- IEnumerable Descendants();
+ _list.RemoveAt(index);
}
+
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
+}
+
+internal interface IElementWithDescendants
+{
+ IEnumerable Descendants();
}
diff --git a/components/Notifications/src/Common/NotificationContentValidationException.cs b/components/Notifications/src/Common/NotificationContentValidationException.cs
index 2963aa444..3156e1831 100644
--- a/components/Notifications/src/Common/NotificationContentValidationException.cs
+++ b/components/Notifications/src/Common/NotificationContentValidationException.cs
@@ -4,16 +4,15 @@
using System;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// Exception returned when invalid notification content is provided.
+///
+internal sealed class NotificationContentValidationException : Exception
{
- ///
- /// Exception returned when invalid notification content is provided.
- ///
- internal sealed class NotificationContentValidationException : Exception
+ public NotificationContentValidationException(string message)
+ : base(message)
{
- public NotificationContentValidationException(string message)
- : base(message)
- {
- }
}
}
diff --git a/components/Notifications/src/Common/Serialization/IHaveXmlAdditionalProperties.cs b/components/Notifications/src/Common/Serialization/IHaveXmlAdditionalProperties.cs
index 757d1f5d7..a4342b951 100644
--- a/components/Notifications/src/Common/Serialization/IHaveXmlAdditionalProperties.cs
+++ b/components/Notifications/src/Common/Serialization/IHaveXmlAdditionalProperties.cs
@@ -6,16 +6,15 @@
#nullable enable
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// An interface for a notification XML element with additional properties.
+///
+internal interface IHaveXmlAdditionalProperties
{
///
- /// An interface for a notification XML element with additional properties.
+ /// Gets the mapping of additional properties.
///
- internal interface IHaveXmlAdditionalProperties
- {
- ///
- /// Gets the mapping of additional properties.
- ///
- IReadOnlyDictionary AdditionalProperties { get; }
- }
+ IReadOnlyDictionary AdditionalProperties { get; }
}
diff --git a/components/Notifications/src/Common/Serialization/IHaveXmlChildren.cs b/components/Notifications/src/Common/Serialization/IHaveXmlChildren.cs
index 12723a323..afc91a952 100644
--- a/components/Notifications/src/Common/Serialization/IHaveXmlChildren.cs
+++ b/components/Notifications/src/Common/Serialization/IHaveXmlChildren.cs
@@ -6,16 +6,15 @@
#nullable enable
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// An interface for a notification XML element with additional children.
+///
+internal interface IHaveXmlChildren
{
///
- /// An interface for a notification XML element with additional children.
+ /// Gets the children of the current element.
///
- internal interface IHaveXmlChildren
- {
- ///
- /// Gets the children of the current element.
- ///
- IEnumerable Children { get; }
- }
+ IEnumerable Children { get; }
}
\ No newline at end of file
diff --git a/components/Notifications/src/Common/Serialization/IHaveXmlName.cs b/components/Notifications/src/Common/Serialization/IHaveXmlName.cs
index f9e96c99d..07f8dd09c 100644
--- a/components/Notifications/src/Common/Serialization/IHaveXmlName.cs
+++ b/components/Notifications/src/Common/Serialization/IHaveXmlName.cs
@@ -2,16 +2,15 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// An interface for a notification XML element with a name.
+///
+internal interface IHaveXmlName
{
///
- /// An interface for a notification XML element with a name.
+ /// Gets the name of the current element.
///
- internal interface IHaveXmlName
- {
- ///
- /// Gets the name of the current element.
- ///
- string Name { get; }
- }
+ string Name { get; }
}
diff --git a/components/Notifications/src/Common/Serialization/IHaveXmlNamedProperties.cs b/components/Notifications/src/Common/Serialization/IHaveXmlNamedProperties.cs
index 29c7e17b5..b69f88eeb 100644
--- a/components/Notifications/src/Common/Serialization/IHaveXmlNamedProperties.cs
+++ b/components/Notifications/src/Common/Serialization/IHaveXmlNamedProperties.cs
@@ -6,18 +6,17 @@
#nullable enable
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// An interface for a notification XML element with named properties.
+///
+internal interface IHaveXmlNamedProperties
{
///
- /// An interface for a notification XML element with named properties.
+ /// Enumerates the available named properties for the element.
///
- internal interface IHaveXmlNamedProperties
- {
- ///
- /// Enumerates the available named properties for the element.
- ///
- /// A sequence of named properties for the element.
- /// The returned values must be valid XML values when is called on them.
- IEnumerable> EnumerateNamedProperties();
- }
+ /// A sequence of named properties for the element.
+ /// The returned values must be valid XML values when is called on them.
+ IEnumerable> EnumerateNamedProperties();
}
diff --git a/components/Notifications/src/Common/Serialization/IHaveXmlText.cs b/components/Notifications/src/Common/Serialization/IHaveXmlText.cs
index 358afa31b..27d3afa29 100644
--- a/components/Notifications/src/Common/Serialization/IHaveXmlText.cs
+++ b/components/Notifications/src/Common/Serialization/IHaveXmlText.cs
@@ -2,16 +2,15 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// An interface for a notification XML element with an explicit XML text content.
+///
+internal interface IHaveXmlText
{
///
- /// An interface for a notification XML element with an explicit XML text content.
+ /// Gets the text content of the current element.
///
- internal interface IHaveXmlText
- {
- ///
- /// Gets the text content of the current element.
- ///
- string Text { get; }
- }
+ string Text { get; }
}
diff --git a/components/Notifications/src/Common/XmlWriterHelper.cs b/components/Notifications/src/Common/XmlWriterHelper.cs
index 6111d2bda..4de5e19b3 100644
--- a/components/Notifications/src/Common/XmlWriterHelper.cs
+++ b/components/Notifications/src/Common/XmlWriterHelper.cs
@@ -7,81 +7,80 @@
using System.Linq;
using System.Xml;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+internal static class XmlWriterHelper
{
- internal static class XmlWriterHelper
+ public static void Write(XmlWriter writer, object element)
{
- public static void Write(XmlWriter writer, object element)
+ // If it isn't an XML element, don't write anything
+ if (element is not IHaveXmlName xmlElement)
{
- // If it isn't an XML element, don't write anything
- if (element is not IHaveXmlName xmlElement)
- {
- return;
- }
-
- writer.WriteStartElement(xmlElement.Name);
-
- // Write all named properties
- foreach (var property in (element as IHaveXmlNamedProperties)?.EnumerateNamedProperties() ?? Enumerable.Empty>())
- {
- if (property.Value is not null)
- {
- writer.WriteAttributeString(property.Key, PropertyValueToString(property.Value));
- }
- }
+ return;
+ }
- // Write all additional properties
- foreach (var property in (element as IHaveXmlAdditionalProperties)?.AdditionalProperties ?? Enumerable.Empty>())
- {
- writer.WriteAttributeString(property.Key, property.Value);
- }
+ writer.WriteStartElement(xmlElement.Name);
- // Write the inner text, if any
- if ((element as IHaveXmlText)?.Text is string { Length: > 0 } text)
+ // Write all named properties
+ foreach (var property in (element as IHaveXmlNamedProperties)?.EnumerateNamedProperties() ?? Enumerable.Empty>())
+ {
+ if (property.Value is not null)
{
- writer.WriteString(text);
+ writer.WriteAttributeString(property.Key, PropertyValueToString(property.Value));
}
+ }
- // Write all children, if any
- foreach (var child in (element as IHaveXmlChildren)?.Children ?? Enumerable.Empty())
- {
- Write(writer, child);
- }
+ // Write all additional properties
+ foreach (var property in (element as IHaveXmlAdditionalProperties)?.AdditionalProperties ?? Enumerable.Empty>())
+ {
+ writer.WriteAttributeString(property.Key, property.Value);
+ }
- writer.WriteEndElement();
+ // Write the inner text, if any
+ if ((element as IHaveXmlText)?.Text is string { Length: > 0 } text)
+ {
+ writer.WriteString(text);
}
- private static string PropertyValueToString(object propertyValue)
+ // Write all children, if any
+ foreach (var child in (element as IHaveXmlChildren)?.Children ?? Enumerable.Empty())
{
- return propertyValue switch
- {
- true => "true",
- false => "false",
- DateTimeOffset dateTime => XmlConvert.ToString(dateTime), // ISO 8601 format
- { } value => value.ToString(),
- _ => null
- };
+ Write(writer, child);
}
- ///
- /// Gets the provided binding value, if it exists. Otherwise, falls back to the absolute value.
- ///
- /// The type of the enum of the class properties.
- /// The collection of data-bound values.
- /// The property to obtain.
- /// The absolute value, if any.
- /// The provided binding value, if it exists. Otherwise, falls back to the absolute value.
- internal static string GetBindingOrAbsoluteXmlValue(IDictionary bindings, T bindableProperty, string absoluteValue)
+ writer.WriteEndElement();
+ }
+
+ private static string PropertyValueToString(object propertyValue)
+ {
+ return propertyValue switch
{
- // If a binding is provided, use the binding value
- string bindingValue;
- if (bindings.TryGetValue(bindableProperty, out bindingValue))
- {
- return "{" + bindingValue + "}";
- }
+ true => "true",
+ false => "false",
+ DateTimeOffset dateTime => XmlConvert.ToString(dateTime), // ISO 8601 format
+ { } value => value.ToString(),
+ _ => null
+ };
+ }
- // Otherwise fallback to the absolute value
- return absoluteValue;
+ ///
+ /// Gets the provided binding value, if it exists. Otherwise, falls back to the absolute value.
+ ///
+ /// The type of the enum of the class properties.
+ /// The collection of data-bound values.
+ /// The property to obtain.
+ /// The absolute value, if any.
+ /// The provided binding value, if it exists. Otherwise, falls back to the absolute value.
+ internal static string GetBindingOrAbsoluteXmlValue(IDictionary 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
diff --git a/components/Notifications/src/CommunityToolkit.Notifications.csproj b/components/Notifications/src/CommunityToolkit.Notifications.csproj
index 4112bc6c6..bc175d9ac 100644
--- a/components/Notifications/src/CommunityToolkit.Notifications.csproj
+++ b/components/Notifications/src/CommunityToolkit.Notifications.csproj
@@ -13,7 +13,11 @@
CommunityToolkit.Notifications
$(PackageIdPrefix).$(ToolkitComponentName)
disable
+ false
false
+
+
+ uap10.0.17763;net8.0-windows10.0.17763.0;net9.0-windows10.0.17763.0;
diff --git a/components/Notifications/src/Tiles/Builder/TileContentBuilder.SpecialTiles.cs b/components/Notifications/src/Tiles/Builder/TileContentBuilder.SpecialTiles.cs
index a706c5b56..a2f0e34cb 100644
--- a/components/Notifications/src/Tiles/Builder/TileContentBuilder.SpecialTiles.cs
+++ b/components/Notifications/src/Tiles/Builder/TileContentBuilder.SpecialTiles.cs
@@ -7,155 +7,155 @@
using System.Linq;
using System.Text;
-namespace CommunityToolkit.Notifications
-{
+namespace CommunityToolkit.Notifications;
+
#pragma warning disable SA1008
#pragma warning disable SA1009
+///
+/// Builder class used to create
+///
+public partial class TileContentBuilder
+{
///
- /// Builder class used to create
+ /// Helper method for creating a tile notification content for using Contact tile template.
///
- public partial class TileContentBuilder
+ /// Source for the contact picture
+ /// Name of the contact
+ /// A description of the contact image, for users of assistive technologies.
+ /// Indicating whether Windows should append a query string to the image URI supplied in the Tile notification.
+ /// Gets or sets 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.
+ /// An instance of represent a payload of a tile notification.
+ public static TileBindingContentContact CreateContactTileContent(Uri contactImageUri, string contactName, string contactImageAltText = default(string), bool? contactImageAddImageQuery = default(bool?), string textLanguage = default(string))
{
- ///
- /// Helper method for creating a tile notification content for using Contact tile template.
- ///
- /// Source for the contact picture
- /// Name of the contact
- /// A description of the contact image, for users of assistive technologies.
- /// Indicating whether Windows should append a query string to the image URI supplied in the Tile notification.
- /// Gets or sets 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.
- /// An instance of represent a payload of a tile notification.
- public static TileBindingContentContact CreateContactTileContent(Uri contactImageUri, string contactName, string contactImageAltText = default(string), bool? contactImageAddImageQuery = default(bool?), string textLanguage = default(string))
- {
- var contactTileContent = new TileBindingContentContact();
- contactTileContent.Image = CreateTileBasicImage(contactImageUri, contactImageAltText, contactImageAddImageQuery);
+ var contactTileContent = new TileBindingContentContact();
+ contactTileContent.Image = CreateTileBasicImage(contactImageUri, contactImageAltText, contactImageAddImageQuery);
- contactTileContent.Text = new TileBasicText();
- contactTileContent.Text.Text = contactName;
+ contactTileContent.Text = new TileBasicText();
+ contactTileContent.Text.Text = contactName;
- if (textLanguage != default(string))
- {
- contactTileContent.Text.Lang = textLanguage;
- }
-
- return contactTileContent;
+ if (textLanguage != default(string))
+ {
+ contactTileContent.Text.Lang = textLanguage;
}
- ///
- /// Helper method for creating a tile notification content for using Iconic tile template.
- ///
- /// Source of the icon image.
- /// A description of the icon image, for users of assistive technologies.
- /// Indicating whether Windows should append a query string to the image URI supplied in the Tile notification.
- /// An instance of represent a payload of a tile notification.
- public static TileBindingContentIconic CreateIconicTileContent(Uri iconImageUri, string iconImageAltText = default(string), bool? iconImageAddImageQuery = default(bool?))
- {
- var iconicTileContent = new TileBindingContentIconic();
- iconicTileContent.Icon = CreateTileBasicImage(iconImageUri, iconImageAltText, iconImageAddImageQuery);
+ return contactTileContent;
+ }
- return iconicTileContent;
- }
+ ///
+ /// Helper method for creating a tile notification content for using Iconic tile template.
+ ///
+ /// Source of the icon image.
+ /// A description of the icon image, for users of assistive technologies.
+ /// Indicating whether Windows should append a query string to the image URI supplied in the Tile notification.
+ /// An instance of represent a payload of a tile notification.
+ public static TileBindingContentIconic CreateIconicTileContent(Uri iconImageUri, string iconImageAltText = default(string), bool? iconImageAddImageQuery = default(bool?))
+ {
+ var iconicTileContent = new TileBindingContentIconic();
+ iconicTileContent.Icon = CreateTileBasicImage(iconImageUri, iconImageAltText, iconImageAddImageQuery);
- ///
- /// Helper method for creating a tile notification content for using People tile template.
- ///
- /// Sources of pictures that will be used on the people tile.
- /// An instance of represent a payload of a tile notification.
- public static TileBindingContentPeople CreatePeopleTileContent(params Uri[] peoplePictureSources)
- {
- IEnumerable images = peoplePictureSources.Select(u => CreateTileBasicImage(u, default(string), default(bool?)));
+ return iconicTileContent;
+ }
- return CreatePeopleTileContent(images);
- }
+ ///
+ /// Helper method for creating a tile notification content for using People tile template.
+ ///
+ /// Sources of pictures that will be used on the people tile.
+ /// An instance of represent a payload of a tile notification.
+ public static TileBindingContentPeople CreatePeopleTileContent(params Uri[] peoplePictureSources)
+ {
+ IEnumerable images = peoplePictureSources.Select(u => CreateTileBasicImage(u, default(string), default(bool?)));
- ///
- /// Helper method for creating a tile notification content for using People tile template.
- ///
- /// Sources of pictures with description and image query indicator that will be used on the people tile.
- /// An instance of represent a payload of a tile notification.
- public static TileBindingContentPeople CreatePeopleTileContent(params (Uri source, string imageAltText, bool? addImageQuery)[] peoplePictures)
- {
- IEnumerable images = peoplePictures.Select(t => CreateTileBasicImage(t.source, t.imageAltText, t.addImageQuery));
+ return CreatePeopleTileContent(images);
+ }
- return CreatePeopleTileContent(images);
- }
+ ///
+ /// Helper method for creating a tile notification content for using People tile template.
+ ///
+ /// Sources of pictures with description and image query indicator that will be used on the people tile.
+ /// An instance of represent a payload of a tile notification.
+ public static TileBindingContentPeople CreatePeopleTileContent(params (Uri source, string imageAltText, bool? addImageQuery)[] peoplePictures)
+ {
+ IEnumerable images = peoplePictures.Select(t => CreateTileBasicImage(t.source, t.imageAltText, t.addImageQuery));
- ///
- /// Helper method for creating a tile notification content for using People tile template.
- ///
- /// Pictures that will be used on the people tile.
- /// An instance of represent a payload of a tile notification.
- public static TileBindingContentPeople CreatePeopleTileContent(IEnumerable peoplePictures)
- {
- var peopleTileContent = new TileBindingContentPeople();
+ return CreatePeopleTileContent(images);
+ }
- foreach (var image in peoplePictures)
- {
- peopleTileContent.Images.Add(image);
- }
+ ///
+ /// Helper method for creating a tile notification content for using People tile template.
+ ///
+ /// Pictures that will be used on the people tile.
+ /// An instance of represent a payload of a tile notification.
+ public static TileBindingContentPeople CreatePeopleTileContent(IEnumerable peoplePictures)
+ {
+ var peopleTileContent = new TileBindingContentPeople();
- return peopleTileContent;
+ foreach (var image in peoplePictures)
+ {
+ peopleTileContent.Images.Add(image);
}
- ///
- /// Helper method for creating a tile notification content for using Photos tile template.
- ///
- /// Sources of pictures that will be used on the photos tile.
- /// An instance of represent a payload of a tile notification.
- public static TileBindingContentPhotos CreatePhotosTileContent(params Uri[] photoSources)
- {
- IEnumerable images = photoSources.Select(u => CreateTileBasicImage(u, default(string), default(bool?)));
+ return peopleTileContent;
+ }
- return CreatePhotosTileContent(images);
- }
+ ///
+ /// Helper method for creating a tile notification content for using Photos tile template.
+ ///
+ /// Sources of pictures that will be used on the photos tile.
+ /// An instance of represent a payload of a tile notification.
+ public static TileBindingContentPhotos CreatePhotosTileContent(params Uri[] photoSources)
+ {
+ IEnumerable images = photoSources.Select(u => CreateTileBasicImage(u, default(string), default(bool?)));
- ///
- /// Helper method for creating a tile notification content for using Photos tile template.
- ///
- /// Sources of pictures with description and addImageQuery indicator that will be used for the photos tile.
- /// An instance of represent a payload of a tile notification.
- public static TileBindingContentPhotos CreatePhotosTileContent(params (Uri source, string imageAltText, bool? addImageQuery)[] photos)
- {
- IEnumerable images = photos.Select(t => CreateTileBasicImage(t.source, t.imageAltText, t.addImageQuery));
+ return CreatePhotosTileContent(images);
+ }
- return CreatePhotosTileContent(images);
- }
+ ///
+ /// Helper method for creating a tile notification content for using Photos tile template.
+ ///
+ /// Sources of pictures with description and addImageQuery indicator that will be used for the photos tile.
+ /// An instance of represent a payload of a tile notification.
+ public static TileBindingContentPhotos CreatePhotosTileContent(params (Uri source, string imageAltText, bool? addImageQuery)[] photos)
+ {
+ IEnumerable images = photos.Select(t => CreateTileBasicImage(t.source, t.imageAltText, t.addImageQuery));
- ///
- /// Helper method for creating a tile notification content for using Photos tile template.
- ///
- /// Pictures that will be used for the photos tile.
- /// An instance of represent a payload of a tile notification.
- public static TileBindingContentPhotos CreatePhotosTileContent(IEnumerable photos)
- {
- var photoTileContent = new TileBindingContentPhotos();
+ return CreatePhotosTileContent(images);
+ }
- foreach (var image in photos)
- {
- photoTileContent.Images.Add(image);
- }
+ ///
+ /// Helper method for creating a tile notification content for using Photos tile template.
+ ///
+ /// Pictures that will be used for the photos tile.
+ /// An instance of represent a payload of a tile notification.
+ public static TileBindingContentPhotos CreatePhotosTileContent(IEnumerable photos)
+ {
+ var photoTileContent = new TileBindingContentPhotos();
- return photoTileContent;
+ foreach (var image in photos)
+ {
+ photoTileContent.Images.Add(image);
}
- private static TileBasicImage CreateTileBasicImage(Uri imageUri, string imageAltText, bool? addImageQuery)
- {
- var tileImage = new TileBasicImage();
- tileImage.Source = imageUri.OriginalString;
+ return photoTileContent;
+ }
- if (imageAltText != default(string))
- {
- tileImage.AlternateText = imageAltText;
- }
+ private static TileBasicImage CreateTileBasicImage(Uri imageUri, string imageAltText, bool? addImageQuery)
+ {
+ var tileImage = new TileBasicImage();
+ tileImage.Source = imageUri.OriginalString;
- if (addImageQuery != default(bool?))
- {
- tileImage.AddImageQuery = addImageQuery;
- }
+ if (imageAltText != default(string))
+ {
+ tileImage.AlternateText = imageAltText;
+ }
- return tileImage;
+ if (addImageQuery != default(bool?))
+ {
+ tileImage.AddImageQuery = addImageQuery;
}
+
+ return tileImage;
}
+}
#pragma warning restore SA1008
#pragma warning restore SA1009
-}
+
diff --git a/components/Notifications/src/Tiles/Builder/TileContentBuilder.cs b/components/Notifications/src/Tiles/Builder/TileContentBuilder.cs
index e8e2cb71c..f6ca87b4c 100644
--- a/components/Notifications/src/Tiles/Builder/TileContentBuilder.cs
+++ b/components/Notifications/src/Tiles/Builder/TileContentBuilder.cs
@@ -4,524 +4,523 @@
using System;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// Builder class used to create
+///
+public partial class TileContentBuilder
{
///
- /// Builder class used to create
+ /// Flag used to create all tile size (Small , Medium, Large and Wide)
///
- public partial class TileContentBuilder
- {
- ///
- /// Flag used to create all tile size (Small , Medium, Large and Wide)
- ///
- public const TileSize AllSize = TileSize.Small | TileSize.Medium | TileSize.Large | TileSize.Wide;
+ public const TileSize AllSize = TileSize.Small | TileSize.Medium | TileSize.Large | TileSize.Wide;
- ///
- /// Gets internal instance of . This is equivalent to the call to .
- ///
- public TileContent Content
- {
- get; private set;
- }
+ ///
+ /// Gets internal instance of . This is equivalent to the call to .
+ ///
+ public TileContent Content
+ {
+ get; private set;
+ }
- private TileVisual Visual
+ private TileVisual Visual
+ {
+ get
{
- get
+ if (Content.Visual == null)
{
- if (Content.Visual == null)
- {
- Content.Visual = new TileVisual();
- }
-
- return Content.Visual;
+ Content.Visual = new TileVisual();
}
+
+ return Content.Visual;
}
+ }
- private TileBinding SmallTile
+ private TileBinding SmallTile
+ {
+ get
{
- get
- {
- return Visual.TileSmall;
- }
-
- set
- {
- Visual.TileSmall = value;
- }
+ return Visual.TileSmall;
}
- private TileBinding MediumTile
+ set
{
- get
- {
- return Visual.TileMedium;
- }
-
- set
- {
- Visual.TileMedium = value;
- }
+ Visual.TileSmall = value;
}
+ }
- private TileBinding WideTile
+ private TileBinding MediumTile
+ {
+ get
{
- get
- {
- return Visual.TileWide;
- }
-
- set
- {
- Visual.TileWide = value;
- }
+ return Visual.TileMedium;
}
- private TileBinding LargeTile
+ set
{
- get
- {
- return Visual.TileLarge;
- }
+ Visual.TileMedium = value;
+ }
+ }
- set
- {
- Visual.TileLarge = value;
- }
+ private TileBinding WideTile
+ {
+ get
+ {
+ return Visual.TileWide;
}
- ///
- /// Initializes a new instance of the class.
- ///
- public TileContentBuilder()
+ set
{
- Content = new TileContent();
+ Visual.TileWide = value;
}
+ }
- ///
- /// Add a tile layout size that the notification will be displayed on.
- ///
- /// The size of tile that the notification will be displayed on.
- /// Specialized tile content. Use for special tile template. Default to NULL.
- /// The current instance of
- public TileContentBuilder AddTile(TileSize size, ITileBindingContent tileContent = null)
+ private TileBinding LargeTile
+ {
+ get
{
- if (size.HasFlag(TileSize.Small))
- {
- SmallTile = new TileBinding();
- SmallTile.Content = tileContent ?? new TileBindingContentAdaptive();
- }
+ return Visual.TileLarge;
+ }
- if (size.HasFlag(TileSize.Medium))
- {
- MediumTile = new TileBinding();
- MediumTile.Content = tileContent ?? new TileBindingContentAdaptive();
- }
+ set
+ {
+ Visual.TileLarge = value;
+ }
+ }
- if (size.HasFlag(TileSize.Wide))
- {
- WideTile = new TileBinding();
- WideTile.Content = tileContent ?? new TileBindingContentAdaptive();
- }
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public TileContentBuilder()
+ {
+ Content = new TileContent();
+ }
- if (size.HasFlag(TileSize.Large))
- {
- LargeTile = new TileBinding();
- LargeTile.Content = tileContent ?? new TileBindingContentAdaptive();
- }
+ ///
+ /// Add a tile layout size that the notification will be displayed on.
+ ///
+ /// The size of tile that the notification will be displayed on.
+ /// Specialized tile content. Use for special tile template. Default to NULL.
+ /// The current instance of
+ public TileContentBuilder AddTile(TileSize size, ITileBindingContent tileContent = null)
+ {
+ if (size.HasFlag(TileSize.Small))
+ {
+ SmallTile = new TileBinding();
+ SmallTile.Content = tileContent ?? new TileBindingContentAdaptive();
+ }
- return this;
+ if (size.HasFlag(TileSize.Medium))
+ {
+ MediumTile = new TileBinding();
+ MediumTile.Content = tileContent ?? new TileBindingContentAdaptive();
}
- ///
- /// Set how the tile notification should display the application branding.
- ///
- /// How branding should appear on the tile
- /// The tile size that the parameter should be applied to. Default to all currently supported tile size.
- /// The current instance of
- public TileContentBuilder SetBranding(TileBranding branding, TileSize size = AllSize)
+ if (size.HasFlag(TileSize.Wide))
{
- if (size == AllSize)
- {
- // Set on visual.
- Visual.Branding = branding;
- }
- else
- {
- if (size.HasFlag(TileSize.Small) && SmallTile != null)
- {
- SmallTile.Branding = branding;
- }
-
- if (size.HasFlag(TileSize.Medium) && MediumTile != null)
- {
- MediumTile.Branding = branding;
- }
-
- if (size.HasFlag(TileSize.Wide) && WideTile != null)
- {
- WideTile.Branding = branding;
- }
-
- if (size.HasFlag(TileSize.Large) && LargeTile != null)
- {
- LargeTile.Branding = branding;
- }
- }
+ WideTile = new TileBinding();
+ WideTile.Content = tileContent ?? new TileBindingContentAdaptive();
+ }
- return this;
+ if (size.HasFlag(TileSize.Large))
+ {
+ LargeTile = new TileBinding();
+ LargeTile.Content = tileContent ?? new TileBindingContentAdaptive();
}
- ///
- /// Set the name that will be used to override the application's name on the tile notification.
- ///
- /// Custom name to display on the tile in place of the application's name
- /// The tile size that parameter should be applied to. Default to all currently supported tile size.
- /// The current instance of
- public TileContentBuilder SetDisplayName(string displayName, TileSize size = AllSize)
+ return this;
+ }
+
+ ///
+ /// Set how the tile notification should display the application branding.
+ ///
+ /// How branding should appear on the tile
+ /// The tile size that the parameter should be applied to. Default to all currently supported tile size.
+ /// The current instance of
+ public TileContentBuilder SetBranding(TileBranding branding, TileSize size = AllSize)
+ {
+ if (size == AllSize)
{
- if (size == AllSize)
- {
- // Set on visual.
- Visual.DisplayName = displayName;
- }
- else
+ // Set on visual.
+ Visual.Branding = branding;
+ }
+ else
+ {
+ if (size.HasFlag(TileSize.Small) && SmallTile != null)
{
- if (size.HasFlag(TileSize.Small) && SmallTile != null)
- {
- SmallTile.DisplayName = displayName;
- }
-
- if (size.HasFlag(TileSize.Medium) && MediumTile != null)
- {
- MediumTile.DisplayName = displayName;
- }
-
- if (size.HasFlag(TileSize.Wide) && WideTile != null)
- {
- WideTile.DisplayName = displayName;
- }
-
- if (size.HasFlag(TileSize.Large) && LargeTile != null)
- {
- LargeTile.DisplayName = displayName;
- }
+ SmallTile.Branding = branding;
}
- return this;
- }
-
- ///
- /// Set the optional background image that stays behind the tile notification.
- ///
- /// Source of the background image
- /// The tile size that the background image should be applied to. Default to all currently supported tile size.
- /// Description of the background image, for user of assistance technology
- ///
- /// Indicating whether Windows should 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.
- ///
- /// The opacity of the black overlay on the background image.
- /// Desired cropping of the image.
- /// The current instance of
- public TileContentBuilder SetBackgroundImage(Uri imageUri, TileSize size = AllSize, string alternateText = default(string), bool? addImageQuery = default(bool?), int? hintOverlay = default(int?), TileBackgroundImageCrop hintCrop = TileBackgroundImageCrop.Default)
- {
- TileBackgroundImage backgroundImage = new TileBackgroundImage();
- backgroundImage.Source = imageUri.OriginalString;
- backgroundImage.HintCrop = hintCrop;
-
- if (alternateText != default(string))
+ if (size.HasFlag(TileSize.Medium) && MediumTile != null)
{
- backgroundImage.AlternateText = alternateText;
+ MediumTile.Branding = branding;
}
- if (addImageQuery != default(bool?))
+ if (size.HasFlag(TileSize.Wide) && WideTile != null)
{
- backgroundImage.AddImageQuery = addImageQuery;
+ WideTile.Branding = branding;
}
- if (hintOverlay != default(int?))
+ if (size.HasFlag(TileSize.Large) && LargeTile != null)
{
- backgroundImage.HintOverlay = hintOverlay;
+ LargeTile.Branding = branding;
}
-
- return SetBackgroundImage(backgroundImage, size);
}
- ///
- /// Set the optional background image that stays behind the tile notification.
- ///
- /// An instance of as the background image for the tile.
- /// The tile size that the background image should be applied to. Default to all currently supported tile size.
- /// The current instance of
- public TileContentBuilder SetBackgroundImage(TileBackgroundImage backgroundImage, TileSize size = AllSize)
+ return this;
+ }
+
+ ///
+ /// Set the name that will be used to override the application's name on the tile notification.
+ ///
+ /// Custom name to display on the tile in place of the application's name
+ /// The tile size that parameter should be applied to. Default to all currently supported tile size.
+ /// The current instance of
+ public TileContentBuilder SetDisplayName(string displayName, TileSize size = AllSize)
+ {
+ if (size == AllSize)
+ {
+ // Set on visual.
+ Visual.DisplayName = displayName;
+ }
+ else
{
- // Set to any available tile at the moment of calling.
if (size.HasFlag(TileSize.Small) && SmallTile != null)
{
- GetAdaptiveTileContent(SmallTile).BackgroundImage = backgroundImage;
+ SmallTile.DisplayName = displayName;
}
if (size.HasFlag(TileSize.Medium) && MediumTile != null)
{
- GetAdaptiveTileContent(MediumTile).BackgroundImage = backgroundImage;
+ MediumTile.DisplayName = displayName;
}
if (size.HasFlag(TileSize.Wide) && WideTile != null)
{
- GetAdaptiveTileContent(WideTile).BackgroundImage = backgroundImage;
+ WideTile.DisplayName = displayName;
}
if (size.HasFlag(TileSize.Large) && LargeTile != null)
{
- GetAdaptiveTileContent(LargeTile).BackgroundImage = backgroundImage;
+ LargeTile.DisplayName = displayName;
}
+ }
- return this;
- }
-
- ///
- /// Set the Tile's Peek Image that animate from the top of the tile notification.
- ///
- /// Source of the peek image
- /// The tile size that the peek image should be applied to. Default to all currently supported tile size.
- /// Description of the peek image, for user of assistance technology
- ///
- /// Indicating whether Windows should 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.
- ///
- /// The opacity of the black overlay on the peek image.
- /// Desired cropping of the image.
- /// The current instance of
- public TileContentBuilder SetPeekImage(Uri imageUri, TileSize size = AllSize, string alternateText = default(string), bool? addImageQuery = default(bool?), int? hintOverlay = default(int?), TilePeekImageCrop hintCrop = TilePeekImageCrop.Default)
- {
- TilePeekImage peekImage = new TilePeekImage();
- peekImage.Source = imageUri.OriginalString;
- peekImage.HintCrop = hintCrop;
-
- if (alternateText != default(string))
- {
- peekImage.AlternateText = alternateText;
- }
+ return this;
+ }
- if (addImageQuery != default(bool?))
- {
- peekImage.AddImageQuery = addImageQuery;
- }
+ ///
+ /// Set the optional background image that stays behind the tile notification.
+ ///
+ /// Source of the background image
+ /// The tile size that the background image should be applied to. Default to all currently supported tile size.
+ /// Description of the background image, for user of assistance technology
+ ///
+ /// Indicating whether Windows should 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.
+ ///
+ /// The opacity of the black overlay on the background image.
+ /// Desired cropping of the image.
+ /// The current instance of
+ public TileContentBuilder SetBackgroundImage(Uri imageUri, TileSize size = AllSize, string alternateText = default(string), bool? addImageQuery = default(bool?), int? hintOverlay = default(int?), TileBackgroundImageCrop hintCrop = TileBackgroundImageCrop.Default)
+ {
+ TileBackgroundImage backgroundImage = new TileBackgroundImage();
+ backgroundImage.Source = imageUri.OriginalString;
+ backgroundImage.HintCrop = hintCrop;
- if (hintOverlay != default(int?))
- {
- peekImage.HintOverlay = hintOverlay;
- }
+ if (alternateText != default(string))
+ {
+ backgroundImage.AlternateText = alternateText;
+ }
- return SetPeekImage(peekImage, size);
+ if (addImageQuery != default(bool?))
+ {
+ backgroundImage.AddImageQuery = addImageQuery;
}
- ///
- /// Set the Tile's Peek Image that animate from the top of the tile notification.
- ///
- /// An instance of for the Tile's peek image
- /// The tile size that the peek image should be applied to. Default to all currently supported tile size.
- /// The current instance of
- public TileContentBuilder SetPeekImage(TilePeekImage peekImage, TileSize size = AllSize)
+ if (hintOverlay != default(int?))
{
- // Set to any available tile at the moment of calling.
- if (size.HasFlag(TileSize.Small) && SmallTile != null)
- {
- GetAdaptiveTileContent(SmallTile).PeekImage = peekImage;
- }
+ backgroundImage.HintOverlay = hintOverlay;
+ }
- if (size.HasFlag(TileSize.Medium) && MediumTile != null)
- {
- GetAdaptiveTileContent(MediumTile).PeekImage = peekImage;
- }
+ return SetBackgroundImage(backgroundImage, size);
+ }
- if (size.HasFlag(TileSize.Wide) && WideTile != null)
- {
- GetAdaptiveTileContent(WideTile).PeekImage = peekImage;
- }
+ ///
+ /// Set the optional background image that stays behind the tile notification.
+ ///
+ /// An instance of as the background image for the tile.
+ /// The tile size that the background image should be applied to. Default to all currently supported tile size.
+ /// The current instance of
+ public TileContentBuilder SetBackgroundImage(TileBackgroundImage backgroundImage, TileSize size = AllSize)
+ {
+ // Set to any available tile at the moment of calling.
+ if (size.HasFlag(TileSize.Small) && SmallTile != null)
+ {
+ GetAdaptiveTileContent(SmallTile).BackgroundImage = backgroundImage;
+ }
- if (size.HasFlag(TileSize.Large) && LargeTile != null)
- {
- GetAdaptiveTileContent(LargeTile).PeekImage = peekImage;
- }
+ if (size.HasFlag(TileSize.Medium) && MediumTile != null)
+ {
+ GetAdaptiveTileContent(MediumTile).BackgroundImage = backgroundImage;
+ }
- return this;
+ if (size.HasFlag(TileSize.Wide) && WideTile != null)
+ {
+ GetAdaptiveTileContent(WideTile).BackgroundImage = backgroundImage;
}
- ///
- /// Set the text stacking (vertical alignment) of the entire binding element.
- ///
- /// Text Stacking Option
- /// The tile size that the peek image should be applied to. Default to all currently supported tile size.
- /// The current instance of
- public TileContentBuilder SetTextStacking(TileTextStacking textStacking, TileSize size = AllSize)
+ if (size.HasFlag(TileSize.Large) && LargeTile != null)
{
- // Set to any available tile at the moment of calling.
- if (size.HasFlag(TileSize.Small) && SmallTile != null)
- {
- GetAdaptiveTileContent(SmallTile).TextStacking = textStacking;
- }
+ GetAdaptiveTileContent(LargeTile).BackgroundImage = backgroundImage;
+ }
- if (size.HasFlag(TileSize.Medium) && MediumTile != null)
- {
- GetAdaptiveTileContent(MediumTile).TextStacking = textStacking;
- }
+ return this;
+ }
- if (size.HasFlag(TileSize.Wide) && WideTile != null)
- {
- GetAdaptiveTileContent(WideTile).TextStacking = textStacking;
- }
+ ///
+ /// Set the Tile's Peek Image that animate from the top of the tile notification.
+ ///
+ /// Source of the peek image
+ /// The tile size that the peek image should be applied to. Default to all currently supported tile size.
+ /// Description of the peek image, for user of assistance technology
+ ///
+ /// Indicating whether Windows should 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.
+ ///
+ /// The opacity of the black overlay on the peek image.
+ /// Desired cropping of the image.
+ /// The current instance of
+ public TileContentBuilder SetPeekImage(Uri imageUri, TileSize size = AllSize, string alternateText = default(string), bool? addImageQuery = default(bool?), int? hintOverlay = default(int?), TilePeekImageCrop hintCrop = TilePeekImageCrop.Default)
+ {
+ TilePeekImage peekImage = new TilePeekImage();
+ peekImage.Source = imageUri.OriginalString;
+ peekImage.HintCrop = hintCrop;
- if (size.HasFlag(TileSize.Large) && LargeTile != null)
- {
- GetAdaptiveTileContent(LargeTile).TextStacking = textStacking;
- }
+ if (alternateText != default(string))
+ {
+ peekImage.AlternateText = alternateText;
+ }
- return this;
+ if (addImageQuery != default(bool?))
+ {
+ peekImage.AddImageQuery = addImageQuery;
}
- ///
- /// Set the tile's activation arguments for tile notification.
- ///
- /// App-Defined custom arguments that will be passed in when the user click on the tile when this tile notification is being displayed.
- /// The tile size that the custom argument should be applied to. Default to all currently supported tile size.
- /// The current instance of
- public TileContentBuilder SetActivationArgument(string args, TileSize size = AllSize)
+ if (hintOverlay != default(int?))
{
- if (size == AllSize)
- {
- Visual.Arguments = args;
- }
- else
- {
- if (size.HasFlag(TileSize.Small) && SmallTile != null)
- {
- SmallTile.Arguments = args;
- }
-
- if (size.HasFlag(TileSize.Medium) && MediumTile != null)
- {
- MediumTile.Arguments = args;
- }
-
- if (size.HasFlag(TileSize.Wide) && WideTile != null)
- {
- WideTile.Arguments = args;
- }
-
- if (size.HasFlag(TileSize.Large) && LargeTile != null)
- {
- LargeTile.Arguments = args;
- }
- }
+ peekImage.HintOverlay = hintOverlay;
+ }
- return this;
- }
-
- ///
- /// Add a custom text that will appear on the tile notification.
- ///
- /// Custom text to display on the tile.
- /// The tile size that the custom text would be added to. Default to all currently supported tile size.
- /// Style that controls the text's font size, weight, and opacity.
- /// Indicating whether text wrapping is enabled. For Tiles, this is false by default.
- /// The maximum number of lines the text element is allowed to display. For Tiles, this is infinity by default
- /// The minimum number of lines the text element must display.
- /// The horizontal alignment of the text
- ///
- /// 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.
- ///
- /// The current instance of
- public TileContentBuilder AddText(string text, TileSize size = AllSize, AdaptiveTextStyle? hintStyle = null, bool? hintWrap = default(bool?), int? hintMaxLines = default(int?), int? hintMinLines = default(int?), AdaptiveTextAlign? hintAlign = null, string language = default(string))
- {
- // Create the adaptive text.
- AdaptiveText adaptive = new AdaptiveText()
- {
- Text = text
- };
+ return SetPeekImage(peekImage, size);
+ }
- if (hintStyle != null)
- {
- adaptive.HintStyle = hintStyle.Value;
- }
+ ///
+ /// Set the Tile's Peek Image that animate from the top of the tile notification.
+ ///
+ /// An instance of for the Tile's peek image
+ /// The tile size that the peek image should be applied to. Default to all currently supported tile size.
+ /// The current instance of
+ public TileContentBuilder SetPeekImage(TilePeekImage peekImage, TileSize size = AllSize)
+ {
+ // Set to any available tile at the moment of calling.
+ if (size.HasFlag(TileSize.Small) && SmallTile != null)
+ {
+ GetAdaptiveTileContent(SmallTile).PeekImage = peekImage;
+ }
- if (hintAlign != null)
- {
- adaptive.HintAlign = hintAlign.Value;
- }
+ if (size.HasFlag(TileSize.Medium) && MediumTile != null)
+ {
+ GetAdaptiveTileContent(MediumTile).PeekImage = peekImage;
+ }
- if (hintWrap != default(bool?))
- {
- adaptive.HintWrap = hintWrap;
- }
+ if (size.HasFlag(TileSize.Wide) && WideTile != null)
+ {
+ GetAdaptiveTileContent(WideTile).PeekImage = peekImage;
+ }
- if (hintMaxLines != default(int?))
- {
- adaptive.HintMaxLines = hintMaxLines;
- }
+ if (size.HasFlag(TileSize.Large) && LargeTile != null)
+ {
+ GetAdaptiveTileContent(LargeTile).PeekImage = peekImage;
+ }
- if (hintMinLines != default(int?) && hintMinLines > 0)
- {
- adaptive.HintMinLines = hintMinLines;
- }
+ return this;
+ }
- if (language != default(string))
- {
- adaptive.Language = language;
- }
+ ///
+ /// Set the text stacking (vertical alignment) of the entire binding element.
+ ///
+ /// Text Stacking Option
+ /// The tile size that the peek image should be applied to. Default to all currently supported tile size.
+ /// The current instance of
+ public TileContentBuilder SetTextStacking(TileTextStacking textStacking, TileSize size = AllSize)
+ {
+ // Set to any available tile at the moment of calling.
+ if (size.HasFlag(TileSize.Small) && SmallTile != null)
+ {
+ GetAdaptiveTileContent(SmallTile).TextStacking = textStacking;
+ }
- // Add to the tile content
- return AddAdaptiveTileVisualChild(adaptive, size);
+ if (size.HasFlag(TileSize.Medium) && MediumTile != null)
+ {
+ GetAdaptiveTileContent(MediumTile).TextStacking = textStacking;
}
- ///
- /// Add an adaptive child to the tile notification.
- ///
- /// An adaptive child to add
- /// Tile size that the adaptive child should be added to. Default to all currently supported tile size.
- /// The current instance of
- ///
- /// This can be used to add Group and Subgroup to the tile.
- ///
- public TileContentBuilder AddAdaptiveTileVisualChild(ITileBindingContentAdaptiveChild child, TileSize size = AllSize)
+ if (size.HasFlag(TileSize.Wide) && WideTile != null)
{
- if (size.HasFlag(TileSize.Small) && SmallTile != null && GetAdaptiveTileContent(SmallTile) != null)
+ GetAdaptiveTileContent(WideTile).TextStacking = textStacking;
+ }
+
+ if (size.HasFlag(TileSize.Large) && LargeTile != null)
+ {
+ GetAdaptiveTileContent(LargeTile).TextStacking = textStacking;
+ }
+
+ return this;
+ }
+
+ ///
+ /// Set the tile's activation arguments for tile notification.
+ ///
+ /// App-Defined custom arguments that will be passed in when the user click on the tile when this tile notification is being displayed.
+ /// The tile size that the custom argument should be applied to. Default to all currently supported tile size.
+ /// The current instance of
+ public TileContentBuilder SetActivationArgument(string args, TileSize size = AllSize)
+ {
+ if (size == AllSize)
+ {
+ Visual.Arguments = args;
+ }
+ else
+ {
+ if (size.HasFlag(TileSize.Small) && SmallTile != null)
{
- GetAdaptiveTileContent(SmallTile).Children.Add(child);
+ SmallTile.Arguments = args;
}
- if (size.HasFlag(TileSize.Medium) && MediumTile != null && GetAdaptiveTileContent(MediumTile) != null)
+ if (size.HasFlag(TileSize.Medium) && MediumTile != null)
{
- GetAdaptiveTileContent(MediumTile).Children.Add(child);
+ MediumTile.Arguments = args;
}
- if (size.HasFlag(TileSize.Wide) && WideTile != null && GetAdaptiveTileContent(WideTile) != null)
+ if (size.HasFlag(TileSize.Wide) && WideTile != null)
{
- GetAdaptiveTileContent(WideTile).Children.Add(child);
+ WideTile.Arguments = args;
}
- if (size.HasFlag(TileSize.Large) && LargeTile != null && GetAdaptiveTileContent(LargeTile) != null)
+ if (size.HasFlag(TileSize.Large) && LargeTile != null)
{
- GetAdaptiveTileContent(LargeTile).Children.Add(child);
+ LargeTile.Arguments = args;
}
+ }
+
+ return this;
+ }
+
+ ///
+ /// Add a custom text that will appear on the tile notification.
+ ///
+ /// Custom text to display on the tile.
+ /// The tile size that the custom text would be added to. Default to all currently supported tile size.
+ /// Style that controls the text's font size, weight, and opacity.
+ /// Indicating whether text wrapping is enabled. For Tiles, this is false by default.
+ /// The maximum number of lines the text element is allowed to display. For Tiles, this is infinity by default
+ /// The minimum number of lines the text element must display.
+ /// The horizontal alignment of the text
+ ///
+ /// 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.
+ ///
+ /// The current instance of
+ public TileContentBuilder AddText(string text, TileSize size = AllSize, AdaptiveTextStyle? hintStyle = null, bool? hintWrap = default(bool?), int? hintMaxLines = default(int?), int? hintMinLines = default(int?), AdaptiveTextAlign? hintAlign = null, string language = default(string))
+ {
+ // Create the adaptive text.
+ AdaptiveText adaptive = new AdaptiveText()
+ {
+ Text = text
+ };
+
+ if (hintStyle != null)
+ {
+ adaptive.HintStyle = hintStyle.Value;
+ }
+
+ if (hintAlign != null)
+ {
+ adaptive.HintAlign = hintAlign.Value;
+ }
- return this;
+ if (hintWrap != default(bool?))
+ {
+ adaptive.HintWrap = hintWrap;
+ }
+
+ if (hintMaxLines != default(int?))
+ {
+ adaptive.HintMaxLines = hintMaxLines;
+ }
+
+ if (hintMinLines != default(int?) && hintMinLines > 0)
+ {
+ adaptive.HintMinLines = hintMinLines;
+ }
+
+ if (language != default(string))
+ {
+ adaptive.Language = language;
+ }
+
+ // Add to the tile content
+ return AddAdaptiveTileVisualChild(adaptive, size);
+ }
+
+ ///
+ /// Add an adaptive child to the tile notification.
+ ///
+ /// An adaptive child to add
+ /// Tile size that the adaptive child should be added to. Default to all currently supported tile size.
+ /// The current instance of
+ ///
+ /// This can be used to add Group and Subgroup to the tile.
+ ///
+ public TileContentBuilder AddAdaptiveTileVisualChild(ITileBindingContentAdaptiveChild child, TileSize size = AllSize)
+ {
+ if (size.HasFlag(TileSize.Small) && SmallTile != null && GetAdaptiveTileContent(SmallTile) != null)
+ {
+ GetAdaptiveTileContent(SmallTile).Children.Add(child);
+ }
+
+ if (size.HasFlag(TileSize.Medium) && MediumTile != null && GetAdaptiveTileContent(MediumTile) != null)
+ {
+ GetAdaptiveTileContent(MediumTile).Children.Add(child);
}
- ///
- /// Get the instance of that has been built by the builder with specified configuration so far.
- ///
- /// An instance of that can be used to create tile notification.
- public TileContent GetTileContent()
+ if (size.HasFlag(TileSize.Wide) && WideTile != null && GetAdaptiveTileContent(WideTile) != null)
{
- return Content;
+ GetAdaptiveTileContent(WideTile).Children.Add(child);
}
- private TileBindingContentAdaptive GetAdaptiveTileContent(TileBinding binding)
+ if (size.HasFlag(TileSize.Large) && LargeTile != null && GetAdaptiveTileContent(LargeTile) != null)
{
- return binding.Content as TileBindingContentAdaptive;
+ GetAdaptiveTileContent(LargeTile).Children.Add(child);
}
+
+ return this;
+ }
+
+ ///
+ /// Get the instance of that has been built by the builder with specified configuration so far.
+ ///
+ /// An instance of that can be used to create tile notification.
+ public TileContent GetTileContent()
+ {
+ return Content;
+ }
+
+ private TileBindingContentAdaptive GetAdaptiveTileContent(TileBinding binding)
+ {
+ return binding.Content as TileBindingContentAdaptive;
}
}
diff --git a/components/Notifications/src/Tiles/Elements/Element_Tile.cs b/components/Notifications/src/Tiles/Elements/Element_Tile.cs
index de1db439c..3cacc013b 100644
--- a/components/Notifications/src/Tiles/Elements/Element_Tile.cs
+++ b/components/Notifications/src/Tiles/Elements/Element_Tile.cs
@@ -4,16 +4,15 @@
using System.Collections.Generic;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+internal sealed class Element_Tile : BaseElement, IHaveXmlName, IHaveXmlChildren
{
- internal sealed class Element_Tile : BaseElement, IHaveXmlName, IHaveXmlChildren
- {
- public Element_TileVisual Visual { get; set; }
+ public Element_TileVisual Visual { get; set; }
- ///
- string IHaveXmlName.Name => "tile";
+ ///
+ string IHaveXmlName.Name => "tile";
- ///
- IEnumerable IHaveXmlChildren.Children => new[] { Visual };
- }
+ ///
+ IEnumerable IHaveXmlChildren.Children => new[] { Visual };
}
\ No newline at end of file
diff --git a/components/Notifications/src/Tiles/Elements/Element_TileBinding.cs b/components/Notifications/src/Tiles/Elements/Element_TileBinding.cs
index 1125354e7..7250b294a 100644
--- a/components/Notifications/src/Tiles/Elements/Element_TileBinding.cs
+++ b/components/Notifications/src/Tiles/Elements/Element_TileBinding.cs
@@ -5,142 +5,141 @@
using System;
using System.Collections.Generic;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+internal sealed class Element_TileBinding : IElementWithDescendants, IHaveXmlName, IHaveXmlNamedProperties, IHaveXmlChildren
{
- internal sealed class Element_TileBinding : IElementWithDescendants, IHaveXmlName, IHaveXmlNamedProperties, IHaveXmlChildren
+ 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)
{
- internal const TileBranding DEFAULT_BRANDING = TileBranding.Auto;
- internal const TileTextStacking DEFAULT_TEXT_STACKING = TileTextStacking.Top;
- internal const int DEFAULT_OVERLAY = 20;
+ Template = template;
+ }
- public Element_TileBinding(TileTemplateNameV3 template)
+ public TileTemplateNameV3 Template { get; private set; }
+
+ ///
+ /// Gets or sets a value whether Windows should 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&ms-contrast=standard&ms-lang=en-us"
+ ///
+ public bool? AddImageQuery { get; set; }
+
+ ///
+ /// Gets or sets a default base URI that is combined with relative URIs in image source attributes.
+ ///
+ public Uri BaseUri { get; set; }
+
+ ///
+ /// Gets or sets the form that the Tile should use to display the app's brand.
+ ///
+ public TileBranding Branding { get; set; } = DEFAULT_BRANDING;
+
+ ///
+ /// Gets or sets 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
+ ///
+ public string ContentId { get; set; }
+
+ ///
+ /// Gets or sets an optional string to override the Tile's display name while showing this notification.
+ ///
+ public string DisplayName { get; set; }
+
+ ///
+ /// Gets or sets 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 overridden 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.
+ ///
+ public string Language { get; set; }
+
+ public string LockDetailedStatus1 { get; set; }
+
+ public string LockDetailedStatus2 { get; set; }
+
+ public string LockDetailedStatus3 { get; set; }
+
+ public string Arguments { get; set; }
+
+ ///
+ /// Throws exception if value is invalid
+ ///
+ /// Overlay value (0-100)
+ internal static void CheckOverlayValue(int value)
+ {
+ if (value < 0 || value > 100)
{
- Template = template;
- }
-
- public TileTemplateNameV3 Template { get; private set; }
-
- ///
- /// Gets or sets a value whether Windows should 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&ms-contrast=standard&ms-lang=en-us"
- ///
- public bool? AddImageQuery { get; set; }
-
- ///
- /// Gets or sets a default base URI that is combined with relative URIs in image source attributes.
- ///
- public Uri BaseUri { get; set; }
-
- ///
- /// Gets or sets the form that the Tile should use to display the app's brand.
- ///
- public TileBranding Branding { get; set; } = DEFAULT_BRANDING;
-
- ///
- /// Gets or sets 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
- ///
- public string ContentId { get; set; }
-
- ///
- /// Gets or sets an optional string to override the Tile's display name while showing this notification.
- ///
- public string DisplayName { get; set; }
-
- ///
- /// Gets or sets 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 overridden 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.
- ///
- public string Language { get; set; }
-
- public string LockDetailedStatus1 { get; set; }
-
- public string LockDetailedStatus2 { get; set; }
-
- public string LockDetailedStatus3 { get; set; }
-
- public string Arguments { get; set; }
-
- ///
- /// Throws exception if value is invalid
- ///
- /// Overlay value (0-100)
- internal static void CheckOverlayValue(int value)
- {
- if (value < 0 || value > 100)
- {
- throw new ArgumentOutOfRangeException("Overlay must be between 0 and 100, inclusive.");
- }
+ throw new ArgumentOutOfRangeException("Overlay must be between 0 and 100, inclusive.");
}
+ }
- public TilePresentation? Presentation { get; set; }
+ public TilePresentation? Presentation { get; set; }
- public TileTextStacking TextStacking { get; set; } = DEFAULT_TEXT_STACKING;
+ public TileTextStacking TextStacking { get; set; } = DEFAULT_TEXT_STACKING;
- public IList Children { get; private set; } = new List();
+ public IList Children { get; private set; } = new List();
- ///
- /// Generates an enumerable collection of children and all those children's children
- ///
- /// Enumerable collection of children and all those children's children.
- public IEnumerable Descendants()
+ ///
+ /// Generates an enumerable collection of children and all those children's children
+ ///
+ /// Enumerable collection of children and all those children's children.
+ public IEnumerable Descendants()
+ {
+ foreach (IElement_TileBindingChild child in Children)
{
- foreach (IElement_TileBindingChild child in Children)
- {
- // Return the child
- yield return child;
+ // Return the child
+ yield return child;
- // And if it has descendants, return the descendants
- if (child is IElementWithDescendants)
+ // And if it has descendants, return the descendants
+ if (child is IElementWithDescendants)
+ {
+ foreach (object descendant in (child as IElementWithDescendants).Descendants())
{
- foreach (object descendant in (child as IElementWithDescendants).Descendants())
- {
- yield return descendant;
- }
+ yield return descendant;
}
}
}
+ }
- ///
- string IHaveXmlName.Name => "binding";
+ ///
+ string IHaveXmlName.Name => "binding";
- ///
- IEnumerable IHaveXmlChildren.Children => Children;
+ ///
+ IEnumerable IHaveXmlChildren.Children => Children;
- ///
- IEnumerable> IHaveXmlNamedProperties.EnumerateNamedProperties()
- {
- yield return new("template", Template);
- yield return new("addImageQuery", AddImageQuery);
- yield return new("baseUri", BaseUri);
+ ///
+ IEnumerable> IHaveXmlNamedProperties.EnumerateNamedProperties()
+ {
+ yield return new("template", Template);
+ yield return new("addImageQuery", AddImageQuery);
+ yield return new("baseUri", BaseUri);
- if (Branding != DEFAULT_BRANDING)
- {
- yield return new("branding", Branding);
- }
+ if (Branding != DEFAULT_BRANDING)
+ {
+ yield return new("branding", Branding);
+ }
- yield return new("contentId", ContentId);
- yield return new("displayName", DisplayName);
- yield return new("lang", Language);
- yield return new("hint-lockDetailedStatus1", LockDetailedStatus1);
- yield return new("hint-lockDetailedStatus2", LockDetailedStatus2);
- yield return new("hint-lockDetailedStatus3", LockDetailedStatus3);
- yield return new("arguments", Arguments);
- yield return new("hint-presentation", Presentation.ToPascalCaseString());
+ yield return new("contentId", ContentId);
+ yield return new("displayName", DisplayName);
+ yield return new("lang", Language);
+ yield return new("hint-lockDetailedStatus1", LockDetailedStatus1);
+ yield return new("hint-lockDetailedStatus2", LockDetailedStatus2);
+ yield return new("hint-lockDetailedStatus3", LockDetailedStatus3);
+ yield return new("arguments", Arguments);
+ yield return new("hint-presentation", Presentation.ToPascalCaseString());
- if (TextStacking != DEFAULT_TEXT_STACKING)
- {
- yield return new("hint-textStacking", TextStacking.ToPascalCaseString());
- }
+ if (TextStacking != DEFAULT_TEXT_STACKING)
+ {
+ yield return new("hint-textStacking", TextStacking.ToPascalCaseString());
}
}
+}
- internal interface IElement_TileBindingChild
- {
- }
+internal interface IElement_TileBindingChild
+{
}
\ No newline at end of file
diff --git a/components/Notifications/src/Tiles/Elements/Element_TileVisual.cs b/components/Notifications/src/Tiles/Elements/Element_TileVisual.cs
index d4a59a30f..71dfc5726 100644
--- a/components/Notifications/src/Tiles/Elements/Element_TileVisual.cs
+++ b/components/Notifications/src/Tiles/Elements/Element_TileVisual.cs
@@ -5,50 +5,49 @@
using System;
using System.Collections.Generic;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+internal sealed class Element_TileVisual : IHaveXmlName, IHaveXmlNamedProperties, IHaveXmlChildren
{
- internal sealed class Element_TileVisual : IHaveXmlName, IHaveXmlNamedProperties, IHaveXmlChildren
- {
- internal const TileBranding DEFAULT_BRANDING = TileBranding.Auto;
- internal const bool DEFAULT_ADD_IMAGE_QUERY = false;
+ internal const TileBranding DEFAULT_BRANDING = TileBranding.Auto;
+ internal const bool DEFAULT_ADD_IMAGE_QUERY = false;
- public bool? AddImageQuery { get; set; }
+ public bool? AddImageQuery { get; set; }
- public Uri BaseUri { get; set; }
+ public Uri BaseUri { get; set; }
- public TileBranding Branding { get; set; } = DEFAULT_BRANDING;
+ public TileBranding Branding { get; set; } = DEFAULT_BRANDING;
- public string ContentId { get; set; }
+ public string ContentId { get; set; }
- public string DisplayName { get; set; }
+ public string DisplayName { get; set; }
- public string Language { get; set; }
+ public string Language { get; set; }
- public string Arguments { get; set; }
+ public string Arguments { get; set; }
- public IList Bindings { get; private set; } = new List();
+ public IList Bindings { get; private set; } = new List();
- ///
- string IHaveXmlName.Name => "visual";
+ ///
+ string IHaveXmlName.Name => "visual";
- ///
- IEnumerable IHaveXmlChildren.Children => Bindings;
+ ///
+ IEnumerable IHaveXmlChildren.Children => Bindings;
- ///
- IEnumerable> IHaveXmlNamedProperties.EnumerateNamedProperties()
+ ///
+ IEnumerable> IHaveXmlNamedProperties.EnumerateNamedProperties()
+ {
+ yield return new("addImageQuery", AddImageQuery);
+ yield return new("baseUri", BaseUri);
+
+ if (Branding != DEFAULT_BRANDING)
{
- yield return new("addImageQuery", AddImageQuery);
- yield return new("baseUri", BaseUri);
-
- if (Branding != DEFAULT_BRANDING)
- {
- yield return new("branding", Branding.ToPascalCaseString());
- }
-
- yield return new("contentId", ContentId);
- yield return new("displayName", DisplayName);
- yield return new("lang", Language);
- yield return new("arguments", Arguments);
+ yield return new("branding", Branding.ToPascalCaseString());
}
+
+ yield return new("contentId", ContentId);
+ yield return new("displayName", DisplayName);
+ yield return new("lang", Language);
+ yield return new("arguments", Arguments);
}
}
\ No newline at end of file
diff --git a/components/Notifications/src/Tiles/Elements/TileElementsCommon.cs b/components/Notifications/src/Tiles/Elements/TileElementsCommon.cs
index f5b808fdd..e7c63cbed 100644
--- a/components/Notifications/src/Tiles/Elements/TileElementsCommon.cs
+++ b/components/Notifications/src/Tiles/Elements/TileElementsCommon.cs
@@ -2,19 +2,18 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+internal enum TilePresentation
{
- internal enum TilePresentation
- {
- People,
- Photos,
- Contact
- }
+ People,
+ Photos,
+ Contact
+}
- internal enum TileImagePlacement
- {
- Inline,
- Background,
- Peek
- }
+internal enum TileImagePlacement
+{
+ Inline,
+ Background,
+ Peek
}
\ No newline at end of file
diff --git a/components/Notifications/src/Tiles/ITileBindingContentAdaptiveChild.cs b/components/Notifications/src/Tiles/ITileBindingContentAdaptiveChild.cs
index 5c9ad93e8..e5ec0eb5a 100644
--- a/components/Notifications/src/Tiles/ITileBindingContentAdaptiveChild.cs
+++ b/components/Notifications/src/Tiles/ITileBindingContentAdaptiveChild.cs
@@ -2,13 +2,12 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// Elements that can be direct children of , including ( , , and ).
+///
+public interface ITileBindingContentAdaptiveChild
{
- ///
- /// Elements that can be direct children of , including ( , , and ).
- ///
- public interface ITileBindingContentAdaptiveChild
- {
- // Blank interface simply for compile-enforcing the child types in the list.
- }
+ // Blank interface simply for compile-enforcing the child types in the list.
}
\ No newline at end of file
diff --git a/components/Notifications/src/Tiles/SpecialTemplates/TileBindingContentContact.cs b/components/Notifications/src/Tiles/SpecialTemplates/TileBindingContentContact.cs
index 865bb849e..9af5c5f6b 100644
--- a/components/Notifications/src/Tiles/SpecialTemplates/TileBindingContentContact.cs
+++ b/components/Notifications/src/Tiles/SpecialTemplates/TileBindingContentContact.cs
@@ -2,42 +2,41 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// Phone-only. Supported on Small, Medium, and Wide.
+///
+public sealed class TileBindingContentContact : ITileBindingContent
{
///
- /// Phone-only. Supported on Small, Medium, and Wide.
+ /// Gets or sets the image to display.
///
- public sealed class TileBindingContentContact : ITileBindingContent
+ public TileBasicImage Image { get; set; }
+
+ ///
+ /// Gets or sets a line of text that is displayed. Not displayed on Small Tile.
+ ///
+ public TileBasicText Text { get; set; }
+
+ internal TileTemplateNameV3 GetTemplateName(TileSize size)
{
- ///
- /// Gets or sets the image to display.
- ///
- public TileBasicImage Image { get; set; }
+ return TileSizeToAdaptiveTemplateConverter.Convert(size);
+ }
- ///
- /// Gets or sets a line of text that is displayed. Not displayed on Small Tile.
- ///
- public TileBasicText Text { get; set; }
+ internal void PopulateElement(Element_TileBinding binding, TileSize size)
+ {
+ binding.Presentation = TilePresentation.Contact;
- internal TileTemplateNameV3 GetTemplateName(TileSize size)
+ // Small size doesn't display the text, so no reason to include it in the payload
+ if (Text != null && size != TileSize.Small)
{
- return TileSizeToAdaptiveTemplateConverter.Convert(size);
+ binding.Children.Add(Text.ConvertToElement());
}
- internal void PopulateElement(Element_TileBinding binding, TileSize size)
+ if (Image != null)
{
- binding.Presentation = TilePresentation.Contact;
-
- // Small size doesn't display the text, so no reason to include it in the payload
- if (Text != null && size != TileSize.Small)
- {
- binding.Children.Add(Text.ConvertToElement());
- }
-
- if (Image != null)
- {
- binding.Children.Add(Image.ConvertToElement());
- }
+ binding.Children.Add(Image.ConvertToElement());
}
}
}
\ No newline at end of file
diff --git a/components/Notifications/src/Tiles/SpecialTemplates/TileBindingContentIconic.cs b/components/Notifications/src/Tiles/SpecialTemplates/TileBindingContentIconic.cs
index 686278736..d4ea949d6 100644
--- a/components/Notifications/src/Tiles/SpecialTemplates/TileBindingContentIconic.cs
+++ b/components/Notifications/src/Tiles/SpecialTemplates/TileBindingContentIconic.cs
@@ -4,41 +4,40 @@
using System;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// Supported on Small and Medium. Enables an iconic Tile template, where you can have an icon and badge display next to each other on the Tile, in true classic Windows Phone style. The number next to the icon is achieved through a separate badge notification.
+///
+public sealed class TileBindingContentIconic : ITileBindingContent
{
///
- /// Supported on Small and Medium. Enables an iconic Tile template, where you can have an icon and badge display next to each other on the Tile, in true classic Windows Phone style. The number next to the icon is achieved through a separate badge notification.
+ /// Gets or sets, at minimum, to support both Desktop and Phone, Small and Medium tiles, a square aspect ratio image with a resolution of 200x200, PNG format, with transparency and no color other than white. For more info see: http://blogs.msdn.com/b/tiles_and_toasts/archive/2015/07/31/iconic-tile-template-for-windows-10.aspx
///
- public sealed class TileBindingContentIconic : ITileBindingContent
- {
- ///
- /// Gets or sets, at minimum, to support both Desktop and Phone, Small and Medium tiles, a square aspect ratio image with a resolution of 200x200, PNG format, with transparency and no color other than white. For more info see: http://blogs.msdn.com/b/tiles_and_toasts/archive/2015/07/31/iconic-tile-template-for-windows-10.aspx
- ///
- public TileBasicImage Icon { get; set; }
+ public TileBasicImage Icon { get; set; }
- internal TileTemplateNameV3 GetTemplateName(TileSize size)
+ internal TileTemplateNameV3 GetTemplateName(TileSize size)
+ {
+ switch (size)
{
- switch (size)
- {
- case TileSize.Small:
- return TileTemplateNameV3.TileSquare71x71IconWithBadge;
+ case TileSize.Small:
+ return TileTemplateNameV3.TileSquare71x71IconWithBadge;
- case TileSize.Medium:
- return TileTemplateNameV3.TileSquare150x150IconWithBadge;
+ case TileSize.Medium:
+ return TileTemplateNameV3.TileSquare150x150IconWithBadge;
- default:
- throw new ArgumentException("The Iconic template is only supported on Small and Medium tiles.");
- }
+ default:
+ throw new ArgumentException("The Iconic template is only supported on Small and Medium tiles.");
}
+ }
- internal void PopulateElement(Element_TileBinding binding, TileSize size)
+ internal void PopulateElement(Element_TileBinding binding, TileSize size)
+ {
+ if (Icon != null)
{
- if (Icon != null)
- {
- var element = Icon.ConvertToElement();
- element.Id = 1;
- binding.Children.Add(element);
- }
+ var element = Icon.ConvertToElement();
+ element.Id = 1;
+ binding.Children.Add(element);
}
}
}
\ No newline at end of file
diff --git a/components/Notifications/src/Tiles/SpecialTemplates/TileBindingContentPeople.cs b/components/Notifications/src/Tiles/SpecialTemplates/TileBindingContentPeople.cs
index 4f5fdcd42..46eab82b3 100644
--- a/components/Notifications/src/Tiles/SpecialTemplates/TileBindingContentPeople.cs
+++ b/components/Notifications/src/Tiles/SpecialTemplates/TileBindingContentPeople.cs
@@ -4,32 +4,31 @@
using System.Collections.Generic;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// New in 1511: Supported on Medium, Wide, and Large (Desktop and Mobile).
+/// Previously for RTM: Phone-only. Supported on Medium and Wide.
+///
+public sealed class TileBindingContentPeople : ITileBindingContent
{
///
- /// New in 1511: Supported on Medium, Wide, and Large (Desktop and Mobile).
- /// Previously for RTM: Phone-only. Supported on Medium and Wide.
+ /// Gets images that will roll around as circles.
///
- public sealed class TileBindingContentPeople : ITileBindingContent
+ public IList Images { get; private set; } = new List();
+
+ internal TileTemplateNameV3 GetTemplateName(TileSize size)
{
- ///
- /// Gets images that will roll around as circles.
- ///
- public IList Images { get; private set; } = new List();
+ return TileSizeToAdaptiveTemplateConverter.Convert(size);
+ }
- internal TileTemplateNameV3 GetTemplateName(TileSize size)
- {
- return TileSizeToAdaptiveTemplateConverter.Convert(size);
- }
+ internal void PopulateElement(Element_TileBinding binding, TileSize size)
+ {
+ binding.Presentation = TilePresentation.People;
- internal void PopulateElement(Element_TileBinding binding, TileSize size)
+ foreach (var img in Images)
{
- binding.Presentation = TilePresentation.People;
-
- foreach (var img in Images)
- {
- binding.Children.Add(img.ConvertToElement());
- }
+ binding.Children.Add(img.ConvertToElement());
}
}
}
\ No newline at end of file
diff --git a/components/Notifications/src/Tiles/SpecialTemplates/TileBindingContentPhotos.cs b/components/Notifications/src/Tiles/SpecialTemplates/TileBindingContentPhotos.cs
index baa5de892..0774bef81 100644
--- a/components/Notifications/src/Tiles/SpecialTemplates/TileBindingContentPhotos.cs
+++ b/components/Notifications/src/Tiles/SpecialTemplates/TileBindingContentPhotos.cs
@@ -4,31 +4,30 @@
using System.Collections.Generic;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// Animates through a slide show of photos. Supported on all sizes.
+///
+public sealed class TileBindingContentPhotos : ITileBindingContent
{
///
- /// Animates through a slide show of photos. Supported on all sizes.
+ /// Gets the collection of slide show images. Up to 12 images can be provided (Mobile will only display up to 9), which will be used for the slide show. Adding more than 12 will throw an exception.
///
- public sealed class TileBindingContentPhotos : ITileBindingContent
+ public IList Images { get; private set; } = new LimitedList(12);
+
+ internal TileTemplateNameV3 GetTemplateName(TileSize size)
{
- ///
- /// Gets the collection of slide show images. Up to 12 images can be provided (Mobile will only display up to 9), which will be used for the slide show. Adding more than 12 will throw an exception.
- ///
- public IList Images { get; private set; } = new LimitedList(12);
+ return TileSizeToAdaptiveTemplateConverter.Convert(size);
+ }
- internal TileTemplateNameV3 GetTemplateName(TileSize size)
- {
- return TileSizeToAdaptiveTemplateConverter.Convert(size);
- }
+ internal void PopulateElement(Element_TileBinding binding, TileSize size)
+ {
+ binding.Presentation = TilePresentation.Photos;
- internal void PopulateElement(Element_TileBinding binding, TileSize size)
+ foreach (var img in Images)
{
- binding.Presentation = TilePresentation.Photos;
-
- foreach (var img in Images)
- {
- binding.Children.Add(img.ConvertToElement());
- }
+ binding.Children.Add(img.ConvertToElement());
}
}
}
\ No newline at end of file
diff --git a/components/Notifications/src/Tiles/TileBackgroundImage.cs b/components/Notifications/src/Tiles/TileBackgroundImage.cs
index b326d2825..556cbe523 100644
--- a/components/Notifications/src/Tiles/TileBackgroundImage.cs
+++ b/components/Notifications/src/Tiles/TileBackgroundImage.cs
@@ -4,87 +4,86 @@
using CommunityToolkit.Notifications.Adaptive.Elements;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// A full-bleed background image that appears beneath the Tile content.
+///
+public sealed class TileBackgroundImage : IBaseImage
{
+ private string _source;
+
///
- /// A full-bleed background image that appears beneath the Tile content.
+ /// Gets or sets 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.
///
- public sealed class TileBackgroundImage : IBaseImage
+ public string Source
{
- private string _source;
+ get { return _source; }
+ set { BaseImageHelper.SetSource(ref _source, value); }
+ }
- ///
- /// Gets or sets 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.
- ///
- public string Source
- {
- get { return _source; }
- set { BaseImageHelper.SetSource(ref _source, value); }
- }
+ ///
+ /// Gets or sets a description of the image, for users of assistive technologies.
+ ///
+ public string AlternateText { get; set; }
- ///
- /// Gets or sets a description of the image, for users of assistive technologies.
- ///
- public string AlternateText { get; set; }
+ ///
+ /// Gets or sets a value whether Windows should 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.
+ ///
+ public bool? AddImageQuery { get; set; }
- ///
- /// Gets or sets a value whether Windows should 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.
- ///
- public bool? AddImageQuery { get; set; }
+ private int? _hintOverlay;
- private int? _hintOverlay;
+ ///
+ /// Gets or sets a black overlay on the background image. This value controls the opacity of the black overlay, with 0 being no overlay and 100 being completely black. Defaults to 20.
+ ///
+ public int? HintOverlay
+ {
+ get
+ {
+ return _hintOverlay;
+ }
- ///
- /// Gets or sets a black overlay on the background image. This value controls the opacity of the black overlay, with 0 being no overlay and 100 being completely black. Defaults to 20.
- ///
- public int? HintOverlay
+ set
{
- get
+ if (value != null)
{
- return _hintOverlay;
+ Element_TileBinding.CheckOverlayValue(value.Value);
}
- set
- {
- if (value != null)
- {
- Element_TileBinding.CheckOverlayValue(value.Value);
- }
-
- _hintOverlay = value;
- }
+ _hintOverlay = value;
}
+ }
- ///
- /// Gets or sets the desired cropping of the image.
- /// Previously for RTM: Did not exist, value will be ignored and background image will be displayed without any cropping.
- ///
- public TileBackgroundImageCrop HintCrop { get; set; }
+ ///
+ /// Gets or sets the desired cropping of the image.
+ /// Previously for RTM: Did not exist, value will be ignored and background image will be displayed without any cropping.
+ ///
+ public TileBackgroundImageCrop HintCrop { get; set; }
- internal Element_AdaptiveImage ConvertToElement()
- {
- Element_AdaptiveImage image = BaseImageHelper.CreateBaseElement(this);
+ internal Element_AdaptiveImage ConvertToElement()
+ {
+ Element_AdaptiveImage image = BaseImageHelper.CreateBaseElement(this);
- image.Placement = AdaptiveImagePlacement.Background;
- image.Crop = GetAdaptiveImageCrop();
- image.Overlay = HintOverlay;
+ image.Placement = AdaptiveImagePlacement.Background;
+ image.Crop = GetAdaptiveImageCrop();
+ image.Overlay = HintOverlay;
- return image;
- }
+ return image;
+ }
- private AdaptiveImageCrop GetAdaptiveImageCrop()
+ private AdaptiveImageCrop GetAdaptiveImageCrop()
+ {
+ switch (HintCrop)
{
- switch (HintCrop)
- {
- case TileBackgroundImageCrop.Circle:
- return AdaptiveImageCrop.Circle;
+ case TileBackgroundImageCrop.Circle:
+ return AdaptiveImageCrop.Circle;
- case TileBackgroundImageCrop.None:
- return AdaptiveImageCrop.None;
+ case TileBackgroundImageCrop.None:
+ return AdaptiveImageCrop.None;
- default:
- return AdaptiveImageCrop.Default;
- }
+ default:
+ return AdaptiveImageCrop.Default;
}
}
}
\ No newline at end of file
diff --git a/components/Notifications/src/Tiles/TileBasicImage.cs b/components/Notifications/src/Tiles/TileBasicImage.cs
index c3b57b815..b784a877b 100644
--- a/components/Notifications/src/Tiles/TileBasicImage.cs
+++ b/components/Notifications/src/Tiles/TileBasicImage.cs
@@ -4,39 +4,38 @@
using CommunityToolkit.Notifications.Adaptive.Elements;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// An image used on various special templates for the Tile.
+///
+public sealed class TileBasicImage : IBaseImage
{
+ private string _source;
+
+ ///
+ /// Gets or sets 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.
+ ///
+ public string Source
+ {
+ get { return _source; }
+ set { BaseImageHelper.SetSource(ref _source, value); }
+ }
+
+ ///
+ /// Gets or sets a description of the image, for users of assistive technologies.
+ ///
+ public string AlternateText { get; set; }
+
///
- /// An image used on various special templates for the Tile.
+ /// Gets or sets a value whether Windows should 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.
///
- public sealed class TileBasicImage : IBaseImage
+ public bool? AddImageQuery { get; set; }
+
+ internal Element_AdaptiveImage ConvertToElement()
{
- private string _source;
-
- ///
- /// Gets or sets 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.
- ///
- public string Source
- {
- get { return _source; }
- set { BaseImageHelper.SetSource(ref _source, value); }
- }
-
- ///
- /// Gets or sets a description of the image, for users of assistive technologies.
- ///
- public string AlternateText { get; set; }
-
- ///
- /// Gets or sets a value whether Windows should 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.
- ///
- public bool? AddImageQuery { get; set; }
-
- internal Element_AdaptiveImage ConvertToElement()
- {
- Element_AdaptiveImage image = BaseImageHelper.CreateBaseElement(this);
-
- return image;
- }
+ Element_AdaptiveImage image = BaseImageHelper.CreateBaseElement(this);
+
+ return image;
}
}
\ No newline at end of file
diff --git a/components/Notifications/src/Tiles/TileBasicText.cs b/components/Notifications/src/Tiles/TileBasicText.cs
index 465d1dd44..ec1f94b97 100644
--- a/components/Notifications/src/Tiles/TileBasicText.cs
+++ b/components/Notifications/src/Tiles/TileBasicText.cs
@@ -4,39 +4,38 @@
using CommunityToolkit.Notifications.Adaptive.Elements;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// A text element on the Tile.
+///
+public sealed class TileBasicText
{
///
- /// A text element on the Tile.
+ /// Gets or sets the text value that will be shown in the text field.
///
- public sealed class TileBasicText
- {
- ///
- /// Gets or sets the text value that will be shown in the text field.
- ///
- public string Text { get; set; }
+ public string Text { get; set; }
- ///
- /// Gets or sets 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.
- ///
- public string Lang { get; set; }
+ ///
+ /// Gets or sets 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.
+ ///
+ public string Lang { get; set; }
- internal Element_AdaptiveText ConvertToElement()
+ internal Element_AdaptiveText ConvertToElement()
+ {
+ return new Element_AdaptiveText()
{
- return new Element_AdaptiveText()
- {
- Text = Text,
- Lang = Lang
- };
- }
+ Text = Text,
+ Lang = Lang
+ };
+ }
- ///
- /// Returns the Text property's value.
- ///
- /// The Text property's value.
- public override string ToString()
- {
- return Text;
- }
+ ///
+ /// Returns the Text property's value.
+ ///
+ /// The Text property's value.
+ public override string ToString()
+ {
+ return Text;
}
}
\ No newline at end of file
diff --git a/components/Notifications/src/Tiles/TileBinding.cs b/components/Notifications/src/Tiles/TileBinding.cs
index 1290f47b2..78faaddc3 100644
--- a/components/Notifications/src/Tiles/TileBinding.cs
+++ b/components/Notifications/src/Tiles/TileBinding.cs
@@ -4,165 +4,164 @@
using System;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// The binding element contains the visual content for a specific Tile size.
+///
+public sealed class TileBinding
{
///
- /// The binding element contains the visual content for a specific Tile size.
+ /// Gets or sets 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 overridden 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.
+ ///
+ public string Language { get; set; }
+
+ ///
+ /// Gets or sets a default base URI that is combined with relative URIs in image source attributes. Defaults to null.
+ ///
+ public Uri BaseUri { get; set; }
+
+ ///
+ /// Gets or sets the form that the Tile should use to display the app's brand..
+ ///
+ public TileBranding Branding { get; set; } = Element_TileBinding.DEFAULT_BRANDING;
+
+ ///
+ /// Gets or sets a value whether Windows is allowed 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&ms-contrast=standard&ms-lang=en-us"
+ ///
+ public bool? AddImageQuery { get; set; }
+
+ ///
+ /// Gets or sets 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.
+ ///
+ public string ContentId { get; set; }
+
+ ///
+ /// Gets or sets an optional string to override the Tile's display name while showing this notification.
///
- public sealed class TileBinding
+ public string DisplayName { get; set; }
+
+ ///
+ /// Gets or sets an app-defined data that is passed back to your app via the TileActivatedInfo property on
+ /// LaunchActivatedEventArgs when the user launches your app from the Live Tile. This allows you to know
+ /// which Tile notifications your user saw when they tapped your Live Tile. On devices without the Anniversary Update,
+ /// this will simply be ignored.
+ ///
+ public string Arguments { get; set; }
+
+ ///
+ /// Gets or sets the actual content to be displayed. One of , , , , or
+ ///
+ public ITileBindingContent Content { get; set; }
+
+ internal Element_TileBinding ConvertToElement(TileSize size)
{
- ///
- /// Gets or sets 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 overridden 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.
- ///
- public string Language { get; set; }
-
- ///
- /// Gets or sets a default base URI that is combined with relative URIs in image source attributes. Defaults to null.
- ///
- public Uri BaseUri { get; set; }
-
- ///
- /// Gets or sets the form that the Tile should use to display the app's brand..
- ///
- public TileBranding Branding { get; set; } = Element_TileBinding.DEFAULT_BRANDING;
-
- ///
- /// Gets or sets a value whether Windows is allowed 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&ms-contrast=standard&ms-lang=en-us"
- ///
- public bool? AddImageQuery { get; set; }
-
- ///
- /// Gets or sets 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.
- ///
- public string ContentId { get; set; }
-
- ///
- /// Gets or sets an optional string to override the Tile's display name while showing this notification.
- ///
- public string DisplayName { get; set; }
-
- ///
- /// Gets or sets an app-defined data that is passed back to your app via the TileActivatedInfo property on
- /// LaunchActivatedEventArgs when the user launches your app from the Live Tile. This allows you to know
- /// which Tile notifications your user saw when they tapped your Live Tile. On devices without the Anniversary Update,
- /// this will simply be ignored.
- ///
- public string Arguments { get; set; }
-
- ///
- /// Gets or sets the actual content to be displayed. One of , , , , or
- ///
- public ITileBindingContent Content { get; set; }
-
- internal Element_TileBinding ConvertToElement(TileSize size)
+ TileTemplateNameV3 templateName = GetTemplateName(Content, size);
+
+ Element_TileBinding binding = new Element_TileBinding(templateName)
{
- TileTemplateNameV3 templateName = GetTemplateName(Content, size);
+ Language = Language,
+ BaseUri = BaseUri,
+ Branding = Branding,
+ AddImageQuery = AddImageQuery,
+ DisplayName = DisplayName,
+ ContentId = ContentId,
+ Arguments = Arguments
- Element_TileBinding binding = new Element_TileBinding(templateName)
- {
- Language = Language,
- BaseUri = BaseUri,
- Branding = Branding,
- AddImageQuery = AddImageQuery,
- DisplayName = DisplayName,
- ContentId = ContentId,
- Arguments = Arguments
+ // LockDetailedStatus gets populated by TileVisual
+ };
- // LockDetailedStatus gets populated by TileVisual
- };
+ PopulateElement(Content, binding, size);
- PopulateElement(Content, binding, size);
+ return binding;
+ }
- return binding;
+ private static void PopulateElement(ITileBindingContent bindingContent, Element_TileBinding binding, TileSize size)
+ {
+ if (bindingContent == null)
+ {
+ return;
}
- private static void PopulateElement(ITileBindingContent bindingContent, Element_TileBinding binding, TileSize size)
+ if (bindingContent is TileBindingContentAdaptive)
{
- if (bindingContent == null)
- {
- return;
- }
-
- if (bindingContent is TileBindingContentAdaptive)
- {
- (bindingContent as TileBindingContentAdaptive).PopulateElement(binding, size);
- }
- else if (bindingContent is TileBindingContentContact)
- {
- (bindingContent as TileBindingContentContact).PopulateElement(binding, size);
- }
- else if (bindingContent is TileBindingContentIconic)
- {
- (bindingContent as TileBindingContentIconic).PopulateElement(binding, size);
- }
- else if (bindingContent is TileBindingContentPeople)
- {
- (bindingContent as TileBindingContentPeople).PopulateElement(binding, size);
- }
- else if (bindingContent is TileBindingContentPhotos)
- {
- (bindingContent as TileBindingContentPhotos).PopulateElement(binding, size);
- }
- else
- {
- throw new NotImplementedException("Unknown binding content type: " + bindingContent.GetType());
- }
+ (bindingContent as TileBindingContentAdaptive).PopulateElement(binding, size);
}
-
- private static TileTemplateNameV3 GetTemplateName(ITileBindingContent bindingContent, TileSize size)
+ else if (bindingContent is TileBindingContentContact)
+ {
+ (bindingContent as TileBindingContentContact).PopulateElement(binding, size);
+ }
+ else if (bindingContent is TileBindingContentIconic)
+ {
+ (bindingContent as TileBindingContentIconic).PopulateElement(binding, size);
+ }
+ else if (bindingContent is TileBindingContentPeople)
+ {
+ (bindingContent as TileBindingContentPeople).PopulateElement(binding, size);
+ }
+ else if (bindingContent is TileBindingContentPhotos)
+ {
+ (bindingContent as TileBindingContentPhotos).PopulateElement(binding, size);
+ }
+ else
{
- if (bindingContent == null)
- {
- return TileSizeToAdaptiveTemplateConverter.Convert(size);
- }
-
- if (bindingContent is TileBindingContentAdaptive)
- {
- return (bindingContent as TileBindingContentAdaptive).GetTemplateName(size);
- }
-
- if (bindingContent is TileBindingContentContact)
- {
- return (bindingContent as TileBindingContentContact).GetTemplateName(size);
- }
-
- if (bindingContent is TileBindingContentIconic)
- {
- return (bindingContent as TileBindingContentIconic).GetTemplateName(size);
- }
-
- if (bindingContent is TileBindingContentPeople)
- {
- return (bindingContent as TileBindingContentPeople).GetTemplateName(size);
- }
-
- if (bindingContent is TileBindingContentPhotos)
- {
- return (bindingContent as TileBindingContentPhotos).GetTemplateName(size);
- }
-
throw new NotImplementedException("Unknown binding content type: " + bindingContent.GetType());
}
}
- ///
- /// Visual Tile content. One of , , , , or .
- ///
- public interface ITileBindingContent
+ private static TileTemplateNameV3 GetTemplateName(ITileBindingContent bindingContent, TileSize size)
{
- }
+ if (bindingContent == null)
+ {
+ return TileSizeToAdaptiveTemplateConverter.Convert(size);
+ }
- internal enum TileTemplate
- {
- TileSmall,
- TileMedium,
- TileWide,
- TileLarge
+ if (bindingContent is TileBindingContentAdaptive)
+ {
+ return (bindingContent as TileBindingContentAdaptive).GetTemplateName(size);
+ }
+
+ if (bindingContent is TileBindingContentContact)
+ {
+ return (bindingContent as TileBindingContentContact).GetTemplateName(size);
+ }
+
+ if (bindingContent is TileBindingContentIconic)
+ {
+ return (bindingContent as TileBindingContentIconic).GetTemplateName(size);
+ }
+
+ if (bindingContent is TileBindingContentPeople)
+ {
+ return (bindingContent as TileBindingContentPeople).GetTemplateName(size);
+ }
+
+ if (bindingContent is TileBindingContentPhotos)
+ {
+ return (bindingContent as TileBindingContentPhotos).GetTemplateName(size);
+ }
+
+ throw new NotImplementedException("Unknown binding content type: " + bindingContent.GetType());
}
+}
+
+///
+/// Visual Tile content. One of , , , , or .
+///
+public interface ITileBindingContent
+{
+}
+
+internal enum TileTemplate
+{
+ TileSmall,
+ TileMedium,
+ TileWide,
+ TileLarge
}
\ No newline at end of file
diff --git a/components/Notifications/src/Tiles/TileBindingContentAdaptive.cs b/components/Notifications/src/Tiles/TileBindingContentAdaptive.cs
index 3b970165e..f75284f47 100644
--- a/components/Notifications/src/Tiles/TileBindingContentAdaptive.cs
+++ b/components/Notifications/src/Tiles/TileBindingContentAdaptive.cs
@@ -5,68 +5,67 @@
using System.Collections.Generic;
using CommunityToolkit.Notifications.Adaptive;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// Supported on all sizes. This is the recommended way of specifying your Tile content. Adaptive Tile templates are the de-facto choice for Windows 10, and you can create a wide variety of custom Tiles through adaptive.
+///
+public sealed class TileBindingContentAdaptive : ITileBindingContent
{
///
- /// Supported on all sizes. This is the recommended way of specifying your Tile content. Adaptive Tile templates are the de-facto choice for Windows 10, and you can create a wide variety of custom Tiles through adaptive.
+ /// Gets , , and objects that can be added as children. The children are displayed in a vertical StackPanel fashion.
///
- public sealed class TileBindingContentAdaptive : ITileBindingContent
- {
- ///
- /// Gets , , and objects that can be added as children. The children are displayed in a vertical StackPanel fashion.
- ///
- public IList Children { get; private set; } = new List();
+ public IList Children { get; private set; } = new List();
- ///
- /// Gets or sets an optional background image that gets displayed behind all the Tile content, full bleed.
- ///
- public TileBackgroundImage BackgroundImage { get; set; }
+ ///
+ /// Gets or sets an optional background image that gets displayed behind all the Tile content, full bleed.
+ ///
+ public TileBackgroundImage BackgroundImage { get; set; }
- ///
- /// Gets or sets an optional peek image that animates in from the top of the Tile.
- ///
- public TilePeekImage PeekImage { get; set; }
+ ///
+ /// Gets or sets an optional peek image that animates in from the top of the Tile.
+ ///
+ public TilePeekImage PeekImage { get; set; }
- ///
- /// Gets or sets the text stacking (vertical alignment) of the entire binding element.
- ///
- public TileTextStacking TextStacking { get; set; } = Element_TileBinding.DEFAULT_TEXT_STACKING;
+ ///
+ /// Gets or sets the text stacking (vertical alignment) of the entire binding element.
+ ///
+ public TileTextStacking TextStacking { get; set; } = Element_TileBinding.DEFAULT_TEXT_STACKING;
- internal TileTemplateNameV3 GetTemplateName(TileSize size)
+ internal TileTemplateNameV3 GetTemplateName(TileSize size)
+ {
+ return TileSizeToAdaptiveTemplateConverter.Convert(size);
+ }
+
+ internal void PopulateElement(Element_TileBinding binding, TileSize size)
+ {
+ // Assign properties
+ binding.TextStacking = TextStacking;
+
+ // Add the background image if there's one
+ if (BackgroundImage != null)
{
- return TileSizeToAdaptiveTemplateConverter.Convert(size);
+ // And add it as a child
+ binding.Children.Add(BackgroundImage.ConvertToElement());
}
- internal void PopulateElement(Element_TileBinding binding, TileSize size)
+ // Add the peek image if there's one
+ if (PeekImage != null)
{
- // Assign properties
- binding.TextStacking = TextStacking;
-
- // Add the background image if there's one
- if (BackgroundImage != null)
- {
- // And add it as a child
- binding.Children.Add(BackgroundImage.ConvertToElement());
- }
-
- // Add the peek image if there's one
- if (PeekImage != null)
- {
- var el = PeekImage.ConvertToElement();
+ var el = PeekImage.ConvertToElement();
- binding.Children.Add(el);
- }
-
- // And then add all the children
- foreach (var child in Children)
- {
- binding.Children.Add(ConvertToBindingChildElement(child));
- }
+ binding.Children.Add(el);
}
- private static IElement_TileBindingChild ConvertToBindingChildElement(ITileBindingContentAdaptiveChild child)
+ // And then add all the children
+ foreach (var child in Children)
{
- return (IElement_TileBindingChild)AdaptiveHelper.ConvertToElement(child);
+ binding.Children.Add(ConvertToBindingChildElement(child));
}
}
+
+ private static IElement_TileBindingChild ConvertToBindingChildElement(ITileBindingContentAdaptiveChild child)
+ {
+ return (IElement_TileBindingChild)AdaptiveHelper.ConvertToElement(child);
+ }
}
\ No newline at end of file
diff --git a/components/Notifications/src/Tiles/TileBranding.cs b/components/Notifications/src/Tiles/TileBranding.cs
index c70a50c0b..2e0f6c86c 100644
--- a/components/Notifications/src/Tiles/TileBranding.cs
+++ b/components/Notifications/src/Tiles/TileBranding.cs
@@ -2,36 +2,35 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// The form that the Tile should use to display the app's brand.
+///
+public enum TileBranding
{
///
- /// The form that the Tile should use to display the app's brand.
+ /// The default choice. If ShowNameOn___ is true for the Tile size being displayed, then branding will be "Name". Otherwise it will be "None".
///
- public enum TileBranding
- {
- ///
- /// The default choice. If ShowNameOn___ is true for the Tile size being displayed, then branding will be "Name". Otherwise it will be "None".
- ///
- Auto,
+ Auto,
- ///
- /// No branding will be displayed.
- ///
- None,
+ ///
+ /// No branding will be displayed.
+ ///
+ None,
- ///
- /// The DisplayName will be shown.
- ///
- Name,
+ ///
+ /// The DisplayName will be shown.
+ ///
+ Name,
- ///
- /// Desktop-only. The Square44x44Logo will be shown. On Mobile, this will fallback to Name.
- ///
- Logo,
+ ///
+ /// Desktop-only. The Square44x44Logo will be shown. On Mobile, this will fallback to Name.
+ ///
+ Logo,
- ///
- /// Desktop-only. Both the DisplayName and Square44x44Logo will be shown. On Mobile, this will fallback to Name.
- ///
- NameAndLogo
- }
+ ///
+ /// Desktop-only. Both the DisplayName and Square44x44Logo will be shown. On Mobile, this will fallback to Name.
+ ///
+ NameAndLogo
}
\ No newline at end of file
diff --git a/components/Notifications/src/Tiles/TileCommon.cs b/components/Notifications/src/Tiles/TileCommon.cs
index 96544d3c9..666995106 100644
--- a/components/Notifications/src/Tiles/TileCommon.cs
+++ b/components/Notifications/src/Tiles/TileCommon.cs
@@ -4,32 +4,31 @@
using System;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// Represent the all tile sizes that are available.
+///
+[Flags]
+public enum TileSize
{
///
- /// Represent the all tile sizes that are available.
+ /// Small Square Tile
///
- [Flags]
- public enum TileSize
- {
- ///
- /// Small Square Tile
- ///
- Small = 1,
+ Small = 1,
- ///
- /// Medium Square Tile
- ///
- Medium = 2,
+ ///
+ /// Medium Square Tile
+ ///
+ Medium = 2,
- ///
- /// Wide Rectangle Tile
- ///
- Wide = 4,
+ ///
+ /// Wide Rectangle Tile
+ ///
+ Wide = 4,
- ///
- /// Large Square Tile
- ///
- Large = 8
- }
+ ///
+ /// Large Square Tile
+ ///
+ Large = 8
}
\ No newline at end of file
diff --git a/components/Notifications/src/Tiles/TileContent.cs b/components/Notifications/src/Tiles/TileContent.cs
index 0f4608809..c86068743 100644
--- a/components/Notifications/src/Tiles/TileContent.cs
+++ b/components/Notifications/src/Tiles/TileContent.cs
@@ -5,49 +5,48 @@
using Windows.Data.Xml.Dom;
using Windows.UI.Notifications;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// Base Tile element, which contains a single visual element.
+///
+public sealed class TileContent
{
///
- /// Base Tile element, which contains a single visual element.
+ /// Gets or sets the visual element. Required.
///
- public sealed class TileContent
- {
- ///
- /// Gets or sets the visual element. Required.
- ///
- public TileVisual Visual { get; set; }
-
- ///
- /// Retrieves the notification XML content as a string, so that it can be sent with a HTTP POST in a push notification.
- ///
- /// The notification XML content as a string.
- public string GetContent()
- {
- return ConvertToElement().GetContent();
- }
+ public TileVisual Visual { get; set; }
- ///
- /// Retrieves the notification XML content as a WinRT XmlDocument, so that it can be used with a local Tile notification's constructor on either or .
- ///
- /// The notification XML content as a WinRT XmlDocument.
- public XmlDocument GetXml()
- {
- XmlDocument doc = new XmlDocument();
- doc.LoadXml(GetContent());
+ ///
+ /// Retrieves the notification XML content as a string, so that it can be sent with a HTTP POST in a push notification.
+ ///
+ /// The notification XML content as a string.
+ public string GetContent()
+ {
+ return ConvertToElement().GetContent();
+ }
- return doc;
- }
+ ///
+ /// Retrieves the notification XML content as a WinRT XmlDocument, so that it can be used with a local Tile notification's constructor on either or .
+ ///
+ /// The notification XML content as a WinRT XmlDocument.
+ public XmlDocument GetXml()
+ {
+ XmlDocument doc = new XmlDocument();
+ doc.LoadXml(GetContent());
- internal Element_Tile ConvertToElement()
- {
- var tile = new Element_Tile();
+ return doc;
+ }
- if (Visual != null)
- {
- tile.Visual = Visual.ConvertToElement();
- }
+ internal Element_Tile ConvertToElement()
+ {
+ var tile = new Element_Tile();
- return tile;
+ if (Visual != null)
+ {
+ tile.Visual = Visual.ConvertToElement();
}
+
+ return tile;
}
}
diff --git a/components/Notifications/src/Tiles/TileImages.cs b/components/Notifications/src/Tiles/TileImages.cs
index 6ac9407f1..a6f5faabe 100644
--- a/components/Notifications/src/Tiles/TileImages.cs
+++ b/components/Notifications/src/Tiles/TileImages.cs
@@ -2,47 +2,46 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// Specify the desired cropping of the image.
+///
+public enum TileBackgroundImageCrop
{
///
- /// Specify the desired cropping of the image.
+ /// Cropping style automatically determined by renderer.
///
- public enum TileBackgroundImageCrop
- {
- ///
- /// Cropping style automatically determined by renderer.
- ///
- Default,
+ Default,
- ///
- /// Default value. Image is not cropped.
- ///
- None,
+ ///
+ /// Default value. Image is not cropped.
+ ///
+ None,
- ///
- /// Image is cropped to a circle shape.
- ///
- Circle
- }
+ ///
+ /// Image is cropped to a circle shape.
+ ///
+ Circle
+}
+///
+/// Specify the desired cropping of the image.
+///
+public enum TilePeekImageCrop
+{
///
- /// Specify the desired cropping of the image.
+ /// Cropping style automatically determined by renderer.
///
- public enum TilePeekImageCrop
- {
- ///
- /// Cropping style automatically determined by renderer.
- ///
- Default,
+ Default,
- ///
- /// Default value. Image is not cropped.
- ///
- None,
+ ///
+ /// Default value. Image is not cropped.
+ ///
+ None,
- ///
- /// Image is cropped to a circle shape.
- ///
- Circle
- }
+ ///
+ /// Image is cropped to a circle shape.
+ ///
+ Circle
}
\ No newline at end of file
diff --git a/components/Notifications/src/Tiles/TilePeekImage.cs b/components/Notifications/src/Tiles/TilePeekImage.cs
index e8e75f309..eaa85b2f0 100644
--- a/components/Notifications/src/Tiles/TilePeekImage.cs
+++ b/components/Notifications/src/Tiles/TilePeekImage.cs
@@ -4,88 +4,87 @@
using CommunityToolkit.Notifications.Adaptive.Elements;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// A peek image that animates in from the top of the Tile.
+///
+public sealed class TilePeekImage : IBaseImage
{
+ private string _source;
+
///
- /// A peek image that animates in from the top of the Tile.
+ /// Gets or sets 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.
///
- public sealed class TilePeekImage : IBaseImage
+ public string Source
{
- private string _source;
+ get { return _source; }
+ set { BaseImageHelper.SetSource(ref _source, value); }
+ }
- ///
- /// Gets or sets 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.
- ///
- public string Source
- {
- get { return _source; }
- set { BaseImageHelper.SetSource(ref _source, value); }
- }
+ ///
+ /// Gets or sets a description of the image, for users of assistive technologies.
+ ///
+ public string AlternateText { get; set; }
- ///
- /// Gets or sets a description of the image, for users of assistive technologies.
- ///
- public string AlternateText { get; set; }
+ ///
+ /// Gets or sets set a value whether Windows is allowed 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.
+ ///
+ public bool? AddImageQuery { get; set; }
- ///
- /// Gets or sets set a value whether Windows is allowed 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.
- ///
- public bool? AddImageQuery { get; set; }
+ private int? _hintOverlay;
- private int? _hintOverlay;
+ ///
+ /// Gets or sets a black overlay on the peek image. This value controls the opacity of the black overlay, with 0 being no overlay and 100 being completely black. Defaults to 0.
+ /// Previously for RTM: Did not exist, value will be ignored and peek image will be displayed with 0 overlay.
+ ///
+ public int? HintOverlay
+ {
+ get
+ {
+ return _hintOverlay;
+ }
- ///
- /// Gets or sets a black overlay on the peek image. This value controls the opacity of the black overlay, with 0 being no overlay and 100 being completely black. Defaults to 0.
- /// Previously for RTM: Did not exist, value will be ignored and peek image will be displayed with 0 overlay.
- ///
- public int? HintOverlay
+ set
{
- get
+ if (value != null)
{
- return _hintOverlay;
+ Element_TileBinding.CheckOverlayValue(value.Value);
}
- set
- {
- if (value != null)
- {
- Element_TileBinding.CheckOverlayValue(value.Value);
- }
-
- _hintOverlay = value;
- }
+ _hintOverlay = value;
}
+ }
- ///
- /// Gets or sets the desired cropping of the image.
- /// Previously for RTM: Did not exist, value will be ignored and peek image will be displayed without any cropping.
- ///
- public TilePeekImageCrop HintCrop { get; set; }
+ ///
+ /// Gets or sets the desired cropping of the image.
+ /// Previously for RTM: Did not exist, value will be ignored and peek image will be displayed without any cropping.
+ ///
+ public TilePeekImageCrop HintCrop { get; set; }
- internal Element_AdaptiveImage ConvertToElement()
- {
- Element_AdaptiveImage image = BaseImageHelper.CreateBaseElement(this);
+ internal Element_AdaptiveImage ConvertToElement()
+ {
+ Element_AdaptiveImage image = BaseImageHelper.CreateBaseElement(this);
- image.Placement = AdaptiveImagePlacement.Peek;
- image.Crop = GetAdaptiveImageCrop();
- image.Overlay = HintOverlay;
+ image.Placement = AdaptiveImagePlacement.Peek;
+ image.Crop = GetAdaptiveImageCrop();
+ image.Overlay = HintOverlay;
- return image;
- }
+ return image;
+ }
- private AdaptiveImageCrop GetAdaptiveImageCrop()
+ private AdaptiveImageCrop GetAdaptiveImageCrop()
+ {
+ switch (HintCrop)
{
- switch (HintCrop)
- {
- case TilePeekImageCrop.Circle:
- return AdaptiveImageCrop.Circle;
+ case TilePeekImageCrop.Circle:
+ return AdaptiveImageCrop.Circle;
- case TilePeekImageCrop.None:
- return AdaptiveImageCrop.None;
+ case TilePeekImageCrop.None:
+ return AdaptiveImageCrop.None;
- default:
- return AdaptiveImageCrop.Default;
- }
+ default:
+ return AdaptiveImageCrop.Default;
}
}
}
\ No newline at end of file
diff --git a/components/Notifications/src/Tiles/TileSizeToAdaptiveTemplateConverter.cs b/components/Notifications/src/Tiles/TileSizeToAdaptiveTemplateConverter.cs
index 86b19981d..0e35c183f 100644
--- a/components/Notifications/src/Tiles/TileSizeToAdaptiveTemplateConverter.cs
+++ b/components/Notifications/src/Tiles/TileSizeToAdaptiveTemplateConverter.cs
@@ -4,29 +4,28 @@
using System;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+internal static class TileSizeToAdaptiveTemplateConverter
{
- internal static class TileSizeToAdaptiveTemplateConverter
+ public static TileTemplateNameV3 Convert(TileSize size)
{
- public static TileTemplateNameV3 Convert(TileSize size)
+ switch (size)
{
- switch (size)
- {
- case TileSize.Small:
- return TileTemplateNameV3.TileSmall;
+ case TileSize.Small:
+ return TileTemplateNameV3.TileSmall;
- case TileSize.Medium:
- return TileTemplateNameV3.TileMedium;
+ case TileSize.Medium:
+ return TileTemplateNameV3.TileMedium;
- case TileSize.Wide:
- return TileTemplateNameV3.TileWide;
+ case TileSize.Wide:
+ return TileTemplateNameV3.TileWide;
- case TileSize.Large:
- return TileTemplateNameV3.TileLarge;
+ case TileSize.Large:
+ return TileTemplateNameV3.TileLarge;
- default:
- throw new NotImplementedException();
- }
+ default:
+ throw new NotImplementedException();
}
}
}
\ No newline at end of file
diff --git a/components/Notifications/src/Tiles/TileTemplateNameV3.cs b/components/Notifications/src/Tiles/TileTemplateNameV3.cs
index 1cdd685aa..932a5a5f2 100644
--- a/components/Notifications/src/Tiles/TileTemplateNameV3.cs
+++ b/components/Notifications/src/Tiles/TileTemplateNameV3.cs
@@ -2,91 +2,90 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+internal enum TileTemplateNameV3
{
- internal enum TileTemplateNameV3
- {
- TileMedium,
- TileSmall,
- TileWide,
- TileLarge,
+ TileMedium,
+ TileSmall,
+ TileWide,
+ TileLarge,
- TileSquare150x150Block,
- TileSquare150x150Image,
- TileSquare150x150PeekImageAndText01,
- TileSquare150x150PeekImageAndText02,
- TileSquare150x150PeekImageAndText03,
- TileSquare150x150PeekImageAndText04,
- TileSquare150x150Text01,
- TileSquare150x150Text02,
- TileSquare150x150Text03,
- TileSquare150x150Text04,
- TileSquare310x310BlockAndText01,
- TileSquare310x310BlockAndText02,
- TileSquare310x310Image,
- TileSquare310x310ImageAndText01,
- TileSquare310x310ImageAndText02,
- TileSquare310x310ImageAndTextOverlay01,
- TileSquare310x310ImageAndTextOverlay02,
- TileSquare310x310ImageAndTextOverlay03,
- TileSquare310x310ImageCollection,
- TileSquare310x310ImageCollectionAndText01,
- TileSquare310x310ImageCollectionAndText02,
- TileSquare310x310SmallImagesAndTextList01,
- TileSquare310x310SmallImagesAndTextList02,
- TileSquare310x310SmallImagesAndTextList03,
- TileSquare310x310SmallImagesAndTextList04,
- TileSquare310x310Text01,
- TileSquare310x310Text02,
- TileSquare310x310Text03,
- TileSquare310x310Text04,
- TileSquare310x310Text05,
- TileSquare310x310Text06,
- TileSquare310x310Text07,
- TileSquare310x310Text08,
- TileSquare310x310TextList01,
- TileSquare310x310TextList02,
- TileSquare310x310TextList03,
- TileWide310x150BlockAndText01,
- TileWide310x150BlockAndText02,
- TileWide310x150Image,
- TileWide310x150ImageAndText01,
- TileWide310x150ImageAndText02,
- TileWide310x150ImageCollection,
- TileWide310x150PeekImage01,
- TileWide310x150PeekImage02,
- TileWide310x150PeekImage03,
- TileWide310x150PeekImage04,
- TileWide310x150PeekImage05,
- TileWide310x150PeekImage06,
- TileWide310x150PeekImageAndText01,
- TileWide310x150PeekImageAndText02,
- TileWide310x150PeekImageCollection01,
- TileWide310x150PeekImageCollection02,
- TileWide310x150PeekImageCollection03,
- TileWide310x150PeekImageCollection04,
- TileWide310x150PeekImageCollection05,
- TileWide310x150PeekImageCollection06,
- TileWide310x150SmallImageAndText01,
- TileWide310x150SmallImageAndText02,
- TileWide310x150SmallImageAndText03,
- TileWide310x150SmallImageAndText04,
- TileWide310x150SmallImageAndText05,
- TileWide310x150Text01,
- TileWide310x150Text02,
- TileWide310x150Text03,
- TileWide310x150Text04,
- TileWide310x150Text05,
- TileWide310x150Text06,
- TileWide310x150Text07,
- TileWide310x150Text08,
- TileWide310x150Text09,
- TileWide310x150Text10,
- TileWide310x150Text11,
+ TileSquare150x150Block,
+ TileSquare150x150Image,
+ TileSquare150x150PeekImageAndText01,
+ TileSquare150x150PeekImageAndText02,
+ TileSquare150x150PeekImageAndText03,
+ TileSquare150x150PeekImageAndText04,
+ TileSquare150x150Text01,
+ TileSquare150x150Text02,
+ TileSquare150x150Text03,
+ TileSquare150x150Text04,
+ TileSquare310x310BlockAndText01,
+ TileSquare310x310BlockAndText02,
+ TileSquare310x310Image,
+ TileSquare310x310ImageAndText01,
+ TileSquare310x310ImageAndText02,
+ TileSquare310x310ImageAndTextOverlay01,
+ TileSquare310x310ImageAndTextOverlay02,
+ TileSquare310x310ImageAndTextOverlay03,
+ TileSquare310x310ImageCollection,
+ TileSquare310x310ImageCollectionAndText01,
+ TileSquare310x310ImageCollectionAndText02,
+ TileSquare310x310SmallImagesAndTextList01,
+ TileSquare310x310SmallImagesAndTextList02,
+ TileSquare310x310SmallImagesAndTextList03,
+ TileSquare310x310SmallImagesAndTextList04,
+ TileSquare310x310Text01,
+ TileSquare310x310Text02,
+ TileSquare310x310Text03,
+ TileSquare310x310Text04,
+ TileSquare310x310Text05,
+ TileSquare310x310Text06,
+ TileSquare310x310Text07,
+ TileSquare310x310Text08,
+ TileSquare310x310TextList01,
+ TileSquare310x310TextList02,
+ TileSquare310x310TextList03,
+ TileWide310x150BlockAndText01,
+ TileWide310x150BlockAndText02,
+ TileWide310x150Image,
+ TileWide310x150ImageAndText01,
+ TileWide310x150ImageAndText02,
+ TileWide310x150ImageCollection,
+ TileWide310x150PeekImage01,
+ TileWide310x150PeekImage02,
+ TileWide310x150PeekImage03,
+ TileWide310x150PeekImage04,
+ TileWide310x150PeekImage05,
+ TileWide310x150PeekImage06,
+ TileWide310x150PeekImageAndText01,
+ TileWide310x150PeekImageAndText02,
+ TileWide310x150PeekImageCollection01,
+ TileWide310x150PeekImageCollection02,
+ TileWide310x150PeekImageCollection03,
+ TileWide310x150PeekImageCollection04,
+ TileWide310x150PeekImageCollection05,
+ TileWide310x150PeekImageCollection06,
+ TileWide310x150SmallImageAndText01,
+ TileWide310x150SmallImageAndText02,
+ TileWide310x150SmallImageAndText03,
+ TileWide310x150SmallImageAndText04,
+ TileWide310x150SmallImageAndText05,
+ TileWide310x150Text01,
+ TileWide310x150Text02,
+ TileWide310x150Text03,
+ TileWide310x150Text04,
+ TileWide310x150Text05,
+ TileWide310x150Text06,
+ TileWide310x150Text07,
+ TileWide310x150Text08,
+ TileWide310x150Text09,
+ TileWide310x150Text10,
+ TileWide310x150Text11,
- TileSquare71x71Image,
- TileSquare71x71IconWithBadge,
- TileSquare150x150IconWithBadge,
- TileWide310x150IconWithBadgeAndText
- }
+ TileSquare71x71Image,
+ TileSquare71x71IconWithBadge,
+ TileSquare150x150IconWithBadge,
+ TileWide310x150IconWithBadgeAndText
}
\ No newline at end of file
diff --git a/components/Notifications/src/Tiles/TileTextStacking.cs b/components/Notifications/src/Tiles/TileTextStacking.cs
index 4b4e352dd..9c7ad284f 100644
--- a/components/Notifications/src/Tiles/TileTextStacking.cs
+++ b/components/Notifications/src/Tiles/TileTextStacking.cs
@@ -2,26 +2,25 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// TextStacking specifies the vertical alignment of content.
+///
+public enum TileTextStacking
{
///
- /// TextStacking specifies the vertical alignment of content.
+ /// Vertical align to the top.
///
- public enum TileTextStacking
- {
- ///
- /// Vertical align to the top.
- ///
- Top,
+ Top,
- ///
- /// Vertical align to the center.
- ///
- Center,
+ ///
+ /// Vertical align to the center.
+ ///
+ Center,
- ///
- /// Vertical align to the bottom.
- ///
- Bottom
- }
+ ///
+ /// Vertical align to the bottom.
+ ///
+ Bottom
}
\ No newline at end of file
diff --git a/components/Notifications/src/Tiles/TileVisual.cs b/components/Notifications/src/Tiles/TileVisual.cs
index 123a785c3..c4380d5e8 100644
--- a/components/Notifications/src/Tiles/TileVisual.cs
+++ b/components/Notifications/src/Tiles/TileVisual.cs
@@ -6,214 +6,213 @@
using System.Linq;
using CommunityToolkit.Notifications.Adaptive.Elements;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// Contains multiple binding child elements, each of which defines a Tile.
+///
+public sealed class TileVisual
{
///
- /// Contains multiple binding child elements, each of which defines a Tile.
+ /// Gets or sets the target locale of the XML payload, specified as a BCP-47 language tags such as "en-US" or "fr-FR". This locale is overridden by any locale specified in binding or 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.
///
- public sealed class TileVisual
- {
- ///
- /// Gets or sets the target locale of the XML payload, specified as a BCP-47 language tags such as "en-US" or "fr-FR". This locale is overridden by any locale specified in binding or 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.
- ///
- public string Language { get; set; }
-
- ///
- /// Gets or sets a default base URI that is combined with relative URIs in image source attributes.
- ///
- public Uri BaseUri { get; set; }
-
- ///
- /// Gets or sets the form that the Tile should use to display the app's brand.
- ///
- public TileBranding Branding { get; set; } = Element_TileVisual.DEFAULT_BRANDING;
-
- ///
- /// Gets or sets a value whether Windows is allowed 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&ms-contrast=standard&ms-lang=en-us"
- ///
- public bool? AddImageQuery { get; set; }
-
- ///
- /// Gets or sets 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.
- ///
- public string ContentId { get; set; }
-
- ///
- /// Gets or sets an optional string to override the Tile's display name while showing this notification.
- ///
- public string DisplayName { get; set; }
-
- ///
- /// Gets or sets the first line of text that will be displayed on the lock screen if the user has selected
- /// your Tile as their detailed status app. Ff you specify this, you must also provide a Wide Tile binding.
- ///
- public string LockDetailedStatus1 { get; set; }
-
- ///
- /// Gets or sets the second line of text that will be displayed on the lock screen if the user has selected
- /// your Tile as their detailed status app. If you specify this, you must also provide a Wide Tile binding.
- ///
- public string LockDetailedStatus2 { get; set; }
-
- ///
- /// Gets or sets the third line of text that will be displayed on the lock screen if the user has selected your
- /// Tile as their detailed status app. If you specify this, you must also provide a Wide Tile binding.
- ///
- public string LockDetailedStatus3 { get; set; }
-
- ///
- /// Gets or sets app-defined data that is passed back to your app via the TileActivatedInfo property on LaunchActivatedEventArgs when the user launches your app from the Live Tile. This allows you to know which Tile notifications your user saw when they tapped your Live Tile. On devices without the Anniversary Update, this will simply be ignored.
- ///
- public string Arguments { get; set; }
-
- ///
- /// Gets or sets an optional small binding to specify content for the small Tile size.
- ///
- public TileBinding TileSmall { get; set; }
-
- ///
- /// Gets or sets an optional medium binding to specify content for the medium Tile size.
- ///
- public TileBinding TileMedium { get; set; }
-
- ///
- /// Gets or sets an optional wide binding to specify content for the wide Tile size.
- ///
- public TileBinding TileWide { get; set; }
-
- ///
- /// Gets or sets an optional large binding to specify content for the large Tile size. Desktop-only
- ///
- public TileBinding TileLarge { get; set; }
-
- ///
- /// Attempts to find and re-use an existing text element inside the binding. Returns true if it could. Otherwise returns false, and the caller will have to specify the detailed status using the lock hint attribute.
- ///
- /// The lock screen line number.
- /// The lock screen line text.
- /// The binding to look in for matches.
- /// True if could re-use existing text element, otherwise false.
- private static bool TryReuseTextElementForLockDetailedText(int lineNumber, string lockText, Element_TileBinding binding)
- {
- if (lockText == null)
- {
- throw new ArgumentNullException("lockText cannot be null");
- }
+ public string Language { get; set; }
- if (binding == null)
- {
- throw new ArgumentNullException("binding cannot be null");
- }
+ ///
+ /// Gets or sets a default base URI that is combined with relative URIs in image source attributes.
+ ///
+ public Uri BaseUri { get; set; }
- // If a text element already has an id with the line number (only look at immediate children, since the lock screen will ignore things under groups/subgroups)
- Element_AdaptiveText matchingIdTextElement = binding.Children.OfType().FirstOrDefault(i => i.Id != null && i.Id.Equals(lineNumber.ToString()));
+ ///
+ /// Gets or sets the form that the Tile should use to display the app's brand.
+ ///
+ public TileBranding Branding { get; set; } = Element_TileVisual.DEFAULT_BRANDING;
- if (matchingIdTextElement != null)
- {
- // If the text in the element matches the lock text, then we're good, don't need to assign anything else!
- if (matchingIdTextElement.Text != null && matchingIdTextElement.Text.Equals(lockText))
- {
- return true;
- }
+ ///
+ /// Gets or sets a value whether Windows is allowed 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&ms-contrast=standard&ms-lang=en-us"
+ ///
+ public bool? AddImageQuery { get; set; }
- // Otherwise, we need to specify the lock text in the hint attribute, so we return false
- return false;
- }
+ ///
+ /// Gets or sets 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.
+ ///
+ public string ContentId { get; set; }
- // Otherwise no text elements use that ID, so we could assign one if we find a text element that doesn't have an ID assigned and matches the lock text
- Element_AdaptiveText matchingTextTextElement = binding.Children.OfType().FirstOrDefault(i => i.Id == null && i.Text != null && i.Text.Equals(lockText));
+ ///
+ /// Gets or sets an optional string to override the Tile's display name while showing this notification.
+ ///
+ public string DisplayName { get; set; }
+
+ ///
+ /// Gets or sets the first line of text that will be displayed on the lock screen if the user has selected
+ /// your Tile as their detailed status app. Ff you specify this, you must also provide a Wide Tile binding.
+ ///
+ public string LockDetailedStatus1 { get; set; }
+
+ ///
+ /// Gets or sets the second line of text that will be displayed on the lock screen if the user has selected
+ /// your Tile as their detailed status app. If you specify this, you must also provide a Wide Tile binding.
+ ///
+ public string LockDetailedStatus2 { get; set; }
+
+ ///
+ /// Gets or sets the third line of text that will be displayed on the lock screen if the user has selected your
+ /// Tile as their detailed status app. If you specify this, you must also provide a Wide Tile binding.
+ ///
+ public string LockDetailedStatus3 { get; set; }
+
+ ///
+ /// Gets or sets app-defined data that is passed back to your app via the TileActivatedInfo property on LaunchActivatedEventArgs when the user launches your app from the Live Tile. This allows you to know which Tile notifications your user saw when they tapped your Live Tile. On devices without the Anniversary Update, this will simply be ignored.
+ ///
+ public string Arguments { get; set; }
+
+ ///
+ /// Gets or sets an optional small binding to specify content for the small Tile size.
+ ///
+ public TileBinding TileSmall { get; set; }
+
+ ///
+ /// Gets or sets an optional medium binding to specify content for the medium Tile size.
+ ///
+ public TileBinding TileMedium { get; set; }
+
+ ///
+ /// Gets or sets an optional wide binding to specify content for the wide Tile size.
+ ///
+ public TileBinding TileWide { get; set; }
+
+ ///
+ /// Gets or sets an optional large binding to specify content for the large Tile size. Desktop-only
+ ///
+ public TileBinding TileLarge { get; set; }
- // If we found text that matched, we'll assign the id so it gets re-used for lock!
- if (matchingTextTextElement != null)
+ ///
+ /// Attempts to find and re-use an existing text element inside the binding. Returns true if it could. Otherwise returns false, and the caller will have to specify the detailed status using the lock hint attribute.
+ ///
+ /// The lock screen line number.
+ /// The lock screen line text.
+ /// The binding to look in for matches.
+ /// True if could re-use existing text element, otherwise false.
+ private static bool TryReuseTextElementForLockDetailedText(int lineNumber, string lockText, Element_TileBinding binding)
+ {
+ if (lockText == null)
+ {
+ throw new ArgumentNullException("lockText cannot be null");
+ }
+
+ if (binding == null)
+ {
+ throw new ArgumentNullException("binding cannot be null");
+ }
+
+ // If a text element already has an id with the line number (only look at immediate children, since the lock screen will ignore things under groups/subgroups)
+ Element_AdaptiveText matchingIdTextElement = binding.Children.OfType().FirstOrDefault(i => i.Id != null && i.Id.Equals(lineNumber.ToString()));
+
+ if (matchingIdTextElement != null)
+ {
+ // If the text in the element matches the lock text, then we're good, don't need to assign anything else!
+ if (matchingIdTextElement.Text != null && matchingIdTextElement.Text.Equals(lockText))
{
- matchingTextTextElement.Id = lineNumber;
return true;
}
- // Otherwise we'll need to specify lock text in hint attribute, so return false
+ // Otherwise, we need to specify the lock text in the hint attribute, so we return false
return false;
}
- internal Element_TileVisual ConvertToElement()
+ // Otherwise no text elements use that ID, so we could assign one if we find a text element that doesn't have an ID assigned and matches the lock text
+ Element_AdaptiveText matchingTextTextElement = binding.Children.OfType().FirstOrDefault(i => i.Id == null && i.Text != null && i.Text.Equals(lockText));
+
+ // If we found text that matched, we'll assign the id so it gets re-used for lock!
+ if (matchingTextTextElement != null)
{
- var visual = new Element_TileVisual()
- {
- Language = Language,
- BaseUri = BaseUri,
- Branding = Branding,
- AddImageQuery = AddImageQuery,
- ContentId = ContentId,
- DisplayName = DisplayName,
- Arguments = Arguments
- };
-
- if (TileSmall != null)
- {
- visual.Bindings.Add(TileSmall.ConvertToElement(TileSize.Small));
- }
+ matchingTextTextElement.Id = lineNumber;
+ return true;
+ }
- if (TileMedium != null)
- {
- visual.Bindings.Add(TileMedium.ConvertToElement(TileSize.Medium));
- }
+ // Otherwise we'll need to specify lock text in hint attribute, so return false
+ return false;
+ }
- if (TileWide != null)
- {
- Element_TileBinding wideBindingElement = TileWide.ConvertToElement(TileSize.Wide);
+ internal Element_TileVisual ConvertToElement()
+ {
+ var visual = new Element_TileVisual()
+ {
+ Language = Language,
+ BaseUri = BaseUri,
+ Branding = Branding,
+ AddImageQuery = AddImageQuery,
+ ContentId = ContentId,
+ DisplayName = DisplayName,
+ Arguments = Arguments
+ };
+
+ if (TileSmall != null)
+ {
+ visual.Bindings.Add(TileSmall.ConvertToElement(TileSize.Small));
+ }
- // If lock detailed status was specified, add them
- if (LockDetailedStatus1 != null)
- {
- // If we can't reuse existing text element, we'll have to use the hints
- if (!TryReuseTextElementForLockDetailedText(1, LockDetailedStatus1, wideBindingElement))
- {
- wideBindingElement.LockDetailedStatus1 = LockDetailedStatus1;
- }
- }
+ if (TileMedium != null)
+ {
+ visual.Bindings.Add(TileMedium.ConvertToElement(TileSize.Medium));
+ }
- if (LockDetailedStatus2 != null)
- {
- if (!TryReuseTextElementForLockDetailedText(2, LockDetailedStatus2, wideBindingElement))
- {
- wideBindingElement.LockDetailedStatus2 = LockDetailedStatus2;
- }
- }
+ if (TileWide != null)
+ {
+ Element_TileBinding wideBindingElement = TileWide.ConvertToElement(TileSize.Wide);
- if (LockDetailedStatus3 != null)
+ // If lock detailed status was specified, add them
+ if (LockDetailedStatus1 != null)
+ {
+ // If we can't reuse existing text element, we'll have to use the hints
+ if (!TryReuseTextElementForLockDetailedText(1, LockDetailedStatus1, wideBindingElement))
{
- if (!TryReuseTextElementForLockDetailedText(3, LockDetailedStatus3, wideBindingElement))
- {
- wideBindingElement.LockDetailedStatus3 = LockDetailedStatus3;
- }
+ wideBindingElement.LockDetailedStatus1 = LockDetailedStatus1;
}
-
- visual.Bindings.Add(wideBindingElement);
}
- // Otherwise if they specified lock values, throw an exception since lock values require wide
- else if (HasLockDetailedStatusValues())
+ if (LockDetailedStatus2 != null)
{
- throw new Exception("To provide lock detailed status text strings, you must also provide a TileWide binding. Either provide a TileWide binding, or leave the detailed status values null.");
+ if (!TryReuseTextElementForLockDetailedText(2, LockDetailedStatus2, wideBindingElement))
+ {
+ wideBindingElement.LockDetailedStatus2 = LockDetailedStatus2;
+ }
}
- if (TileLarge != null)
+ if (LockDetailedStatus3 != null)
{
- visual.Bindings.Add(TileLarge.ConvertToElement(TileSize.Large));
+ if (!TryReuseTextElementForLockDetailedText(3, LockDetailedStatus3, wideBindingElement))
+ {
+ wideBindingElement.LockDetailedStatus3 = LockDetailedStatus3;
+ }
}
- // TODO: If a BaseUri wasn't provided, we can potentially optimize the payload size by calculating the best BaseUri
- return visual;
+ visual.Bindings.Add(wideBindingElement);
}
- private bool HasLockDetailedStatusValues()
+ // Otherwise if they specified lock values, throw an exception since lock values require wide
+ else if (HasLockDetailedStatusValues())
{
- return LockDetailedStatus1 != null && LockDetailedStatus2 != null && LockDetailedStatus3 != null;
+ throw new Exception("To provide lock detailed status text strings, you must also provide a TileWide binding. Either provide a TileWide binding, or leave the detailed status values null.");
}
+
+ if (TileLarge != null)
+ {
+ visual.Bindings.Add(TileLarge.ConvertToElement(TileSize.Large));
+ }
+
+ // TODO: If a BaseUri wasn't provided, we can potentially optimize the payload size by calculating the best BaseUri
+ return visual;
+ }
+
+ private bool HasLockDetailedStatusValues()
+ {
+ return LockDetailedStatus1 != null && LockDetailedStatus2 != null && LockDetailedStatus3 != null;
}
}
\ No newline at end of file
diff --git a/components/Notifications/src/Toasts/Builder/CustomizeToast.cs b/components/Notifications/src/Toasts/Builder/CustomizeToast.cs
index 1f4bf30bb..db7abed5c 100644
--- a/components/Notifications/src/Toasts/Builder/CustomizeToast.cs
+++ b/components/Notifications/src/Toasts/Builder/CustomizeToast.cs
@@ -5,31 +5,30 @@
using Windows.Foundation;
using Windows.UI.Notifications;
-namespace CommunityToolkit.Notifications
-{
- ///
- /// Allows you to set additional properties on the object before the toast is displayed.
- ///
- /// The toast to modify that will be displayed.
- public delegate void CustomizeToast(ToastNotification toast);
+namespace CommunityToolkit.Notifications;
- ///
- /// Allows you to set additional properties on the object before the toast is displayed.
- ///
- /// The toast to modify that will be displayed.
- /// An operation.
- public delegate IAsyncAction CustomizeToastAsync(ToastNotification toast);
+///
+/// Allows you to set additional properties on the object before the toast is displayed.
+///
+/// The toast to modify that will be displayed.
+public delegate void CustomizeToast(ToastNotification toast);
- ///
- /// Allows you to set additional properties on the object before the toast is scheduled.
- ///
- /// The scheduled toast to modify that will be scheduled.
- public delegate void CustomizeScheduledToast(ScheduledToastNotification toast);
+///
+/// Allows you to set additional properties on the object before the toast is displayed.
+///
+/// The toast to modify that will be displayed.
+/// An operation.
+public delegate IAsyncAction CustomizeToastAsync(ToastNotification toast);
- ///
- /// Allows you to set additional properties on the object before the toast is scheduled.
- ///
- /// The scheduled toast to modify that will be scheduled.
- /// An operation.
- public delegate IAsyncAction CustomizeScheduledToastAsync(ScheduledToastNotification toast);
-}
+///
+/// Allows you to set additional properties on the object before the toast is scheduled.
+///
+/// The scheduled toast to modify that will be scheduled.
+public delegate void CustomizeScheduledToast(ScheduledToastNotification toast);
+
+///
+/// Allows you to set additional properties on the object before the toast is scheduled.
+///
+/// The scheduled toast to modify that will be scheduled.
+/// An operation.
+public delegate IAsyncAction CustomizeScheduledToastAsync(ScheduledToastNotification toast);
diff --git a/components/Notifications/src/Toasts/Builder/ToastContentBuilder.Actions.cs b/components/Notifications/src/Toasts/Builder/ToastContentBuilder.Actions.cs
index 2bfc96d06..c286e0d80 100644
--- a/components/Notifications/src/Toasts/Builder/ToastContentBuilder.Actions.cs
+++ b/components/Notifications/src/Toasts/Builder/ToastContentBuilder.Actions.cs
@@ -6,277 +6,277 @@
using System.Collections.Generic;
using System.Linq;
-namespace CommunityToolkit.Notifications
-{
+namespace CommunityToolkit.Notifications;
+
#pragma warning disable SA1008
#pragma warning disable SA1009
- ///
- /// Builder class used to create
- ///
- public partial class ToastContentBuilder
+///
+/// Builder class used to create
+///
+public partial class ToastContentBuilder
+{
+ private IToastActions Actions
{
- private IToastActions Actions
+ get
{
- get
+ if (Content.Actions == null)
{
- if (Content.Actions == null)
- {
- Content.Actions = new ToastActionsCustom();
- }
-
- return Content.Actions;
+ Content.Actions = new ToastActionsCustom();
}
- }
- private IList ButtonList
- {
- get
- {
- return ((ToastActionsCustom)Actions).Buttons;
- }
+ return Content.Actions;
}
+ }
- private IList InputList
+ private IList ButtonList
+ {
+ get
{
- get
- {
- return ((ToastActionsCustom)Actions).Inputs;
- }
+ return ((ToastActionsCustom)Actions).Buttons;
}
+ }
- private string SerializeArgumentsIncludingGeneric(ToastArguments arguments)
+ private IList InputList
+ {
+ get
{
- if (_genericArguments.Count == 0)
- {
- return arguments.ToString();
- }
-
- foreach (var genericArg in _genericArguments)
- {
- if (!arguments.Contains(genericArg.Key))
- {
- arguments.Add(genericArg.Key, genericArg.Value);
- }
- }
-
- return arguments.ToString();
+ return ((ToastActionsCustom)Actions).Inputs;
}
+ }
- ///
- /// Add a button to the current toast.
- ///
- /// Text to display on the button.
- /// Type of activation this button will use when clicked. Defaults to Foreground.
- /// App-defined string of arguments that the app can later retrieve once it is activated when the user clicks the button.
- /// The current instance of
- public ToastContentBuilder AddButton(string content, ToastActivationType activationType, string arguments)
+ private string SerializeArgumentsIncludingGeneric(ToastArguments arguments)
+ {
+ if (_genericArguments.Count == 0)
{
- return AddButton(content, activationType, arguments, default);
+ return arguments.ToString();
}
- ///
- /// Add a button to the current toast.
- ///
- /// Text to display on the button.
- /// Type of activation this button will use when clicked. Defaults to Foreground.
- /// App-defined string of arguments that the app can later retrieve once it is activated when the user clicks the button.
- /// Optional image icon for the button to display (required for buttons adjacent to inputs like quick reply).
- /// The current instance of
- public ToastContentBuilder AddButton(string content, ToastActivationType activationType, string arguments, Uri imageUri)
+ foreach (var genericArg in _genericArguments)
{
- // Add new button
- ToastButton button = new ToastButton(content, arguments)
+ if (!arguments.Contains(genericArg.Key))
{
- ActivationType = activationType
- };
-
- if (imageUri != default)
- {
- button.ImageUri = imageUri.OriginalString;
+ arguments.Add(genericArg.Key, genericArg.Value);
}
-
- return AddButton(button);
}
- ///
- /// Add a button to the current toast.
- ///
- /// An instance of class that implement for the button that will be used on the toast.
- /// The current instance of
- public ToastContentBuilder AddButton(IToastButton button)
- {
- if (button is ToastButton toastButton && toastButton.Content == null && toastButton.NeedsContent())
- {
- throw new InvalidOperationException("Content is required on button.");
- }
-
- // List has max 5 buttons
- if (ButtonList.Count == 5)
- {
- throw new InvalidOperationException("A toast can't have more than 5 buttons");
- }
+ return arguments.ToString();
+ }
- if (button is ToastButton b && b.CanAddArguments())
- {
- foreach (var arg in _genericArguments)
- {
- if (!b.ContainsArgument(arg.Key))
- {
- b.AddArgument(arg.Key, arg.Value);
- }
- }
- }
+ ///
+ /// Add a button to the current toast.
+ ///
+ /// Text to display on the button.
+ /// Type of activation this button will use when clicked. Defaults to Foreground.
+ /// App-defined string of arguments that the app can later retrieve once it is activated when the user clicks the button.
+ /// The current instance of
+ public ToastContentBuilder AddButton(string content, ToastActivationType activationType, string arguments)
+ {
+ return AddButton(content, activationType, arguments, default);
+ }
- ButtonList.Add(button);
+ ///
+ /// Add a button to the current toast.
+ ///
+ /// Text to display on the button.
+ /// Type of activation this button will use when clicked. Defaults to Foreground.
+ /// App-defined string of arguments that the app can later retrieve once it is activated when the user clicks the button.
+ /// Optional image icon for the button to display (required for buttons adjacent to inputs like quick reply).
+ /// The current instance of
+ public ToastContentBuilder AddButton(string content, ToastActivationType activationType, string arguments, Uri imageUri)
+ {
+ // Add new button
+ ToastButton button = new ToastButton(content, arguments)
+ {
+ ActivationType = activationType
+ };
- return this;
+ if (imageUri != default)
+ {
+ button.ImageUri = imageUri.OriginalString;
}
- ///
- /// Add an button to the toast that will be display to the right of the input text box, achieving a quick reply scenario.
- ///
- /// ID of an existing in order to have this button display to the right of the input, achieving a quick reply scenario.
- /// Text to display on the button.
- /// Type of activation this button will use when clicked. Defaults to Foreground.
- /// App-defined string of arguments that the app can later retrieve once it is activated when the user clicks the button.
- /// The current instance of
- public ToastContentBuilder AddButton(string textBoxId, string content, ToastActivationType activationType, string arguments)
+ return AddButton(button);
+ }
+
+ ///
+ /// Add a button to the current toast.
+ ///
+ /// An instance of class that implement for the button that will be used on the toast.
+ /// The current instance of
+ public ToastContentBuilder AddButton(IToastButton button)
+ {
+ if (button is ToastButton toastButton && toastButton.Content == null && toastButton.NeedsContent())
{
- return AddButton(textBoxId, content, activationType, arguments, default);
+ throw new InvalidOperationException("Content is required on button.");
}
- ///
- /// Add an button to the toast that will be display to the right of the input text box, achieving a quick reply scenario.
- ///
- /// ID of an existing in order to have this button display to the right of the input, achieving a quick reply scenario.
- /// Text to display on the button.
- /// Type of activation this button will use when clicked. Defaults to Foreground.
- /// App-defined string of arguments that the app can later retrieve once it is activated when the user clicks the button.
- /// An optional image icon for the button to display (required for buttons adjacent to inputs like quick reply)
- /// The current instance of
- public ToastContentBuilder AddButton(string textBoxId, string content, ToastActivationType activationType, string arguments, Uri imageUri)
+ // List has max 5 buttons
+ if (ButtonList.Count == 5)
{
- // Add new button
- ToastButton button = new ToastButton(content, arguments)
- {
- ActivationType = activationType,
- TextBoxId = textBoxId
- };
+ throw new InvalidOperationException("A toast can't have more than 5 buttons");
+ }
- if (imageUri != default)
+ if (button is ToastButton b && b.CanAddArguments())
+ {
+ foreach (var arg in _genericArguments)
{
- button.ImageUri = imageUri.OriginalString;
+ if (!b.ContainsArgument(arg.Key))
+ {
+ b.AddArgument(arg.Key, arg.Value);
+ }
}
-
- return AddButton(button);
}
- ///
- /// Add an input text box that the user can type into.
- ///
- /// Required ID property so that developers can retrieve user input once the app is activated.
- /// Placeholder text to be displayed on the text box when the user hasn't typed any text yet.
- /// Title text to display above the text box.
- /// The current instance of
- public ToastContentBuilder AddInputTextBox(
- string id,
- string placeHolderContent = default,
- string title = default)
- {
- var inputTextBox = new ToastTextBox(id);
+ ButtonList.Add(button);
- if (placeHolderContent != default)
- {
- inputTextBox.PlaceholderContent = placeHolderContent;
- }
+ return this;
+ }
- if (title != default)
- {
- inputTextBox.Title = title;
- }
+ ///
+ /// Add an button to the toast that will be display to the right of the input text box, achieving a quick reply scenario.
+ ///
+ /// ID of an existing in order to have this button display to the right of the input, achieving a quick reply scenario.
+ /// Text to display on the button.
+ /// Type of activation this button will use when clicked. Defaults to Foreground.
+ /// App-defined string of arguments that the app can later retrieve once it is activated when the user clicks the button.
+ /// The current instance of
+ public ToastContentBuilder AddButton(string textBoxId, string content, ToastActivationType activationType, string arguments)
+ {
+ return AddButton(textBoxId, content, activationType, arguments, default);
+ }
- return AddToastInput(inputTextBox);
- }
+ ///
+ /// Add an button to the toast that will be display to the right of the input text box, achieving a quick reply scenario.
+ ///
+ /// ID of an existing in order to have this button display to the right of the input, achieving a quick reply scenario.
+ /// Text to display on the button.
+ /// Type of activation this button will use when clicked. Defaults to Foreground.
+ /// App-defined string of arguments that the app can later retrieve once it is activated when the user clicks the button.
+ /// An optional image icon for the button to display (required for buttons adjacent to inputs like quick reply)
+ /// The current instance of
+ public ToastContentBuilder AddButton(string textBoxId, string content, ToastActivationType activationType, string arguments, Uri imageUri)
+ {
+ // Add new button
+ ToastButton button = new ToastButton(content, arguments)
+ {
+ ActivationType = activationType,
+ TextBoxId = textBoxId
+ };
- ///
- /// Add a combo box / drop-down menu that contain options for user to select.
- ///
- /// Required ID property used so that developers can retrieve user input once the app is activated.
- /// List of choices that will be available for user to select.
- /// The current instance of
- public ToastContentBuilder AddComboBox(string id, params (string comboBoxItemId, string comboBoxItemContent)[] choices)
+ if (imageUri != default)
{
- return AddComboBox(id, default, choices);
+ button.ImageUri = imageUri.OriginalString;
}
- ///
- /// Add a combo box / drop-down menu that contain options for user to select.
- ///
- /// Required ID property used so that developers can retrieve user input once the app is activated.
- /// Sets which item is selected by default, and refers to the Id property of . If you do not provide this or null, the default selection will be empty (user sees nothing).
- /// List of choices that will be available for user to select.
- /// The current instance of
- public ToastContentBuilder AddComboBox(string id, string defaultSelectionBoxItemId, params (string comboBoxItemId, string comboBoxItemContent)[] choices)
+ return AddButton(button);
+ }
+
+ ///
+ /// Add an input text box that the user can type into.
+ ///
+ /// Required ID property so that developers can retrieve user input once the app is activated.
+ /// Placeholder text to be displayed on the text box when the user hasn't typed any text yet.
+ /// Title text to display above the text box.
+ /// The current instance of
+ public ToastContentBuilder AddInputTextBox(
+ string id,
+ string placeHolderContent = default,
+ string title = default)
+ {
+ var inputTextBox = new ToastTextBox(id);
+
+ if (placeHolderContent != default)
{
- return AddComboBox(id, default, defaultSelectionBoxItemId, choices);
+ inputTextBox.PlaceholderContent = placeHolderContent;
}
- ///
- /// Add a combo box / drop-down menu that contain options for user to select.
- ///
- /// Required ID property used so that developers can retrieve user input once the app is activated.
- /// Title text to display above the Combo Box.
- /// Sets which item is selected by default, and refers to the Id property of . If you do not provide this or null, the default selection will be empty (user sees nothing).
- /// List of choices that will be available for user to select.
- /// The current instance of
- public ToastContentBuilder AddComboBox(string id, string title, string defaultSelectionBoxItemId, params (string comboBoxItemId, string comboBoxItemContent)[] choices)
+ if (title != default)
{
- return AddComboBox(id, title, defaultSelectionBoxItemId, choices as IEnumerable<(string, string)>);
+ inputTextBox.Title = title;
}
- ///
- /// Add a combo box / drop-down menu that contain options for user to select.
- ///
- /// Required ID property used so that developers can retrieve user input once the app is activated.
- /// Title text to display above the Combo Box.
- /// Sets which item is selected by default, and refers to the Id property of . If you do not provide this or null, the default selection will be empty (user sees nothing).
- /// List of choices that will be available for user to select.
- /// The current instance of
- public ToastContentBuilder AddComboBox(string id, string title, string defaultSelectionBoxItemId, IEnumerable<(string comboBoxItemId, string comboBoxItemContent)> choices)
- {
- var box = new ToastSelectionBox(id);
+ return AddToastInput(inputTextBox);
+ }
- if (defaultSelectionBoxItemId != default)
- {
- box.DefaultSelectionBoxItemId = defaultSelectionBoxItemId;
- }
+ ///
+ /// Add a combo box / drop-down menu that contain options for user to select.
+ ///
+ /// Required ID property used so that developers can retrieve user input once the app is activated.
+ /// List of choices that will be available for user to select.
+ /// The current instance of
+ public ToastContentBuilder AddComboBox(string id, params (string comboBoxItemId, string comboBoxItemContent)[] choices)
+ {
+ return AddComboBox(id, default, choices);
+ }
- if (title != default)
- {
- box.Title = title;
- }
+ ///
+ /// Add a combo box / drop-down menu that contain options for user to select.
+ ///
+ /// Required ID property used so that developers can retrieve user input once the app is activated.
+ /// Sets which item is selected by default, and refers to the Id property of . If you do not provide this or null, the default selection will be empty (user sees nothing).
+ /// List of choices that will be available for user to select.
+ /// The current instance of
+ public ToastContentBuilder AddComboBox(string id, string defaultSelectionBoxItemId, params (string comboBoxItemId, string comboBoxItemContent)[] choices)
+ {
+ return AddComboBox(id, default, defaultSelectionBoxItemId, choices);
+ }
- for (int i = 0; i < choices.Count(); i++)
- {
- var (comboBoxItemId, comboBoxItemContent) = choices.ElementAt(i);
- box.Items.Add(new ToastSelectionBoxItem(comboBoxItemId, comboBoxItemContent));
- }
+ ///
+ /// Add a combo box / drop-down menu that contain options for user to select.
+ ///
+ /// Required ID property used so that developers can retrieve user input once the app is activated.
+ /// Title text to display above the Combo Box.
+ /// Sets which item is selected by default, and refers to the Id property of . If you do not provide this or null, the default selection will be empty (user sees nothing).
+ /// List of choices that will be available for user to select.
+ /// The current instance of
+ public ToastContentBuilder AddComboBox(string id, string title, string defaultSelectionBoxItemId, params (string comboBoxItemId, string comboBoxItemContent)[] choices)
+ {
+ return AddComboBox(id, title, defaultSelectionBoxItemId, choices as IEnumerable<(string, string)>);
+ }
+
+ ///
+ /// Add a combo box / drop-down menu that contain options for user to select.
+ ///
+ /// Required ID property used so that developers can retrieve user input once the app is activated.
+ /// Title text to display above the Combo Box.
+ /// Sets which item is selected by default, and refers to the Id property of . If you do not provide this or null, the default selection will be empty (user sees nothing).
+ /// List of choices that will be available for user to select.
+ /// The current instance of
+ public ToastContentBuilder AddComboBox(string id, string title, string defaultSelectionBoxItemId, IEnumerable<(string comboBoxItemId, string comboBoxItemContent)> choices)
+ {
+ var box = new ToastSelectionBox(id);
- return AddToastInput(box);
+ if (defaultSelectionBoxItemId != default)
+ {
+ box.DefaultSelectionBoxItemId = defaultSelectionBoxItemId;
}
- ///
- /// Add an input option to the Toast.
- ///
- /// An instance of a class that implement that will be used on the toast.
- /// The current instance of
- public ToastContentBuilder AddToastInput(IToastInput input)
+ if (title != default)
{
- InputList.Add(input);
+ box.Title = title;
+ }
- return this;
+ for (int i = 0; i < choices.Count(); i++)
+ {
+ var (comboBoxItemId, comboBoxItemContent) = choices.ElementAt(i);
+ box.Items.Add(new ToastSelectionBoxItem(comboBoxItemId, comboBoxItemContent));
}
+
+ return AddToastInput(box);
}
+
+ ///
+ /// Add an input option to the Toast.
+ ///
+ /// An instance of a class that implement that will be used on the toast.
+ /// The current instance of
+ public ToastContentBuilder AddToastInput(IToastInput input)
+ {
+ InputList.Add(input);
+
+ return this;
+ }
+}
#pragma warning restore SA1008
#pragma warning restore SA1009
-}
+
diff --git a/components/Notifications/src/Toasts/Builder/ToastContentBuilder.Visuals.cs b/components/Notifications/src/Toasts/Builder/ToastContentBuilder.Visuals.cs
index 1e3ce72d9..849428b19 100644
--- a/components/Notifications/src/Toasts/Builder/ToastContentBuilder.Visuals.cs
+++ b/components/Notifications/src/Toasts/Builder/ToastContentBuilder.Visuals.cs
@@ -8,412 +8,411 @@
using System.Text;
using Windows.UI.Notifications;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// Builder class used to create
+///
+public partial class ToastContentBuilder
{
- ///
- /// Builder class used to create
- ///
- public partial class ToastContentBuilder
+ private ToastVisual Visual
{
- private ToastVisual Visual
+ get
{
- get
+ if (Content.Visual == null)
{
- if (Content.Visual == null)
- {
- Content.Visual = new ToastVisual();
- Content.Visual.BindingGeneric = new ToastBindingGeneric();
- }
-
- return Content.Visual;
+ Content.Visual = new ToastVisual();
+ Content.Visual.BindingGeneric = new ToastBindingGeneric();
}
+
+ return Content.Visual;
}
+ }
- private ToastGenericAppLogo AppLogoOverrideUri
+ private ToastGenericAppLogo AppLogoOverrideUri
+ {
+ get
{
- get
- {
- return Visual.BindingGeneric.AppLogoOverride;
- }
-
- set
- {
- Visual.BindingGeneric.AppLogoOverride = value;
- }
+ return Visual.BindingGeneric.AppLogoOverride;
}
- private ToastGenericAttributionText AttributionText
+ set
{
- get
- {
- return Visual.BindingGeneric.Attribution;
- }
-
- set
- {
- Visual.BindingGeneric.Attribution = value;
- }
+ Visual.BindingGeneric.AppLogoOverride = value;
}
+ }
- private ToastGenericHeroImage HeroImage
+ private ToastGenericAttributionText AttributionText
+ {
+ get
{
- get
- {
- return Visual.BindingGeneric.HeroImage;
- }
+ return Visual.BindingGeneric.Attribution;
+ }
- set
- {
- Visual.BindingGeneric.HeroImage = value;
- }
+ set
+ {
+ Visual.BindingGeneric.Attribution = value;
}
+ }
- private IList VisualChildren
+ private ToastGenericHeroImage HeroImage
+ {
+ get
{
- get
- {
- return Visual.BindingGeneric.Children;
- }
+ return Visual.BindingGeneric.HeroImage;
}
- ///
- /// Create an instance of NotificationData that can be used to update toast that has a progress bar.
- ///
- /// Instance of ToastContent that contain progress bars that need to be updated
- /// Index of the progress bar (0-based) that this notification data is updating in the case that toast has multiple progress bars. Default to 0.
- /// Title of the progress bar.
- /// Value of the progress bar.
- /// An optional string to be displayed instead of the default percentage string. If this isn't provided, something like "70%" will be displayed.
- /// A status string, which is displayed underneath the progress bar on the left. Default to empty.
- /// A sequence number to prevent out-of-order updates, or assign 0 to indicate "always update".
- /// An instance of NotificationData that can be used to update the toast.
- public static NotificationData CreateProgressBarData(ToastContent toast, int index = 0, string title = default, double? value = default, string valueStringOverride = default, string status = default, uint sequence = 0)
- {
- var progressBar = toast.Visual.BindingGeneric.Children.Where(c => c is AdaptiveProgressBar).ElementAt(index) as AdaptiveProgressBar;
- if (progressBar == null)
- {
- throw new ArgumentException(nameof(toast), "Given toast does not have any progress bar");
- }
+ set
+ {
+ Visual.BindingGeneric.HeroImage = value;
+ }
+ }
- NotificationData data = new NotificationData();
- data.SequenceNumber = sequence;
+ private IList VisualChildren
+ {
+ get
+ {
+ return Visual.BindingGeneric.Children;
+ }
+ }
- // Native C++ doesn't support BindableString
- if (progressBar.Title is BindableString bindableTitle && title != default)
- {
- data.Values[bindableTitle.BindingName] = title;
- }
+ ///
+ /// Create an instance of NotificationData that can be used to update toast that has a progress bar.
+ ///
+ /// Instance of ToastContent that contain progress bars that need to be updated
+ /// Index of the progress bar (0-based) that this notification data is updating in the case that toast has multiple progress bars. Default to 0.
+ /// Title of the progress bar.
+ /// Value of the progress bar.
+ /// An optional string to be displayed instead of the default percentage string. If this isn't provided, something like "70%" will be displayed.
+ /// A status string, which is displayed underneath the progress bar on the left. Default to empty.
+ /// A sequence number to prevent out-of-order updates, or assign 0 to indicate "always update".
+ /// An instance of NotificationData that can be used to update the toast.
+ public static NotificationData CreateProgressBarData(ToastContent toast, int index = 0, string title = default, double? value = default, string valueStringOverride = default, string status = default, uint sequence = 0)
+ {
+ var progressBar = toast.Visual.BindingGeneric.Children.Where(c => c is AdaptiveProgressBar).ElementAt(index) as AdaptiveProgressBar;
+ if (progressBar == null)
+ {
+ throw new ArgumentException(nameof(toast), "Given toast does not have any progress bar");
+ }
- if (progressBar.Value is BindableProgressBarValue bindableProgressValue && value != default)
- {
- data.Values[bindableProgressValue.BindingName] = value.ToString();
- }
+ NotificationData data = new NotificationData();
+ data.SequenceNumber = sequence;
- if (progressBar.ValueStringOverride is BindableString bindableValueStringOverride && valueStringOverride != default)
- {
- data.Values[bindableValueStringOverride.BindingName] = valueStringOverride;
- }
+ // Native C++ doesn't support BindableString
+ if (progressBar.Title is BindableString bindableTitle && title != default)
+ {
+ data.Values[bindableTitle.BindingName] = title;
+ }
- if (progressBar.Status is BindableString bindableStatus && status != default)
- {
- data.Values[bindableStatus.BindingName] = status;
- }
+ if (progressBar.Value is BindableProgressBarValue bindableProgressValue && value != default)
+ {
+ data.Values[bindableProgressValue.BindingName] = value.ToString();
+ }
- return data;
+ if (progressBar.ValueStringOverride is BindableString bindableValueStringOverride && valueStringOverride != default)
+ {
+ data.Values[bindableValueStringOverride.BindingName] = valueStringOverride;
}
- ///
- /// Add an Attribution Text to be displayed on the toast.
- ///
- /// Text to be displayed as Attribution Text
- /// The current instance of
- public ToastContentBuilder AddAttributionText(string text)
+ if (progressBar.Status is BindableString bindableStatus && status != default)
{
- return AddAttributionText(text, default);
+ data.Values[bindableStatus.BindingName] = status;
}
- ///
- /// Add an Attribution Text to be displayed on the toast.
- ///
- /// Text to be displayed as Attribution Text
- /// The target locale of the XML payload, specified as a BCP-47 language tags such as "en-US" or "fr-FR".
- /// The current instance of
- public ToastContentBuilder AddAttributionText(string text, string language)
+ return data;
+ }
+
+ ///
+ /// Add an Attribution Text to be displayed on the toast.
+ ///
+ /// Text to be displayed as Attribution Text
+ /// The current instance of
+ public ToastContentBuilder AddAttributionText(string text)
+ {
+ return AddAttributionText(text, default);
+ }
+
+ ///
+ /// Add an Attribution Text to be displayed on the toast.
+ ///
+ /// Text to be displayed as Attribution Text
+ /// The target locale of the XML payload, specified as a BCP-47 language tags such as "en-US" or "fr-FR".
+ /// The current instance of
+ public ToastContentBuilder AddAttributionText(string text, string language)
+ {
+ AttributionText = new ToastGenericAttributionText()
+ {
+ Text = text
+ };
+
+ if (language != default)
{
- AttributionText = new ToastGenericAttributionText()
- {
- Text = text
- };
+ AttributionText.Language = language;
+ }
- if (language != default)
- {
- AttributionText.Language = language;
- }
+ return this;
+ }
+
+ ///
+ /// Override the app logo with custom image of choice that will be displayed on the toast.
+ ///
+ /// 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.
+ /// Specify how the image should be cropped.
+ /// A description of the image, for users of assistive technologies.
+ /// A value whether Windows is allowed to append a query string to the image URI supplied in the Tile notification.
+ /// The current instance of
+ public ToastContentBuilder AddAppLogoOverride(
+ Uri uri,
+ ToastGenericAppLogoCrop? hintCrop = default,
+ string alternateText = default,
+ bool? addImageQuery = default)
+ {
+ AppLogoOverrideUri = new ToastGenericAppLogo()
+ {
+ Source = uri.OriginalString
+ };
- return this;
+ if (hintCrop != default)
+ {
+ AppLogoOverrideUri.HintCrop = hintCrop.Value;
}
- ///
- /// Override the app logo with custom image of choice that will be displayed on the toast.
- ///
- /// 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.
- /// Specify how the image should be cropped.
- /// A description of the image, for users of assistive technologies.
- /// A value whether Windows is allowed to append a query string to the image URI supplied in the Tile notification.
- /// The current instance of
- public ToastContentBuilder AddAppLogoOverride(
- Uri uri,
- ToastGenericAppLogoCrop? hintCrop = default,
- string alternateText = default,
- bool? addImageQuery = default)
+ if (alternateText != default)
{
- AppLogoOverrideUri = new ToastGenericAppLogo()
- {
- Source = uri.OriginalString
- };
+ AppLogoOverrideUri.AlternateText = alternateText;
+ }
- if (hintCrop != default)
- {
- AppLogoOverrideUri.HintCrop = hintCrop.Value;
- }
+ if (addImageQuery != default)
+ {
+ AppLogoOverrideUri.AddImageQuery = addImageQuery;
+ }
- if (alternateText != default)
- {
- AppLogoOverrideUri.AlternateText = alternateText;
- }
+ return this;
+ }
- if (addImageQuery != default)
- {
- AppLogoOverrideUri.AddImageQuery = addImageQuery;
- }
+ ///
+ /// Add a hero image to the toast.
+ ///
+ /// 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.
+ /// A description of the image, for users of assistive technologies.
+ /// A value whether Windows is allowed to append a query string to the image URI supplied in the Tile notification.
+ /// The current instance of
+ public ToastContentBuilder AddHeroImage(
+ Uri uri,
+ string alternateText = default,
+ bool? addImageQuery = default)
+ {
+ HeroImage = new ToastGenericHeroImage()
+ {
+ Source = uri.OriginalString
+ };
- return this;
+ if (alternateText != default)
+ {
+ HeroImage.AlternateText = alternateText;
}
- ///
- /// Add a hero image to the toast.
- ///
- /// 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.
- /// A description of the image, for users of assistive technologies.
- /// A value whether Windows is allowed to append a query string to the image URI supplied in the Tile notification.
- /// The current instance of
- public ToastContentBuilder AddHeroImage(
- Uri uri,
- string alternateText = default,
- bool? addImageQuery = default)
+ if (addImageQuery != default)
{
- HeroImage = new ToastGenericHeroImage()
- {
- Source = uri.OriginalString
- };
+ HeroImage.AddImageQuery = addImageQuery;
+ }
- if (alternateText != default)
- {
- HeroImage.AlternateText = alternateText;
- }
+ return this;
+ }
- if (addImageQuery != default)
- {
- HeroImage.AddImageQuery = addImageQuery;
- }
+ ///
+ /// Add an image inline with other toast content.
+ ///
+ /// 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.
+ /// A description of the image, for users of assistive technologies.
+ /// A value whether Windows is allowed to append a query string to the image URI supplied in the Tile notification.
+ /// A value whether a margin is removed. images have an 8px margin around them.
+ /// This property is not used. Setting this has no impact.
+ /// The current instance of
+ public ToastContentBuilder AddInlineImage(
+ Uri uri,
+ string alternateText = default,
+ bool? addImageQuery = default,
+ AdaptiveImageCrop? hintCrop = default,
+ bool? hintRemoveMargin = default)
+ {
+ var inlineImage = new AdaptiveImage()
+ {
+ Source = uri.OriginalString
+ };
- return this;
- }
-
- ///
- /// Add an image inline with other toast content.
- ///
- /// 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.
- /// A description of the image, for users of assistive technologies.
- /// A value whether Windows is allowed to append a query string to the image URI supplied in the Tile notification.
- /// A value whether a margin is removed. images have an 8px margin around them.
- /// This property is not used. Setting this has no impact.
- /// The current instance of
- public ToastContentBuilder AddInlineImage(
- Uri uri,
- string alternateText = default,
- bool? addImageQuery = default,
- AdaptiveImageCrop? hintCrop = default,
- bool? hintRemoveMargin = default)
- {
- var inlineImage = new AdaptiveImage()
- {
- Source = uri.OriginalString
- };
+ if (hintCrop != null)
+ {
+ inlineImage.HintCrop = hintCrop.Value;
+ }
- if (hintCrop != null)
- {
- inlineImage.HintCrop = hintCrop.Value;
- }
+ if (alternateText != default)
+ {
+ inlineImage.AlternateText = alternateText;
+ }
- if (alternateText != default)
- {
- inlineImage.AlternateText = alternateText;
- }
+ if (addImageQuery != default)
+ {
+ inlineImage.AddImageQuery = addImageQuery;
+ }
- if (addImageQuery != default)
- {
- inlineImage.AddImageQuery = addImageQuery;
- }
+ return AddVisualChild(inlineImage);
+ }
- return AddVisualChild(inlineImage);
- }
+ ///
+ /// Add a progress bar to the toast.
+ ///
+ /// Title of the progress bar.
+ /// Value of the progress bar. Default is 0
+ /// Determine if the progress bar value should be indeterminate. Default to false.
+ /// An optional string to be displayed instead of the default percentage string. If this isn't provided, something like "70%" will be displayed.
+ /// A status string which is displayed underneath the progress bar. This string should reflect the status of the operation, like "Downloading..." or "Installing...". Default to empty.
+ /// The current instance of
+ /// More info at: https://docs.microsoft.com/en-us/windows/uwp/design/shell/tiles-and-notifications/toast-progress-bar
+ public ToastContentBuilder AddProgressBar(string title = default, double? value = null, bool isIndeterminate = false, string valueStringOverride = default, string status = default)
+ {
+ int index = VisualChildren.Count(c => c is AdaptiveProgressBar);
- ///
- /// Add a progress bar to the toast.
- ///
- /// Title of the progress bar.
- /// Value of the progress bar. Default is 0
- /// Determine if the progress bar value should be indeterminate. Default to false.
- /// An optional string to be displayed instead of the default percentage string. If this isn't provided, something like "70%" will be displayed.
- /// A status string which is displayed underneath the progress bar. This string should reflect the status of the operation, like "Downloading..." or "Installing...". Default to empty.
- /// The current instance of
- /// More info at: https://docs.microsoft.com/en-us/windows/uwp/design/shell/tiles-and-notifications/toast-progress-bar
- public ToastContentBuilder AddProgressBar(string title = default, double? value = null, bool isIndeterminate = false, string valueStringOverride = default, string status = default)
+ var progressBar = new AdaptiveProgressBar()
{
- int index = VisualChildren.Count(c => c is AdaptiveProgressBar);
+ };
- var progressBar = new AdaptiveProgressBar()
- {
- };
+ if (title == default)
+ {
+ progressBar.Title = new BindableString($"progressBarTitle_{index}");
+ }
+ else
+ {
+ progressBar.Title = title;
+ }
- if (title == default)
- {
- progressBar.Title = new BindableString($"progressBarTitle_{index}");
- }
- else
- {
- progressBar.Title = title;
- }
+ if (isIndeterminate)
+ {
+ progressBar.Value = AdaptiveProgressBarValue.Indeterminate;
+ }
+ else if (value == null)
+ {
+ progressBar.Value = new BindableProgressBarValue($"progressValue_{index}");
+ }
+ else
+ {
+ progressBar.Value = value.Value;
+ }
- if (isIndeterminate)
- {
- progressBar.Value = AdaptiveProgressBarValue.Indeterminate;
- }
- else if (value == null)
- {
- progressBar.Value = new BindableProgressBarValue($"progressValue_{index}");
- }
- else
- {
- progressBar.Value = value.Value;
- }
+ if (valueStringOverride == default)
+ {
+ progressBar.ValueStringOverride = new BindableString($"progressValueString_{index}");
+ }
+ else
+ {
+ progressBar.ValueStringOverride = valueStringOverride;
+ }
- if (valueStringOverride == default)
- {
- progressBar.ValueStringOverride = new BindableString($"progressValueString_{index}");
- }
- else
- {
- progressBar.ValueStringOverride = valueStringOverride;
- }
+ if (status == default)
+ {
+ progressBar.Status = new BindableString($"progressStatus_{index}");
+ }
+ else
+ {
+ progressBar.Status = status;
+ }
- if (status == default)
- {
- progressBar.Status = new BindableString($"progressStatus_{index}");
- }
- else
- {
- progressBar.Status = status;
- }
+ return AddVisualChild(progressBar);
+ }
- return AddVisualChild(progressBar);
- }
-
- ///
- /// Add text to the toast.
- ///
- /// Custom text to display on the tile.
- /// This property is not used. Setting this has no effect.
- /// This property is not used. Setting this has no effect. If you need to disable wrapping, set hintMaxLines to 1.
- /// The maximum number of lines the text element is allowed to display.
- /// hintMinLines is not used. Setting this has no effect.
- /// hintAlign is not used. Setting this has no effect.
- ///
- /// 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.
- ///
- /// The current instance of
- /// Throws when attempting to add/reserve more than 4 lines on a single toast.
- /// Throws when value is larger than 2.
- /// More info at: https://docs.microsoft.com/en-us/windows/uwp/design/shell/tiles-and-notifications/adaptive-interactive-toasts#text-elements
- public ToastContentBuilder AddText(
- string text,
- AdaptiveTextStyle? hintStyle = null,
- bool? hintWrap = default,
- int? hintMaxLines = default,
- int? hintMinLines = default,
- AdaptiveTextAlign? hintAlign = null,
- string language = default)
- {
- int lineCount = GetCurrentTextLineCount();
- if (GetCurrentTextLineCount() == 4)
- {
- // Reached maximum, we can't go further.
- throw new InvalidOperationException("We have reached max lines allowed (4) per toast");
- }
+ ///
+ /// Add text to the toast.
+ ///
+ /// Custom text to display on the tile.
+ /// This property is not used. Setting this has no effect.
+ /// This property is not used. Setting this has no effect. If you need to disable wrapping, set hintMaxLines to 1.
+ /// The maximum number of lines the text element is allowed to display.
+ /// hintMinLines is not used. Setting this has no effect.
+ /// hintAlign is not used. Setting this has no effect.
+ ///
+ /// 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.
+ ///
+ /// The current instance of
+ /// Throws when attempting to add/reserve more than 4 lines on a single toast.
+ /// Throws when value is larger than 2.
+ /// More info at: https://docs.microsoft.com/en-us/windows/uwp/design/shell/tiles-and-notifications/adaptive-interactive-toasts#text-elements
+ public ToastContentBuilder AddText(
+ string text,
+ AdaptiveTextStyle? hintStyle = null,
+ bool? hintWrap = default,
+ int? hintMaxLines = default,
+ int? hintMinLines = default,
+ AdaptiveTextAlign? hintAlign = null,
+ string language = default)
+ {
+ int lineCount = GetCurrentTextLineCount();
+ if (GetCurrentTextLineCount() == 4)
+ {
+ // Reached maximum, we can't go further.
+ throw new InvalidOperationException("We have reached max lines allowed (4) per toast");
+ }
- AdaptiveText adaptive = new AdaptiveText()
- {
- Text = text
- };
+ AdaptiveText adaptive = new AdaptiveText()
+ {
+ Text = text
+ };
- if (hintMaxLines != default)
+ if (hintMaxLines != default)
+ {
+ if (hintMaxLines > 2)
{
- if (hintMaxLines > 2)
- {
- throw new ArgumentOutOfRangeException(nameof(hintMaxLines), "max line can't go more than 2 lines.");
- }
- else if ((lineCount + hintMaxLines) > 4)
- {
- throw new InvalidOperationException($"Can't exceed more than 4 lines of text per toast. Current line count : {lineCount} | Requesting line count: {lineCount + hintMaxLines}");
- }
-
- adaptive.HintMaxLines = hintMaxLines;
+ throw new ArgumentOutOfRangeException(nameof(hintMaxLines), "max line can't go more than 2 lines.");
}
-
- if (language != default)
+ else if ((lineCount + hintMaxLines) > 4)
{
- adaptive.Language = language;
+ throw new InvalidOperationException($"Can't exceed more than 4 lines of text per toast. Current line count : {lineCount} | Requesting line count: {lineCount + hintMaxLines}");
}
- return AddVisualChild(adaptive);
+ adaptive.HintMaxLines = hintMaxLines;
}
- ///
- /// Add a visual element to the toast.
- ///
- /// An instance of a class that implement .
- /// The current instance of
- public ToastContentBuilder AddVisualChild(IToastBindingGenericChild child)
+ if (language != default)
{
- VisualChildren.Add(child);
-
- return this;
+ adaptive.Language = language;
}
- private int GetCurrentTextLineCount()
- {
- if (!VisualChildren.Any(c => c is AdaptiveText))
- {
- return 0;
- }
+ return AddVisualChild(adaptive);
+ }
- var textList = VisualChildren.Where(c => c is AdaptiveText).Select(c => c as AdaptiveText).ToList();
+ ///
+ /// Add a visual element to the toast.
+ ///
+ /// An instance of a class that implement .
+ /// The current instance of
+ public ToastContentBuilder AddVisualChild(IToastBindingGenericChild child)
+ {
+ VisualChildren.Add(child);
- // First one is already the header.
- // https://docs.microsoft.com/en-us/windows/uwp/design/shell/tiles-and-notifications/adaptive-interactive-toasts#text-elements
- // The default (and maximum) is up to 2 lines of text for the title, and up to 4 lines (combined) for the two additional description elements (the second and third AdaptiveText).
- AdaptiveText text = textList.First();
- int count = 0;
- count += text.HintMaxLines ?? 2;
+ return this;
+ }
- for (int i = 1; i < textList.Count; i++)
- {
- text = textList[i];
- count += text.HintMaxLines ?? 1;
- }
+ private int GetCurrentTextLineCount()
+ {
+ if (!VisualChildren.Any(c => c is AdaptiveText))
+ {
+ return 0;
+ }
+
+ var textList = VisualChildren.Where(c => c is AdaptiveText).Select(c => c as AdaptiveText).ToList();
+
+ // First one is already the header.
+ // https://docs.microsoft.com/en-us/windows/uwp/design/shell/tiles-and-notifications/adaptive-interactive-toasts#text-elements
+ // The default (and maximum) is up to 2 lines of text for the title, and up to 4 lines (combined) for the two additional description elements (the second and third AdaptiveText).
+ AdaptiveText text = textList.First();
+ int count = 0;
+ count += text.HintMaxLines ?? 2;
- return count;
+ for (int i = 1; i < textList.Count; i++)
+ {
+ text = textList[i];
+ count += text.HintMaxLines ?? 1;
}
+
+ return count;
}
}
diff --git a/components/Notifications/src/Toasts/Builder/ToastContentBuilder.cs b/components/Notifications/src/Toasts/Builder/ToastContentBuilder.cs
index 2be548c84..793cd54ca 100644
--- a/components/Notifications/src/Toasts/Builder/ToastContentBuilder.cs
+++ b/components/Notifications/src/Toasts/Builder/ToastContentBuilder.cs
@@ -5,435 +5,434 @@
using System;
using System.Collections.Generic;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// Builder class used to create
+///
+public partial class ToastContentBuilder : IToastActivateableBuilder
{
+ private Dictionary _genericArguments = new Dictionary();
+
+ private bool _customArgumentsUsedOnToastItself;
+
///
- /// Builder class used to create
+ /// Gets internal instance of . This is equivalent to the call to .
///
- public partial class ToastContentBuilder : IToastActivateableBuilder
+ public ToastContent Content
{
- private Dictionary _genericArguments = new Dictionary();
+ get; private set;
+ }
- private bool _customArgumentsUsedOnToastItself;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public ToastContentBuilder()
+ {
+ Content = new ToastContent();
+ }
- ///
- /// Gets internal instance of . This is equivalent to the call to .
- ///
- public ToastContent Content
- {
- get; private set;
- }
+ ///
+ /// Add custom time stamp on the toast to override the time display on the toast.
+ ///
+ /// Custom Time to be displayed on the toast
+ /// The current instance of
+ public ToastContentBuilder AddCustomTimeStamp(DateTime dateTime)
+ {
+ Content.DisplayTimestamp = dateTime;
- ///
- /// Initializes a new instance of the class.
- ///
- public ToastContentBuilder()
- {
- Content = new ToastContent();
- }
+ return this;
+ }
- ///
- /// Add custom time stamp on the toast to override the time display on the toast.
- ///
- /// Custom Time to be displayed on the toast
- /// The current instance of
- public ToastContentBuilder AddCustomTimeStamp(DateTime dateTime)
- {
- Content.DisplayTimestamp = dateTime;
+ ///
+ /// Add a header to a toast.
+ ///
+ /// A developer-created identifier that uniquely identifies this header. If two notifications have the same header id, they will be displayed underneath the same header in Action Center.
+ /// A title for the header.
+ /// Developer-defined arguments that are returned to the app when the user clicks this header.
+ /// The current instance of
+ /// More info about toast header: https://docs.microsoft.com/en-us/windows/uwp/design/shell/tiles-and-notifications/toast-headers
+ public ToastContentBuilder AddHeader(string id, string title, ToastArguments arguments)
+ {
+ return AddHeader(id, title, arguments.ToString());
+ }
- return this;
- }
+ ///
+ /// Add a header to a toast.
+ ///
+ /// A developer-created identifier that uniquely identifies this header. If two notifications have the same header id, they will be displayed underneath the same header in Action Center.
+ /// A title for the header.
+ /// A developer-defined string of arguments that is returned to the app when the user clicks this header.
+ /// The current instance of
+ /// More info about toast header: https://docs.microsoft.com/en-us/windows/uwp/design/shell/tiles-and-notifications/toast-headers
+ public ToastContentBuilder AddHeader(string id, string title, string arguments)
+ {
+ Content.Header = new ToastHeader(id, title, arguments);
- ///
- /// Add a header to a toast.
- ///
- /// A developer-created identifier that uniquely identifies this header. If two notifications have the same header id, they will be displayed underneath the same header in Action Center.
- /// A title for the header.
- /// Developer-defined arguments that are returned to the app when the user clicks this header.
- /// The current instance of
- /// More info about toast header: https://docs.microsoft.com/en-us/windows/uwp/design/shell/tiles-and-notifications/toast-headers
- public ToastContentBuilder AddHeader(string id, string title, ToastArguments arguments)
- {
- return AddHeader(id, title, arguments.ToString());
- }
+ return this;
+ }
- ///
- /// Add a header to a toast.
- ///
- /// A developer-created identifier that uniquely identifies this header. If two notifications have the same header id, they will be displayed underneath the same header in Action Center.
- /// A title for the header.
- /// A developer-defined string of arguments that is returned to the app when the user clicks this header.
- /// The current instance of
- /// More info about toast header: https://docs.microsoft.com/en-us/windows/uwp/design/shell/tiles-and-notifications/toast-headers
- public ToastContentBuilder AddHeader(string id, string title, string arguments)
- {
- Content.Header = new ToastHeader(id, title, arguments);
+ ///
+ /// Adds a key (without value) to the activation arguments that will be returned when the toast notification or its buttons are clicked.
+ ///
+ /// The key.
+ /// The current instance of
+ public ToastContentBuilder AddArgument(string key)
+ {
+ return AddArgumentHelper(key, null);
+ }
- return this;
- }
+ ///
+ /// Adds a key/value to the activation arguments that will be returned when the toast notification or its buttons are clicked.
+ ///
+ /// The key for this value.
+ /// The value itself.
+ /// The current instance of
+ public ToastContentBuilder AddArgument(string key, string value)
+ {
+ return AddArgumentHelper(key, value);
+ }
- ///
- /// Adds a key (without value) to the activation arguments that will be returned when the toast notification or its buttons are clicked.
- ///
- /// The key.
- /// The current instance of
- public ToastContentBuilder AddArgument(string key)
- {
- return AddArgumentHelper(key, null);
- }
+ ///
+ /// Adds a key/value to the activation arguments that will be returned when the toast notification or its buttons are clicked.
+ ///
+ /// The key for this value.
+ /// The value itself.
+ /// The current instance of
+ public ToastContentBuilder AddArgument(string key, int value)
+ {
+ return AddArgumentHelper(key, value.ToString());
+ }
- ///
- /// Adds a key/value to the activation arguments that will be returned when the toast notification or its buttons are clicked.
- ///
- /// The key for this value.
- /// The value itself.
- /// The current instance of
- public ToastContentBuilder AddArgument(string key, string value)
- {
- return AddArgumentHelper(key, value);
- }
+ ///
+ /// Adds a key/value to the activation arguments that will be returned when the toast notification or its buttons are clicked.
+ ///
+ /// The key for this value.
+ /// The value itself.
+ /// The current instance of
+ public ToastContentBuilder AddArgument(string key, double value)
+ {
+ return AddArgumentHelper(key, value.ToString());
+ }
- ///
- /// Adds a key/value to the activation arguments that will be returned when the toast notification or its buttons are clicked.
- ///
- /// The key for this value.
- /// The value itself.
- /// The current instance of
- public ToastContentBuilder AddArgument(string key, int value)
- {
- return AddArgumentHelper(key, value.ToString());
- }
+ ///
+ /// Adds a key/value to the activation arguments that will be returned when the toast notification or its buttons are clicked.
+ ///
+ /// The key for this value.
+ /// The value itself.
+ /// The current instance of
+ public ToastContentBuilder AddArgument(string key, float value)
+ {
+ return AddArgumentHelper(key, value.ToString());
+ }
- ///
- /// Adds a key/value to the activation arguments that will be returned when the toast notification or its buttons are clicked.
- ///
- /// The key for this value.
- /// The value itself.
- /// The current instance of
- public ToastContentBuilder AddArgument(string key, double value)
- {
- return AddArgumentHelper(key, value.ToString());
- }
+ ///
+ /// Adds a key/value to the activation arguments that will be returned when the toast notification or its buttons are clicked.
+ ///
+ /// The key for this value.
+ /// The value itself.
+ /// The current instance of
+ public ToastContentBuilder AddArgument(string key, bool value)
+ {
+ return AddArgumentHelper(key, value ? "1" : "0"); // Encode as 1 or 0 to save string space
+ }
- ///
- /// Adds a key/value to the activation arguments that will be returned when the toast notification or its buttons are clicked.
- ///
- /// The key for this value.
- /// The value itself.
- /// The current instance of
- public ToastContentBuilder AddArgument(string key, float value)
- {
- return AddArgumentHelper(key, value.ToString());
- }
+ ///
+ /// Adds a key/value to the activation arguments that will be returned when the toast notification or its buttons are clicked.
+ ///
+ /// The key for this value.
+ /// The value itself. Note that the enums are stored using their numeric value, so be aware that changing your enum number values might break existing activation of toasts currently in Action Center.
+ /// The current instance of
+ public ToastContentBuilder AddArgument(string key, Enum value)
+ {
+ return AddArgumentHelper(key, ((int)(object)value).ToString());
+ }
- ///
- /// Adds a key/value to the activation arguments that will be returned when the toast notification or its buttons are clicked.
- ///
- /// The key for this value.
- /// The value itself.
- /// The current instance of
- public ToastContentBuilder AddArgument(string key, bool value)
+ private ToastContentBuilder AddArgumentHelper(string key, string value)
+ {
+ if (key == null)
{
- return AddArgumentHelper(key, value ? "1" : "0"); // Encode as 1 or 0 to save string space
+ throw new ArgumentNullException(nameof(key));
}
- ///
- /// Adds a key/value to the activation arguments that will be returned when the toast notification or its buttons are clicked.
- ///
- /// The key for this value.
- /// The value itself. Note that the enums are stored using their numeric value, so be aware that changing your enum number values might break existing activation of toasts currently in Action Center.
- /// The current instance of
- public ToastContentBuilder AddArgument(string key, Enum value)
+ bool alreadyExists = _genericArguments.ContainsKey(key);
+
+ _genericArguments[key] = value;
+
+ if (Content.ActivationType != ToastActivationType.Protocol && !_customArgumentsUsedOnToastItself)
{
- return AddArgumentHelper(key, ((int)(object)value).ToString());
+ Content.Launch = alreadyExists ? SerializeArgumentsHelper(_genericArguments) : AddArgumentHelper(Content.Launch, key, value);
}
- private ToastContentBuilder AddArgumentHelper(string key, string value)
+ if (Content.Actions is ToastActionsCustom actions)
{
- if (key == null)
- {
- throw new ArgumentNullException(nameof(key));
- }
-
- bool alreadyExists = _genericArguments.ContainsKey(key);
-
- _genericArguments[key] = value;
-
- if (Content.ActivationType != ToastActivationType.Protocol && !_customArgumentsUsedOnToastItself)
- {
- Content.Launch = alreadyExists ? SerializeArgumentsHelper(_genericArguments) : AddArgumentHelper(Content.Launch, key, value);
- }
-
- if (Content.Actions is ToastActionsCustom actions)
+ foreach (var button in actions.Buttons)
{
- foreach (var button in actions.Buttons)
+ if (button is ToastButton b && b.CanAddArguments() && !b.ContainsArgument(key))
{
- if (button is ToastButton b && b.CanAddArguments() && !b.ContainsArgument(key))
- {
- b.AddArgument(key, value);
- }
+ b.AddArgument(key, value);
}
}
-
- return this;
}
- private string SerializeArgumentsHelper(IDictionary arguments)
- {
- var args = new ToastArguments();
+ return this;
+ }
- foreach (var a in arguments)
- {
- args.Add(a.Key, a.Value);
- }
+ private string SerializeArgumentsHelper(IDictionary arguments)
+ {
+ var args = new ToastArguments();
- return args.ToString();
+ foreach (var a in arguments)
+ {
+ args.Add(a.Key, a.Value);
}
- private string AddArgumentHelper(string existing, string key, string value)
- {
- string pair = ToastArguments.EncodePair(key, value);
+ return args.ToString();
+ }
- if (existing == null)
- {
- return pair;
- }
- else
- {
- return existing + ToastArguments.Separator + pair;
- }
- }
+ private string AddArgumentHelper(string existing, string key, string value)
+ {
+ string pair = ToastArguments.EncodePair(key, value);
- ///
- /// Configures the toast notification to launch the specified url when the toast body is clicked.
- ///
- /// The protocol to launch.
- /// The current instance of
- public ToastContentBuilder SetProtocolActivation(Uri protocol)
+ if (existing == null)
{
- return SetProtocolActivation(protocol, default);
+ return pair;
}
-
- ///
- /// Configures the toast notification to launch the specified url when the toast body is clicked.
- ///
- /// The protocol to launch.
- /// New in Creators Update: The target PFN, so that regardless of whether multiple apps are registered to handle the same protocol uri, your desired app will always be launched.
- /// The current instance of
- public ToastContentBuilder SetProtocolActivation(Uri protocol, string targetApplicationPfn)
+ else
{
- Content.Launch = protocol.ToString();
- Content.ActivationType = ToastActivationType.Protocol;
-
- if (targetApplicationPfn != null)
- {
- if (Content.ActivationOptions == null)
- {
- Content.ActivationOptions = new ToastActivationOptions();
- }
-
- Content.ActivationOptions.ProtocolActivationTargetApplicationPfn = targetApplicationPfn;
- }
-
- return this;
+ return existing + ToastArguments.Separator + pair;
}
+ }
- ///
- /// Configures the toast notification to use background activation when the toast body is clicked.
- ///
- /// The current instance of
- public ToastContentBuilder SetBackgroundActivation()
- {
- Content.ActivationType = ToastActivationType.Background;
- return this;
- }
+ ///
+ /// Configures the toast notification to launch the specified url when the toast body is clicked.
+ ///
+ /// The protocol to launch.
+ /// The current instance of
+ public ToastContentBuilder SetProtocolActivation(Uri protocol)
+ {
+ return SetProtocolActivation(protocol, default);
+ }
- ///
- /// Instead of this method, for foreground/background activation, it is suggested to use and optionally . For protocol activation, you should use . Add info that can be used by the application when the app was activated/launched by the toast.
- ///
- /// Custom app-defined launch arguments to be passed along on toast activation
- /// Set the activation type that will be used when the user click on this toast
- /// The current instance of
- public ToastContentBuilder AddToastActivationInfo(string launchArgs, ToastActivationType activationType)
- {
- Content.Launch = launchArgs;
- Content.ActivationType = activationType;
- _customArgumentsUsedOnToastItself = true;
- return this;
- }
+ ///
+ /// Configures the toast notification to launch the specified url when the toast body is clicked.
+ ///
+ /// The protocol to launch.
+ /// New in Creators Update: The target PFN, so that regardless of whether multiple apps are registered to handle the same protocol uri, your desired app will always be launched.
+ /// The current instance of
+ public ToastContentBuilder SetProtocolActivation(Uri protocol, string targetApplicationPfn)
+ {
+ Content.Launch = protocol.ToString();
+ Content.ActivationType = ToastActivationType.Protocol;
- ///
- /// Sets the amount of time the Toast should display. You typically should use the
- /// Scenario attribute instead, which impacts how long a Toast stays on screen.
- ///
- /// Duration of the toast
- /// The current instance of
- public ToastContentBuilder SetToastDuration(ToastDuration duration)
+ if (targetApplicationPfn != null)
{
- Content.Duration = duration;
- return this;
- }
+ if (Content.ActivationOptions == null)
+ {
+ Content.ActivationOptions = new ToastActivationOptions();
+ }
- ///
- /// Sets the scenario, to make the Toast behave like an alarm, reminder, or more.
- ///
- /// Scenario to be used for the toast's behavior
- /// The current instance of
- public ToastContentBuilder SetToastScenario(ToastScenario scenario)
- {
- Content.Scenario = scenario;
- return this;
+ Content.ActivationOptions.ProtocolActivationTargetApplicationPfn = targetApplicationPfn;
}
- ///
- /// Set custom audio to go along with the toast.
- ///
- /// Source to the media that will be played when the toast is pop
- /// Indicating whether sound should repeat as long as the Toast is shown; false to play only once (default).
- /// Indicating whether sound is muted; false to allow the Toast notification sound to play (default).
- /// The current instance of
- public ToastContentBuilder AddAudio(
- Uri src,
- bool? loop = default,
- bool? silent = default)
- {
- var audio = new ToastAudio();
- audio.Src = src;
+ return this;
+ }
- if (loop != default)
- {
- audio.Loop = loop.Value;
- }
+ ///
+ /// Configures the toast notification to use background activation when the toast body is clicked.
+ ///
+ /// The current instance of
+ public ToastContentBuilder SetBackgroundActivation()
+ {
+ Content.ActivationType = ToastActivationType.Background;
+ return this;
+ }
- if (silent != default)
- {
- audio.Silent = silent.Value;
- }
+ ///
+ /// Instead of this method, for foreground/background activation, it is suggested to use and optionally . For protocol activation, you should use . Add info that can be used by the application when the app was activated/launched by the toast.
+ ///
+ /// Custom app-defined launch arguments to be passed along on toast activation
+ /// Set the activation type that will be used when the user click on this toast
+ /// The current instance of
+ public ToastContentBuilder AddToastActivationInfo(string launchArgs, ToastActivationType activationType)
+ {
+ Content.Launch = launchArgs;
+ Content.ActivationType = activationType;
+ _customArgumentsUsedOnToastItself = true;
+ return this;
+ }
- return AddAudio(audio);
- }
+ ///
+ /// Sets the amount of time the Toast should display. You typically should use the
+ /// Scenario attribute instead, which impacts how long a Toast stays on screen.
+ ///
+ /// Duration of the toast
+ /// The current instance of
+ public ToastContentBuilder SetToastDuration(ToastDuration duration)
+ {
+ Content.Duration = duration;
+ return this;
+ }
- ///
- /// Set custom audio to go along with the toast.
- ///
- /// The to set.
- /// The current instance of
- public ToastContentBuilder AddAudio(ToastAudio audio)
- {
- if (audio.Src != null && !audio.Src.IsFile && audio.Src.Scheme != "ms-appx" && audio.Src.Scheme != "ms-winsoundevent")
- {
- throw new InvalidOperationException("Audio Source must either be a ms-appx file, absolute file, or ms-winsoundevent.");
- }
+ ///
+ /// Sets the scenario, to make the Toast behave like an alarm, reminder, or more.
+ ///
+ /// Scenario to be used for the toast's behavior
+ /// The current instance of
+ public ToastContentBuilder SetToastScenario(ToastScenario scenario)
+ {
+ Content.Scenario = scenario;
+ return this;
+ }
- Content.Audio = audio;
- return this;
- }
+ ///
+ /// Set custom audio to go along with the toast.
+ ///
+ /// Source to the media that will be played when the toast is pop
+ /// Indicating whether sound should repeat as long as the Toast is shown; false to play only once (default).
+ /// Indicating whether sound is muted; false to allow the Toast notification sound to play (default).
+ /// The current instance of
+ public ToastContentBuilder AddAudio(
+ Uri src,
+ bool? loop = default,
+ bool? silent = default)
+ {
+ var audio = new ToastAudio();
+ audio.Src = src;
- ///
- /// Get the instance of that has been built by the builder with specified configuration so far.
- ///
- /// An instance of that can be used to create tile notification.
- public ToastContent GetToastContent()
+ if (loop != default)
{
- return Content;
+ audio.Loop = loop.Value;
}
- ///
- /// Retrieves the notification XML content as a WinRT XmlDocument, so that it can be used with a local Toast notification's constructor on either or .
- ///
- /// The notification XML content as a WinRT XmlDocument.
- public Windows.Data.Xml.Dom.XmlDocument GetXml()
+ if (silent != default)
{
- return GetToastContent().GetXml();
+ audio.Silent = silent.Value;
}
- ///
- /// Shows a new toast notification with the current content.
- ///
- public void Show()
+ return AddAudio(audio);
+ }
+
+ ///
+ /// Set custom audio to go along with the toast.
+ ///
+ /// The to set.
+ /// The current instance of
+ public ToastContentBuilder AddAudio(ToastAudio audio)
+ {
+ if (audio.Src != null && !audio.Src.IsFile && audio.Src.Scheme != "ms-appx" && audio.Src.Scheme != "ms-winsoundevent")
{
- CustomizeToast customize = null;
- Show(customize);
+ throw new InvalidOperationException("Audio Source must either be a ms-appx file, absolute file, or ms-winsoundevent.");
}
- ///
- /// Shows a new toast notification with the current content.
- ///
- /// Allows you to set additional properties on the object.
- public void Show(CustomizeToast customize)
- {
- var notif = new Windows.UI.Notifications.ToastNotification(GetToastContent().GetXml());
- customize?.Invoke(notif);
+ Content.Audio = audio;
+ return this;
+ }
- ToastNotificationManagerCompat.CreateToastNotifier().Show(notif);
- }
+ ///
+ /// Get the instance of that has been built by the builder with specified configuration so far.
+ ///
+ /// An instance of that can be used to create tile notification.
+ public ToastContent GetToastContent()
+ {
+ return Content;
+ }
- ///
- /// Shows a new toast notification with the current content.
- ///
- /// Allows you to set additional properties on the object.
- /// An operation that completes after your async customizations have completed.
- public Windows.Foundation.IAsyncAction Show(CustomizeToastAsync customize)
- {
- return ShowAsyncHelper(customize).AsAsyncAction();
- }
+ ///
+ /// Retrieves the notification XML content as a WinRT XmlDocument, so that it can be used with a local Toast notification's constructor on either or .
+ ///
+ /// The notification XML content as a WinRT XmlDocument.
+ public Windows.Data.Xml.Dom.XmlDocument GetXml()
+ {
+ return GetToastContent().GetXml();
+ }
- private async System.Threading.Tasks.Task ShowAsyncHelper(CustomizeToastAsync customize)
- {
- var notif = new Windows.UI.Notifications.ToastNotification(GetToastContent().GetXml());
+ ///
+ /// Shows a new toast notification with the current content.
+ ///
+ public void Show()
+ {
+ CustomizeToast customize = null;
+ Show(customize);
+ }
- if (customize != null)
- {
- await customize.Invoke(notif);
- }
+ ///
+ /// Shows a new toast notification with the current content.
+ ///
+ /// Allows you to set additional properties on the object.
+ public void Show(CustomizeToast customize)
+ {
+ var notif = new Windows.UI.Notifications.ToastNotification(GetToastContent().GetXml());
+ customize?.Invoke(notif);
- ToastNotificationManagerCompat.CreateToastNotifier().Show(notif);
- }
+ ToastNotificationManagerCompat.CreateToastNotifier().Show(notif);
+ }
+
+ ///
+ /// Shows a new toast notification with the current content.
+ ///
+ /// Allows you to set additional properties on the object.
+ /// An operation that completes after your async customizations have completed.
+ public Windows.Foundation.IAsyncAction Show(CustomizeToastAsync customize)
+ {
+ return ShowAsyncHelper(customize).AsAsyncAction();
+ }
- ///
- /// Schedules the notification.
- ///
- /// The date and time that Windows should display the toast notification. This time must be in the future.
- public void Schedule(DateTimeOffset deliveryTime)
+ private async System.Threading.Tasks.Task ShowAsyncHelper(CustomizeToastAsync customize)
+ {
+ var notif = new Windows.UI.Notifications.ToastNotification(GetToastContent().GetXml());
+
+ if (customize != null)
{
- CustomizeScheduledToast customize = null;
- Schedule(deliveryTime, customize);
+ await customize.Invoke(notif);
}
- ///
- /// Schedules the notification.
- ///
- /// The date and time that Windows should display the toast notification. This time must be in the future.
- /// Allows you to set additional properties on the object.
- public void Schedule(DateTimeOffset deliveryTime, CustomizeScheduledToast customize)
- {
- var notif = new Windows.UI.Notifications.ScheduledToastNotification(GetToastContent().GetXml(), deliveryTime);
- customize?.Invoke(notif);
+ ToastNotificationManagerCompat.CreateToastNotifier().Show(notif);
+ }
- ToastNotificationManagerCompat.CreateToastNotifier().AddToSchedule(notif);
- }
+ ///
+ /// Schedules the notification.
+ ///
+ /// The date and time that Windows should display the toast notification. This time must be in the future.
+ public void Schedule(DateTimeOffset deliveryTime)
+ {
+ CustomizeScheduledToast customize = null;
+ Schedule(deliveryTime, customize);
+ }
- ///
- /// Schedules the notification.
- ///
- /// The date and time that Windows should display the toast notification. This time must be in the future.
- /// Allows you to set additional properties on the object.
- /// An operation that completes after your async customizations have completed.
- public Windows.Foundation.IAsyncAction Schedule(DateTimeOffset deliveryTime, CustomizeScheduledToastAsync customize)
- {
- return ScheduleAsyncHelper(deliveryTime, customize).AsAsyncAction();
- }
+ ///
+ /// Schedules the notification.
+ ///
+ /// The date and time that Windows should display the toast notification. This time must be in the future.
+ /// Allows you to set additional properties on the object.
+ public void Schedule(DateTimeOffset deliveryTime, CustomizeScheduledToast customize)
+ {
+ var notif = new Windows.UI.Notifications.ScheduledToastNotification(GetToastContent().GetXml(), deliveryTime);
+ customize?.Invoke(notif);
- private async System.Threading.Tasks.Task ScheduleAsyncHelper(DateTimeOffset deliveryTime, CustomizeScheduledToastAsync customize = null)
- {
- var notif = new Windows.UI.Notifications.ScheduledToastNotification(GetToastContent().GetXml(), deliveryTime);
+ ToastNotificationManagerCompat.CreateToastNotifier().AddToSchedule(notif);
+ }
- if (customize != null)
- {
- await customize.Invoke(notif);
- }
+ ///
+ /// Schedules the notification.
+ ///
+ /// The date and time that Windows should display the toast notification. This time must be in the future.
+ /// Allows you to set additional properties on the object.
+ /// An operation that completes after your async customizations have completed.
+ public Windows.Foundation.IAsyncAction Schedule(DateTimeOffset deliveryTime, CustomizeScheduledToastAsync customize)
+ {
+ return ScheduleAsyncHelper(deliveryTime, customize).AsAsyncAction();
+ }
+
+ private async System.Threading.Tasks.Task ScheduleAsyncHelper(DateTimeOffset deliveryTime, CustomizeScheduledToastAsync customize = null)
+ {
+ var notif = new Windows.UI.Notifications.ScheduledToastNotification(GetToastContent().GetXml(), deliveryTime);
- ToastNotificationManagerCompat.CreateToastNotifier().AddToSchedule(notif);
+ if (customize != null)
+ {
+ await customize.Invoke(notif);
}
+
+ ToastNotificationManagerCompat.CreateToastNotifier().AddToSchedule(notif);
}
}
diff --git a/components/Notifications/src/Toasts/Compat/ToastNotificationHistoryCompat.cs b/components/Notifications/src/Toasts/Compat/ToastNotificationHistoryCompat.cs
index f94a46ff2..6e0429ae4 100644
--- a/components/Notifications/src/Toasts/Compat/ToastNotificationHistoryCompat.cs
+++ b/components/Notifications/src/Toasts/Compat/ToastNotificationHistoryCompat.cs
@@ -5,86 +5,85 @@
using System.Collections.Generic;
using Windows.UI.Notifications;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// Manages the toast notifications for an app including the ability the clear all toast history and removing individual toasts.
+///
+public class ToastNotificationHistoryCompat
{
+ private string _aumid;
+ private ToastNotificationHistory _history;
+
+ internal ToastNotificationHistoryCompat(string aumid)
+ {
+ _aumid = aumid;
+ _history = ToastNotificationManager.History;
+ }
+
///
- /// Manages the toast notifications for an app including the ability the clear all toast history and removing individual toasts.
+ /// Removes all notifications sent by this app from action center.
///
- public class ToastNotificationHistoryCompat
+ public void Clear()
{
- private string _aumid;
- private ToastNotificationHistory _history;
-
- internal ToastNotificationHistoryCompat(string aumid)
+ if (_aumid != null)
{
- _aumid = aumid;
- _history = ToastNotificationManager.History;
+ _history.Clear(_aumid);
}
-
- ///
- /// Removes all notifications sent by this app from action center.
- ///
- public void Clear()
+ else
{
- if (_aumid != null)
- {
- _history.Clear(_aumid);
- }
- else
- {
- _history.Clear();
- }
+ _history.Clear();
}
+ }
- ///
- /// Gets all notifications sent by this app that are currently still in Action Center.
- ///
- /// A collection of toasts.
- public IReadOnlyList GetHistory()
+ ///
+ /// Gets all notifications sent by this app that are currently still in Action Center.
+ ///
+ /// A collection of toasts.
+ public IReadOnlyList GetHistory()
+ {
+ return _aumid != null ? _history.GetHistory(_aumid) : _history.GetHistory();
+ }
+
+ ///
+ /// Removes an individual toast, with the specified tag label, from action center.
+ ///
+ /// The tag label of the toast notification to be removed.
+ public void Remove(string tag)
+ {
+ _history.Remove(tag);
+ }
+
+ ///
+ /// Removes a toast notification from the action using the notification's tag and group labels.
+ ///
+ /// The tag label of the toast notification to be removed.
+ /// The group label of the toast notification to be removed.
+ public void Remove(string tag, string group)
+ {
+ if (_aumid != null)
{
- return _aumid != null ? _history.GetHistory(_aumid) : _history.GetHistory();
+ _history.Remove(tag, group, _aumid);
}
-
- ///
- /// Removes an individual toast, with the specified tag label, from action center.
- ///
- /// The tag label of the toast notification to be removed.
- public void Remove(string tag)
+ else
{
- _history.Remove(tag);
+ _history.Remove(tag, group);
}
+ }
- ///
- /// Removes a toast notification from the action using the notification's tag and group labels.
- ///
- /// The tag label of the toast notification to be removed.
- /// The group label of the toast notification to be removed.
- public void Remove(string tag, string group)
+ ///
+ /// Removes a group of toast notifications, identified by the specified group label, from action center.
+ ///
+ /// The group label of the toast notifications to be removed.
+ public void RemoveGroup(string group)
+ {
+ if (_aumid != null)
{
- if (_aumid != null)
- {
- _history.Remove(tag, group, _aumid);
- }
- else
- {
- _history.Remove(tag, group);
- }
+ _history.RemoveGroup(group, _aumid);
}
-
- ///
- /// Removes a group of toast notifications, identified by the specified group label, from action center.
- ///
- /// The group label of the toast notifications to be removed.
- public void RemoveGroup(string group)
+ else
{
- if (_aumid != null)
- {
- _history.RemoveGroup(group, _aumid);
- }
- else
- {
- _history.RemoveGroup(group);
- }
+ _history.RemoveGroup(group);
}
}
}
diff --git a/components/Notifications/src/Toasts/Compat/ToastNotificationManagerCompat.cs b/components/Notifications/src/Toasts/Compat/ToastNotificationManagerCompat.cs
index 443e359fb..cd8f6f794 100644
--- a/components/Notifications/src/Toasts/Compat/ToastNotificationManagerCompat.cs
+++ b/components/Notifications/src/Toasts/Compat/ToastNotificationManagerCompat.cs
@@ -15,42 +15,41 @@
using Windows.Foundation.Collections;
using Windows.UI.Notifications;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// Provides access to sending and managing toast notifications. Works for all types of apps, even Win32 non-MSIX/sparse apps.
+///
+public static class ToastNotificationManagerCompat
{
///
- /// Provides access to sending and managing toast notifications. Works for all types of apps, even Win32 non-MSIX/sparse apps.
+ /// Creates a toast notifier.
///
- public static class ToastNotificationManagerCompat
+ /// An instance of the toast notifier.
+ public static ToastNotifierCompat CreateToastNotifier()
{
- ///
- /// Creates a toast notifier.
- ///
- /// An instance of the toast notifier.
- public static ToastNotifierCompat CreateToastNotifier()
- {
- return new ToastNotifierCompat(ToastNotificationManager.CreateToastNotifier());
- }
+ return new ToastNotifierCompat(ToastNotificationManager.CreateToastNotifier());
+ }
- ///
- /// Gets the object.
- ///
- public static ToastNotificationHistoryCompat History
+ ///
+ /// Gets the object.
+ ///
+ public static ToastNotificationHistoryCompat History
+ {
+ get
{
- get
- {
- return new ToastNotificationHistoryCompat(null);
- }
+ return new ToastNotificationHistoryCompat(null);
}
+ }
- ///
- /// Gets a value indicating whether http images can be used within toasts. This is true if running with package identity (UWP, MSIX, or sparse package).
- ///
- public static bool CanUseHttpImages
+ ///
+ /// Gets a value indicating whether http images can be used within toasts. This is true if running with package identity (UWP, MSIX, or sparse package).
+ ///
+ public static bool CanUseHttpImages
+ {
+ get
{
- get
- {
- return true;
- }
+ return true;
}
}
}
diff --git a/components/Notifications/src/Toasts/Compat/ToastNotifierCompat.cs b/components/Notifications/src/Toasts/Compat/ToastNotifierCompat.cs
index a27ff19a5..a4637f76a 100644
--- a/components/Notifications/src/Toasts/Compat/ToastNotifierCompat.cs
+++ b/components/Notifications/src/Toasts/Compat/ToastNotifierCompat.cs
@@ -5,97 +5,96 @@
using System.Collections.Generic;
using Windows.UI.Notifications;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// Allows you to show and schedule toast notifications.
+///
+public sealed class ToastNotifierCompat
{
+ private ToastNotifier _notifier;
+
+ internal ToastNotifierCompat(ToastNotifier notifier)
+ {
+ _notifier = notifier;
+ }
+
///
- /// Allows you to show and schedule toast notifications.
+ /// Displays the specified toast notification.
///
- public sealed class ToastNotifierCompat
+ /// The object that contains the content of the toast notification to display.
+ public void Show(ToastNotification notification)
{
- private ToastNotifier _notifier;
-
- internal ToastNotifierCompat(ToastNotifier notifier)
- {
- _notifier = notifier;
- }
-
- ///
- /// Displays the specified toast notification.
- ///
- /// The object that contains the content of the toast notification to display.
- public void Show(ToastNotification notification)
- {
- _notifier.Show(notification);
- }
+ _notifier.Show(notification);
+ }
- ///
- /// Hides the specified toast notification from the screen (moves it into Action Center).
- ///
- /// The object that specifies the toast to hide.
- public void Hide(ToastNotification notification)
- {
- _notifier.Hide(notification);
- }
+ ///
+ /// Hides the specified toast notification from the screen (moves it into Action Center).
+ ///
+ /// The object that specifies the toast to hide.
+ public void Hide(ToastNotification notification)
+ {
+ _notifier.Hide(notification);
+ }
- ///
- /// Adds a ScheduledToastNotification for later display by Windows.
- ///
- /// The scheduled toast notification, which includes its content and timing instructions.
- public void AddToSchedule(ScheduledToastNotification scheduledToast)
- {
- _notifier.AddToSchedule(scheduledToast);
- }
+ ///
+ /// Adds a ScheduledToastNotification for later display by Windows.
+ ///
+ /// The scheduled toast notification, which includes its content and timing instructions.
+ public void AddToSchedule(ScheduledToastNotification scheduledToast)
+ {
+ _notifier.AddToSchedule(scheduledToast);
+ }
- ///
- /// Cancels the scheduled display of a specified ScheduledToastNotification.
- ///
- /// The notification to remove from the schedule.
- public void RemoveFromSchedule(ScheduledToastNotification scheduledToast)
- {
- _notifier.RemoveFromSchedule(scheduledToast);
- }
+ ///
+ /// Cancels the scheduled display of a specified ScheduledToastNotification.
+ ///
+ /// The notification to remove from the schedule.
+ public void RemoveFromSchedule(ScheduledToastNotification scheduledToast)
+ {
+ _notifier.RemoveFromSchedule(scheduledToast);
+ }
- ///
- /// Gets the collection of ScheduledToastNotification objects that this app has scheduled for display.
- ///
- /// The collection of scheduled toast notifications that the app bound to this notifier has scheduled for timed display.
- public IReadOnlyList GetScheduledToastNotifications()
- {
- return _notifier.GetScheduledToastNotifications();
- }
+ ///
+ /// Gets the collection of ScheduledToastNotification objects that this app has scheduled for display.
+ ///
+ /// The collection of scheduled toast notifications that the app bound to this notifier has scheduled for timed display.
+ public IReadOnlyList GetScheduledToastNotifications()
+ {
+ return _notifier.GetScheduledToastNotifications();
+ }
- ///
- /// Updates the existing toast notification that has the specified tag and belongs to the specified notification group.
- ///
- /// An object that contains the updated info.
- /// The identifier of the toast notification to update.
- /// The ID of the ToastCollection that contains the notification.
- /// A value that indicates the result of the update (failure, success, etc).
- public NotificationUpdateResult Update(NotificationData data, string tag, string group)
- {
- return _notifier.Update(data, tag, group);
- }
+ ///
+ /// Updates the existing toast notification that has the specified tag and belongs to the specified notification group.
+ ///
+ /// An object that contains the updated info.
+ /// The identifier of the toast notification to update.
+ /// The ID of the ToastCollection that contains the notification.
+ /// A value that indicates the result of the update (failure, success, etc).
+ public NotificationUpdateResult Update(NotificationData data, string tag, string group)
+ {
+ return _notifier.Update(data, tag, group);
+ }
- ///
- /// Updates the existing toast notification that has the specified tag.
- ///
- /// An object that contains the updated info.
- /// The identifier of the toast notification to update.
- /// A value that indicates the result of the update (failure, success, etc).
- public NotificationUpdateResult Update(NotificationData data, string tag)
- {
- return _notifier.Update(data, tag);
- }
+ ///
+ /// Updates the existing toast notification that has the specified tag.
+ ///
+ /// An object that contains the updated info.
+ /// The identifier of the toast notification to update.
+ /// A value that indicates the result of the update (failure, success, etc).
+ public NotificationUpdateResult Update(NotificationData data, string tag)
+ {
+ return _notifier.Update(data, tag);
+ }
- ///
- /// Gets a value that tells you whether there is an app, user, or system block that prevents the display of a toast notification.
- ///
- public NotificationSetting Setting
+ ///
+ /// Gets a value that tells you whether there is an app, user, or system block that prevents the display of a toast notification.
+ ///
+ public NotificationSetting Setting
+ {
+ get
{
- get
- {
- return _notifier.Setting;
- }
+ return _notifier.Setting;
}
}
}
diff --git a/components/Notifications/src/Toasts/Elements/Element_Toast.cs b/components/Notifications/src/Toasts/Elements/Element_Toast.cs
index 1e158248c..6a895f476 100644
--- a/components/Notifications/src/Toasts/Elements/Element_Toast.cs
+++ b/components/Notifications/src/Toasts/Elements/Element_Toast.cs
@@ -5,152 +5,151 @@
using System;
using System.Collections.Generic;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+internal sealed class Element_Toast : BaseElement, IElement_ToastActivatable, IHaveXmlAdditionalProperties, IHaveXmlName, IHaveXmlNamedProperties, IHaveXmlChildren
{
- internal sealed class Element_Toast : BaseElement, IElement_ToastActivatable, IHaveXmlAdditionalProperties, IHaveXmlName, IHaveXmlNamedProperties, IHaveXmlChildren
- {
- internal const ToastScenario DEFAULT_SCENARIO = ToastScenario.Default;
- internal const Element_ToastActivationType DEFAULT_ACTIVATION_TYPE = Element_ToastActivationType.Foreground;
- internal const ToastDuration DEFAULT_DURATION = ToastDuration.Short;
+ internal const ToastScenario DEFAULT_SCENARIO = ToastScenario.Default;
+ internal const Element_ToastActivationType DEFAULT_ACTIVATION_TYPE = Element_ToastActivationType.Foreground;
+ internal const ToastDuration DEFAULT_DURATION = ToastDuration.Short;
- public Element_ToastActivationType ActivationType { get; set; } = DEFAULT_ACTIVATION_TYPE;
+ public Element_ToastActivationType ActivationType { get; set; } = DEFAULT_ACTIVATION_TYPE;
- public string ProtocolActivationTargetApplicationPfn { get; set; }
+ public string ProtocolActivationTargetApplicationPfn { get; set; }
- public ToastAfterActivationBehavior AfterActivationBehavior
+ public ToastAfterActivationBehavior AfterActivationBehavior
+ {
+ get
{
- get
- {
- return ToastAfterActivationBehavior.Default;
- }
+ return ToastAfterActivationBehavior.Default;
+ }
- set
+ set
+ {
+ if (value != ToastAfterActivationBehavior.Default)
{
- if (value != ToastAfterActivationBehavior.Default)
- {
- throw new InvalidOperationException("AfterActivationBehavior on ToastContent only supports the Default value.");
- }
+ throw new InvalidOperationException("AfterActivationBehavior on ToastContent only supports the Default value.");
}
}
+ }
- public ToastDuration Duration { get; set; } = DEFAULT_DURATION;
+ public ToastDuration Duration { get; set; } = DEFAULT_DURATION;
- public string Launch { get; set; }
+ public string Launch { get; set; }
- public ToastScenario Scenario { get; set; } = DEFAULT_SCENARIO;
+ public ToastScenario Scenario { get; set; } = DEFAULT_SCENARIO;
- public DateTimeOffset? DisplayTimestamp { get; set; }
+ public DateTimeOffset? DisplayTimestamp { get; set; }
- public Element_ToastVisual Visual { get; set; }
+ public Element_ToastVisual Visual { get; set; }
- public Element_ToastAudio Audio { get; set; }
+ public Element_ToastAudio Audio { get; set; }
- public Element_ToastActions Actions { get; set; }
+ public Element_ToastActions Actions { get; set; }
- public Element_ToastHeader Header { get; set; }
+ public Element_ToastHeader Header { get; set; }
- public string HintToastId { get; set; }
+ public string HintToastId { get; set; }
- public string HintPeople { get; set; }
+ public string HintPeople { get; set; }
- public IReadOnlyDictionary AdditionalProperties { get; set; }
+ public IReadOnlyDictionary AdditionalProperties { get; set; }
- public static Element_ToastActivationType ConvertActivationType(ToastActivationType publicType)
+ public static Element_ToastActivationType ConvertActivationType(ToastActivationType publicType)
+ {
+ switch (publicType)
{
- switch (publicType)
- {
- case ToastActivationType.Foreground:
- return Element_ToastActivationType.Foreground;
+ case ToastActivationType.Foreground:
+ return Element_ToastActivationType.Foreground;
- case ToastActivationType.Background:
- return Element_ToastActivationType.Background;
+ case ToastActivationType.Background:
+ return Element_ToastActivationType.Background;
- case ToastActivationType.Protocol:
- return Element_ToastActivationType.Protocol;
+ case ToastActivationType.Protocol:
+ return Element_ToastActivationType.Protocol;
- default:
- throw new NotImplementedException();
- }
+ default:
+ throw new NotImplementedException();
}
+ }
- ///
- string IHaveXmlName.Name => "toast";
+ ///
+ string IHaveXmlName.Name => "toast";
- ///
- IEnumerable IHaveXmlChildren.Children => new object[] { Visual, Audio, Actions, Header };
+ ///
+ IEnumerable IHaveXmlChildren.Children => new object[] { Visual, Audio, Actions, Header };
- ///
- IEnumerable> IHaveXmlNamedProperties.EnumerateNamedProperties()
+ ///
+ IEnumerable> IHaveXmlNamedProperties.EnumerateNamedProperties()
+ {
+ if (ActivationType != DEFAULT_ACTIVATION_TYPE)
{
- if (ActivationType != DEFAULT_ACTIVATION_TYPE)
- {
- yield return new("activationType", ActivationType.ToPascalCaseString());
- }
-
- yield return new("protocolActivationTargetApplicationPfn", ProtocolActivationTargetApplicationPfn);
+ yield return new("activationType", ActivationType.ToPascalCaseString());
+ }
- if (AfterActivationBehavior != ToastAfterActivationBehavior.Default)
- {
- yield return new("afterActivationBehavior", AfterActivationBehavior.ToPascalCaseString());
- }
+ yield return new("protocolActivationTargetApplicationPfn", ProtocolActivationTargetApplicationPfn);
- if (Duration != DEFAULT_DURATION)
- {
- yield return new("duration", Duration.ToPascalCaseString());
- }
+ if (AfterActivationBehavior != ToastAfterActivationBehavior.Default)
+ {
+ yield return new("afterActivationBehavior", AfterActivationBehavior.ToPascalCaseString());
+ }
- yield return new("launch", Launch);
+ if (Duration != DEFAULT_DURATION)
+ {
+ yield return new("duration", Duration.ToPascalCaseString());
+ }
- if (Scenario != DEFAULT_SCENARIO)
- {
- yield return new("scenario", Scenario.ToPascalCaseString());
- }
+ yield return new("launch", Launch);
- yield return new("displayTimestamp", DisplayTimestamp);
- yield return new("hint-toastId", HintToastId);
- yield return new("hint-people", HintPeople);
+ if (Scenario != DEFAULT_SCENARIO)
+ {
+ yield return new("scenario", Scenario.ToPascalCaseString());
}
+
+ yield return new("displayTimestamp", DisplayTimestamp);
+ yield return new("hint-toastId", HintToastId);
+ yield return new("hint-people", HintPeople);
}
+}
+///
+/// The amount of time the Toast should display.
+///
+public enum ToastDuration
+{
///
- /// The amount of time the Toast should display.
+ /// Default value. Toast appears for a short while and then goes into Action Center.
///
- public enum ToastDuration
- {
- ///
- /// Default value. Toast appears for a short while and then goes into Action Center.
- ///
- Short,
-
- ///
- /// Toast stays on-screen for longer, and then goes into Action Center.
- ///
- Long
- }
+ Short,
///
- /// Specifies the scenario, controlling behaviors about the Toast.
+ /// Toast stays on-screen for longer, and then goes into Action Center.
///
- public enum ToastScenario
- {
- ///
- /// The normal Toast behavior. The Toast appears for a short duration, and then automatically dismisses into Action Center.
- ///
- Default,
-
- ///
- /// Causes the Toast to stay on-screen and expanded until the user takes action. Also causes a looping alarm sound to be selected by default.
- ///
- Alarm,
-
- ///
- /// Causes the Toast to stay on-screen and expanded until the user takes action.
- ///
- Reminder,
-
- ///
- /// Causes the Toast to stay on-screen and expanded until the user takes action (on Mobile this expands to full screen). Also causes a looping incoming call sound to be selected by default.
- ///
- IncomingCall
- }
+ Long
+}
+
+///
+/// Specifies the scenario, controlling behaviors about the Toast.
+///
+public enum ToastScenario
+{
+ ///
+ /// The normal Toast behavior. The Toast appears for a short duration, and then automatically dismisses into Action Center.
+ ///
+ Default,
+
+ ///
+ /// Causes the Toast to stay on-screen and expanded until the user takes action. Also causes a looping alarm sound to be selected by default.
+ ///
+ Alarm,
+
+ ///
+ /// Causes the Toast to stay on-screen and expanded until the user takes action.
+ ///
+ Reminder,
+
+ ///
+ /// Causes the Toast to stay on-screen and expanded until the user takes action (on Mobile this expands to full screen). Also causes a looping incoming call sound to be selected by default.
+ ///
+ IncomingCall
}
\ No newline at end of file
diff --git a/components/Notifications/src/Toasts/Elements/Element_ToastAction.cs b/components/Notifications/src/Toasts/Elements/Element_ToastAction.cs
index eaab27b19..d9b387520 100644
--- a/components/Notifications/src/Toasts/Elements/Element_ToastAction.cs
+++ b/components/Notifications/src/Toasts/Elements/Element_ToastAction.cs
@@ -4,103 +4,102 @@
using System.Collections.Generic;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+internal sealed class Element_ToastAction : IElement_ToastActionsChild, IElement_ToastActivatable, IHaveXmlName, IHaveXmlNamedProperties
{
- internal sealed class Element_ToastAction : IElement_ToastActionsChild, IElement_ToastActivatable, IHaveXmlName, IHaveXmlNamedProperties
- {
- internal const Element_ToastActivationType DEFAULT_ACTIVATION_TYPE = Element_ToastActivationType.Foreground;
- internal const ToastAfterActivationBehavior DEFAULT_AFTER_ACTIVATION_BEHAVIOR = ToastAfterActivationBehavior.Default;
- internal const Element_ToastActionPlacement DEFAULT_PLACEMENT = Element_ToastActionPlacement.Inline;
+ internal const Element_ToastActivationType DEFAULT_ACTIVATION_TYPE = Element_ToastActivationType.Foreground;
+ internal const ToastAfterActivationBehavior DEFAULT_AFTER_ACTIVATION_BEHAVIOR = ToastAfterActivationBehavior.Default;
+ internal const Element_ToastActionPlacement DEFAULT_PLACEMENT = Element_ToastActionPlacement.Inline;
- ///
- /// Gets or sets the text to be displayed on the button.
- ///
- public string Content { get; set; }
+ ///
+ /// Gets or sets the text to be displayed on the button.
+ ///
+ public string Content { get; set; }
- ///
- /// Gets or sets the arguments attribute describing the app-defined data that the app can later retrieve once it is activated from user taking this action.
- ///
- public string Arguments { get; set; }
+ ///
+ /// Gets or sets the arguments attribute describing the app-defined data that the app can later retrieve once it is activated from user taking this action.
+ ///
+ public string Arguments { get; set; }
- public Element_ToastActivationType ActivationType { get; set; } = DEFAULT_ACTIVATION_TYPE;
+ public Element_ToastActivationType ActivationType { get; set; } = DEFAULT_ACTIVATION_TYPE;
- public string ProtocolActivationTargetApplicationPfn { get; set; }
+ public string ProtocolActivationTargetApplicationPfn { get; set; }
- public ToastAfterActivationBehavior AfterActivationBehavior { get; set; } = DEFAULT_AFTER_ACTIVATION_BEHAVIOR;
+ public ToastAfterActivationBehavior AfterActivationBehavior { get; set; } = DEFAULT_AFTER_ACTIVATION_BEHAVIOR;
- ///
- /// Gets or sets optional value to provide an image icon for this action to display inside the button alone with the text content.
- ///
- public string ImageUri { get; set; }
+ ///
+ /// Gets or sets optional value to provide an image icon for this action to display inside the button alone with the text content.
+ ///
+ public string ImageUri { get; set; }
- ///
- /// Gets or sets value used for the quick reply scenario.
- ///
- public string InputId { get; set; }
+ ///
+ /// Gets or sets value used for the quick reply scenario.
+ ///
+ public string InputId { get; set; }
- public Element_ToastActionPlacement Placement { get; set; } = DEFAULT_PLACEMENT;
+ public Element_ToastActionPlacement Placement { get; set; } = DEFAULT_PLACEMENT;
- public string HintActionId { get; set; }
+ public string HintActionId { get; set; }
- ///
- string IHaveXmlName.Name => "action";
+ ///
+ string IHaveXmlName.Name => "action";
- ///
- IEnumerable> IHaveXmlNamedProperties.EnumerateNamedProperties()
- {
- yield return new("content", Content);
- yield return new("arguments", Arguments);
-
- if (ActivationType != DEFAULT_ACTIVATION_TYPE)
- {
- yield return new("activationType", ActivationType.ToPascalCaseString());
- }
+ ///
+ IEnumerable> IHaveXmlNamedProperties.EnumerateNamedProperties()
+ {
+ yield return new("content", Content);
+ yield return new("arguments", Arguments);
- yield return new("protocolActivationTargetApplicationPfn", ProtocolActivationTargetApplicationPfn);
+ if (ActivationType != DEFAULT_ACTIVATION_TYPE)
+ {
+ yield return new("activationType", ActivationType.ToPascalCaseString());
+ }
- if (AfterActivationBehavior != DEFAULT_AFTER_ACTIVATION_BEHAVIOR)
- {
- yield return new("afterActivationBehavior", AfterActivationBehavior.ToPascalCaseString());
- }
+ yield return new("protocolActivationTargetApplicationPfn", ProtocolActivationTargetApplicationPfn);
- yield return new("imageUri", ImageUri);
- yield return new("hint-inputId", InputId);
+ if (AfterActivationBehavior != DEFAULT_AFTER_ACTIVATION_BEHAVIOR)
+ {
+ yield return new("afterActivationBehavior", AfterActivationBehavior.ToPascalCaseString());
+ }
- if (Placement != DEFAULT_PLACEMENT)
- {
- yield return new("placement", Placement.ToPascalCaseString());
- }
+ yield return new("imageUri", ImageUri);
+ yield return new("hint-inputId", InputId);
- yield return new("hint-actionId", HintActionId);
+ if (Placement != DEFAULT_PLACEMENT)
+ {
+ yield return new("placement", Placement.ToPascalCaseString());
}
- }
- internal enum Element_ToastActionPlacement
- {
- Inline,
- ContextMenu
+ yield return new("hint-actionId", HintActionId);
}
+}
- internal enum Element_ToastActivationType
- {
- ///
- /// Default value. Your foreground app is launched.
- ///
- Foreground,
-
- ///
- /// Your corresponding background task (assuming you set everything up) is triggered, and you can execute code in the background (like sending the user's quick reply message) without interrupting the user.
- ///
- Background,
-
- ///
- /// Launch a different app using protocol activation.
- ///
- Protocol,
-
- ///
- /// System handles the activation.
- ///
- System
- }
+internal enum Element_ToastActionPlacement
+{
+ Inline,
+ ContextMenu
+}
+
+internal enum Element_ToastActivationType
+{
+ ///
+ /// Default value. Your foreground app is launched.
+ ///
+ Foreground,
+
+ ///
+ /// Your corresponding background task (assuming you set everything up) is triggered, and you can execute code in the background (like sending the user's quick reply message) without interrupting the user.
+ ///
+ Background,
+
+ ///
+ /// Launch a different app using protocol activation.
+ ///
+ Protocol,
+
+ ///
+ /// System handles the activation.
+ ///
+ System
}
\ No newline at end of file
diff --git a/components/Notifications/src/Toasts/Elements/Element_ToastActions.cs b/components/Notifications/src/Toasts/Elements/Element_ToastActions.cs
index c5ff90347..be2bff657 100644
--- a/components/Notifications/src/Toasts/Elements/Element_ToastActions.cs
+++ b/components/Notifications/src/Toasts/Elements/Element_ToastActions.cs
@@ -4,39 +4,38 @@
using System.Collections.Generic;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+internal sealed class Element_ToastActions : IHaveXmlName, IHaveXmlNamedProperties, IHaveXmlChildren
{
- internal sealed class Element_ToastActions : IHaveXmlName, IHaveXmlNamedProperties, IHaveXmlChildren
- {
- internal const ToastSystemCommand DEFAULT_SYSTEM_COMMAND = ToastSystemCommand.None;
+ internal const ToastSystemCommand DEFAULT_SYSTEM_COMMAND = ToastSystemCommand.None;
- public ToastSystemCommand SystemCommands { get; set; } = ToastSystemCommand.None;
+ public ToastSystemCommand SystemCommands { get; set; } = ToastSystemCommand.None;
- public IList Children { get; private set; } = new List();
+ public IList Children { get; private set; } = new List();
- ///
- string IHaveXmlName.Name => "actions";
+ ///
+ string IHaveXmlName.Name => "actions";
- ///
- IEnumerable IHaveXmlChildren.Children => Children;
+ ///
+ IEnumerable IHaveXmlChildren.Children => Children;
- ///
- IEnumerable> IHaveXmlNamedProperties.EnumerateNamedProperties()
+ ///
+ IEnumerable> IHaveXmlNamedProperties.EnumerateNamedProperties()
+ {
+ if (SystemCommands != DEFAULT_SYSTEM_COMMAND)
{
- if (SystemCommands != DEFAULT_SYSTEM_COMMAND)
- {
- yield return new("hint-systemCommands", SystemCommands);
- }
+ yield return new("hint-systemCommands", SystemCommands);
}
}
+}
- internal interface IElement_ToastActionsChild
- {
- }
+internal interface IElement_ToastActionsChild
+{
+}
- internal enum ToastSystemCommand
- {
- None,
- SnoozeAndDismiss
- }
+internal enum ToastSystemCommand
+{
+ None,
+ SnoozeAndDismiss
}
\ No newline at end of file
diff --git a/components/Notifications/src/Toasts/Elements/Element_ToastAudio.cs b/components/Notifications/src/Toasts/Elements/Element_ToastAudio.cs
index 2a674556a..34b8949d9 100644
--- a/components/Notifications/src/Toasts/Elements/Element_ToastAudio.cs
+++ b/components/Notifications/src/Toasts/Elements/Element_ToastAudio.cs
@@ -5,42 +5,41 @@
using System;
using System.Collections.Generic;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+internal sealed class Element_ToastAudio : IHaveXmlName, IHaveXmlNamedProperties
{
- internal sealed class Element_ToastAudio : IHaveXmlName, IHaveXmlNamedProperties
- {
- internal const bool DEFAULT_LOOP = false;
- internal const bool DEFAULT_SILENT = false;
+ internal const bool DEFAULT_LOOP = false;
+ internal const bool DEFAULT_SILENT = false;
- ///
- /// Gets or sets the media file to play in place of the default sound. This can either be a ms-winsoundevent value, or a custom ms-appx:/// or ms-appdata:/// file, or null for the default sound.
- ///
- public Uri Src { get; set; }
+ ///
+ /// Gets or sets the media file to play in place of the default sound. This can either be a ms-winsoundevent value, or a custom ms-appx:/// or ms-appdata:/// file, or null for the default sound.
+ ///
+ public Uri Src { get; set; }
- public bool Loop { get; set; } = DEFAULT_LOOP;
+ public bool Loop { get; set; } = DEFAULT_LOOP;
- ///
- /// Gets or sets a value indicating whether the sound is muted; false to allow the Toast notification sound to play.
- ///
- public bool Silent { get; set; } = DEFAULT_SILENT;
+ ///
+ /// Gets or sets a value indicating whether the sound is muted; false to allow the Toast notification sound to play.
+ ///
+ public bool Silent { get; set; } = DEFAULT_SILENT;
- ///
- string IHaveXmlName.Name => "audio";
+ ///
+ string IHaveXmlName.Name => "audio";
- ///
- IEnumerable> IHaveXmlNamedProperties.EnumerateNamedProperties()
- {
- yield return new("src", Src);
+ ///
+ IEnumerable> IHaveXmlNamedProperties.EnumerateNamedProperties()
+ {
+ yield return new("src", Src);
- if (Loop != DEFAULT_LOOP)
- {
- yield return new("loop", Loop);
- }
+ if (Loop != DEFAULT_LOOP)
+ {
+ yield return new("loop", Loop);
+ }
- if (Silent != DEFAULT_SILENT)
- {
- yield return new("silent", Silent);
- }
+ if (Silent != DEFAULT_SILENT)
+ {
+ yield return new("silent", Silent);
}
}
}
\ No newline at end of file
diff --git a/components/Notifications/src/Toasts/Elements/Element_ToastBinding.cs b/components/Notifications/src/Toasts/Elements/Element_ToastBinding.cs
index c5a680a74..f2fda2f58 100644
--- a/components/Notifications/src/Toasts/Elements/Element_ToastBinding.cs
+++ b/components/Notifications/src/Toasts/Elements/Element_ToastBinding.cs
@@ -5,73 +5,72 @@
using System;
using System.Collections.Generic;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+internal sealed class Element_ToastBinding : IHaveXmlName, IHaveXmlNamedProperties, IHaveXmlChildren
{
- internal sealed class Element_ToastBinding : IHaveXmlName, IHaveXmlNamedProperties, IHaveXmlChildren
+ public Element_ToastBinding(ToastTemplateType template)
{
- public Element_ToastBinding(ToastTemplateType template)
- {
- Template = template;
- }
+ Template = template;
+ }
- public ToastTemplateType Template { get; private set; }
+ public ToastTemplateType Template { get; private set; }
- ///
- /// Gets or sets a value whether Windows should 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&ms-contrast=standard&ms-lang=en-us"
- ///
- public bool? AddImageQuery { get; set; }
+ ///
+ /// Gets or sets a value whether Windows should 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&ms-contrast=standard&ms-lang=en-us"
+ ///
+ public bool? AddImageQuery { get; set; }
- ///
- /// Gets or sets a default base URI that is combined with relative URIs in image source attributes.
- ///
- public Uri BaseUri { get; set; }
+ ///
+ /// Gets or sets a default base URI that is combined with relative URIs in image source attributes.
+ ///
+ public Uri BaseUri { get; set; }
- ///
- /// Gets or sets 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 overridden 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.
- ///
- public string Language { get; set; }
+ ///
+ /// Gets or sets 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 overridden 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.
+ ///
+ public string Language { get; set; }
- public string ExperienceType { get; set; }
+ public string ExperienceType { get; set; }
- public IList Children { get; private set; } = new List();
+ public IList Children { get; private set; } = new List();
- ///
- string IHaveXmlName.Name => "binding";
+ ///
+ string IHaveXmlName.Name => "binding";
- ///
- IEnumerable IHaveXmlChildren.Children => Children;
+ ///
+ IEnumerable IHaveXmlChildren.Children => Children;
- ///
- IEnumerable> IHaveXmlNamedProperties.EnumerateNamedProperties()
- {
- yield return new("template", Template);
- yield return new("addImageQuery", AddImageQuery);
- yield return new("baseUri", BaseUri);
- yield return new("lang", Language);
- yield return new("experienceType", ExperienceType);
- }
- }
-
- internal interface IElement_ToastBindingChild
+ ///
+ IEnumerable> IHaveXmlNamedProperties.EnumerateNamedProperties()
{
+ yield return new("template", Template);
+ yield return new("addImageQuery", AddImageQuery);
+ yield return new("baseUri", BaseUri);
+ yield return new("lang", Language);
+ yield return new("experienceType", ExperienceType);
}
+}
- internal enum ToastTemplateType
- {
- ToastGeneric,
- ToastImageAndText01,
- ToastImageAndText02,
- ToastImageAndText03,
- ToastImageAndText04,
- ToastText01,
- ToastText02,
- ToastText03,
- ToastText04
- }
+internal interface IElement_ToastBindingChild
+{
+}
+
+internal enum ToastTemplateType
+{
+ ToastGeneric,
+ ToastImageAndText01,
+ ToastImageAndText02,
+ ToastImageAndText03,
+ ToastImageAndText04,
+ ToastText01,
+ ToastText02,
+ ToastText03,
+ ToastText04
}
\ No newline at end of file
diff --git a/components/Notifications/src/Toasts/Elements/Element_ToastHeader.cs b/components/Notifications/src/Toasts/Elements/Element_ToastHeader.cs
index 7b1f5aec7..673848f69 100644
--- a/components/Notifications/src/Toasts/Elements/Element_ToastHeader.cs
+++ b/components/Notifications/src/Toasts/Elements/Element_ToastHeader.cs
@@ -5,57 +5,56 @@
using System;
using System.Collections.Generic;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+internal sealed class Element_ToastHeader : IElement_ToastActivatable, IHaveXmlName, IHaveXmlNamedProperties
{
- internal sealed class Element_ToastHeader : IElement_ToastActivatable, IHaveXmlName, IHaveXmlNamedProperties
- {
- public string Id { get; set; }
+ public string Id { get; set; }
- public string Title { get; set; }
+ public string Title { get; set; }
- public string Arguments { get; set; }
+ public string Arguments { get; set; }
- public Element_ToastActivationType ActivationType { get; set; } = Element_ToastActivationType.Foreground;
+ public Element_ToastActivationType ActivationType { get; set; } = Element_ToastActivationType.Foreground;
- public string ProtocolActivationTargetApplicationPfn { get; set; }
+ public string ProtocolActivationTargetApplicationPfn { get; set; }
- public ToastAfterActivationBehavior AfterActivationBehavior
+ public ToastAfterActivationBehavior AfterActivationBehavior
+ {
+ get
{
- get
- {
- return ToastAfterActivationBehavior.Default;
- }
+ return ToastAfterActivationBehavior.Default;
+ }
- set
+ set
+ {
+ if (value != ToastAfterActivationBehavior.Default)
{
- if (value != ToastAfterActivationBehavior.Default)
- {
- throw new InvalidOperationException("AfterActivationBehavior on ToastHeader only supports the Default value.");
- }
+ throw new InvalidOperationException("AfterActivationBehavior on ToastHeader only supports the Default value.");
}
}
+ }
- ///
- string IHaveXmlName.Name => "header";
+ ///
+ string IHaveXmlName.Name => "header";
- ///
- IEnumerable> IHaveXmlNamedProperties.EnumerateNamedProperties()
- {
- yield return new("id", Id);
- yield return new("title", Title);
- yield return new("arguments", Arguments);
+ ///
+ IEnumerable> IHaveXmlNamedProperties.EnumerateNamedProperties()
+ {
+ yield return new("id", Id);
+ yield return new("title", Title);
+ yield return new("arguments", Arguments);
- if (ActivationType != Element_ToastActivationType.Foreground)
- {
- yield return new("activationType", ActivationType.ToPascalCaseString());
- }
+ if (ActivationType != Element_ToastActivationType.Foreground)
+ {
+ yield return new("activationType", ActivationType.ToPascalCaseString());
+ }
- yield return new("protocolActivationTargetApplicationPfn", ProtocolActivationTargetApplicationPfn);
+ yield return new("protocolActivationTargetApplicationPfn", ProtocolActivationTargetApplicationPfn);
- if (AfterActivationBehavior != ToastAfterActivationBehavior.Default)
- {
- yield return new("afterActivationBehavior", AfterActivationBehavior.ToPascalCaseString());
- }
+ if (AfterActivationBehavior != ToastAfterActivationBehavior.Default)
+ {
+ yield return new("afterActivationBehavior", AfterActivationBehavior.ToPascalCaseString());
}
}
}
\ No newline at end of file
diff --git a/components/Notifications/src/Toasts/Elements/Element_ToastImage.cs b/components/Notifications/src/Toasts/Elements/Element_ToastImage.cs
index e3473a278..4043a654f 100644
--- a/components/Notifications/src/Toasts/Elements/Element_ToastImage.cs
+++ b/components/Notifications/src/Toasts/Elements/Element_ToastImage.cs
@@ -4,70 +4,69 @@
using System.Collections.Generic;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+internal sealed class Element_ToastImage : IElement_ToastBindingChild, IHaveXmlName, IHaveXmlNamedProperties
{
- internal sealed class Element_ToastImage : IElement_ToastBindingChild, IHaveXmlName, IHaveXmlNamedProperties
- {
- internal const ToastImagePlacement DEFAULT_PLACEMENT = ToastImagePlacement.Inline;
- internal const bool DEFAULT_ADD_IMAGE_QUERY = false;
- internal const ToastImageCrop DEFAULT_CROP = ToastImageCrop.None;
+ internal const ToastImagePlacement DEFAULT_PLACEMENT = ToastImagePlacement.Inline;
+ internal const bool DEFAULT_ADD_IMAGE_QUERY = false;
+ internal const ToastImageCrop DEFAULT_CROP = ToastImageCrop.None;
+
+ public string Src { get; set; }
+
+ public string Alt { get; set; }
+
+ public bool AddImageQuery { get; set; } = DEFAULT_ADD_IMAGE_QUERY;
- public string Src { get; set; }
+ public ToastImagePlacement Placement { get; set; } = DEFAULT_PLACEMENT;
- public string Alt { get; set; }
+ public ToastImageCrop Crop { get; set; } = DEFAULT_CROP;
- public bool AddImageQuery { get; set; } = DEFAULT_ADD_IMAGE_QUERY;
+ ///
+ string IHaveXmlName.Name => "image";
- public ToastImagePlacement Placement { get; set; } = DEFAULT_PLACEMENT;
+ ///
+ IEnumerable> IHaveXmlNamedProperties.EnumerateNamedProperties()
+ {
+ yield return new("src", Src);
+ yield return new("alt", Alt);
- public ToastImageCrop Crop { get; set; } = DEFAULT_CROP;
+ if (AddImageQuery != DEFAULT_ADD_IMAGE_QUERY)
+ {
+ yield return new("addImageQuery", AddImageQuery);
+ }
- ///
- string IHaveXmlName.Name => "image";
+ if (Placement != DEFAULT_PLACEMENT)
+ {
+ yield return new("placement", Placement.ToPascalCaseString());
+ }
- ///
- IEnumerable> IHaveXmlNamedProperties.EnumerateNamedProperties()
+ if (Crop != DEFAULT_CROP)
{
- yield return new("src", Src);
- yield return new("alt", Alt);
-
- if (AddImageQuery != DEFAULT_ADD_IMAGE_QUERY)
- {
- yield return new("addImageQuery", AddImageQuery);
- }
-
- if (Placement != DEFAULT_PLACEMENT)
- {
- yield return new("placement", Placement.ToPascalCaseString());
- }
-
- if (Crop != DEFAULT_CROP)
- {
- yield return new("crop", Crop.ToPascalCaseString());
- }
+ yield return new("crop", Crop.ToPascalCaseString());
}
}
+}
+///
+/// Specify the desired cropping of the image.
+///
+public enum ToastImageCrop
+{
///
- /// Specify the desired cropping of the image.
+ /// Default value. Image is not cropped.
///
- public enum ToastImageCrop
- {
- ///
- /// Default value. Image is not cropped.
- ///
- None,
-
- ///
- /// Image is cropped to a circle shape.
- ///
- Circle
- }
+ None,
- internal enum ToastImagePlacement
- {
- Inline,
- AppLogoOverride,
- Hero
- }
+ ///
+ /// Image is cropped to a circle shape.
+ ///
+ Circle
+}
+
+internal enum ToastImagePlacement
+{
+ Inline,
+ AppLogoOverride,
+ Hero
}
\ No newline at end of file
diff --git a/components/Notifications/src/Toasts/Elements/Element_ToastInput.cs b/components/Notifications/src/Toasts/Elements/Element_ToastInput.cs
index 0e8cd882b..927098191 100644
--- a/components/Notifications/src/Toasts/Elements/Element_ToastInput.cs
+++ b/components/Notifications/src/Toasts/Elements/Element_ToastInput.cs
@@ -4,58 +4,57 @@
using System.Collections.Generic;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+internal sealed class Element_ToastInput : IElement_ToastActionsChild, IHaveXmlName, IHaveXmlNamedProperties, IHaveXmlChildren
{
- internal sealed class Element_ToastInput : IElement_ToastActionsChild, IHaveXmlName, IHaveXmlNamedProperties, IHaveXmlChildren
- {
- ///
- /// Gets or sets the required attributes for developers to retrieve user inputs once the app is activated (in the foreground or background).
- ///
- public string Id { get; set; }
-
- public ToastInputType Type { get; set; }
-
- ///
- /// Gets or sets the optional title attribute and is for developers to specify a title for the input for shells to render when there is affordance.
- ///
- public string Title { get; set; }
-
- ///
- /// Gets or sets the optional placeholderContent attribute and is the grey-out hint text for text input type. This attribute is ignored when the input type is not �text�.
- ///
- public string PlaceholderContent { get; set; }
-
- ///
- /// Gets or sets the optional defaultInput attribute and it allows developer to provide a default input value.
- ///
- public string DefaultInput { get; set; }
-
- public IList Children { get; private set; } = new List();
-
- ///
- string IHaveXmlName.Name => "input";
-
- ///
- IEnumerable IHaveXmlChildren.Children => Children;
-
- ///
- IEnumerable> IHaveXmlNamedProperties.EnumerateNamedProperties()
- {
- yield return new("id", Id);
- yield return new("type", Type.ToPascalCaseString());
- yield return new("title", Title);
- yield return new("placeHolderContent", PlaceholderContent);
- yield return new("defaultInput", DefaultInput);
- }
- }
+ ///
+ /// Gets or sets the required attributes for developers to retrieve user inputs once the app is activated (in the foreground or background).
+ ///
+ public string Id { get; set; }
- internal interface IElement_ToastInputChild
- {
- }
+ public ToastInputType Type { get; set; }
+
+ ///
+ /// Gets or sets the optional title attribute and is for developers to specify a title for the input for shells to render when there is affordance.
+ ///
+ public string Title { get; set; }
+
+ ///
+ /// Gets or sets the optional placeholderContent attribute and is the grey-out hint text for text input type. This attribute is ignored when the input type is not �text�.
+ ///
+ public string PlaceholderContent { get; set; }
+
+ ///
+ /// Gets or sets the optional defaultInput attribute and it allows developer to provide a default input value.
+ ///
+ public string DefaultInput { get; set; }
- internal enum ToastInputType
+ public IList Children { get; private set; } = new List();
+
+ ///
+ string IHaveXmlName.Name => "input";
+
+ ///
+ IEnumerable IHaveXmlChildren.Children => Children;
+
+ ///
+ IEnumerable> IHaveXmlNamedProperties.EnumerateNamedProperties()
{
- Text,
- Selection
+ yield return new("id", Id);
+ yield return new("type", Type.ToPascalCaseString());
+ yield return new("title", Title);
+ yield return new("placeHolderContent", PlaceholderContent);
+ yield return new("defaultInput", DefaultInput);
}
+}
+
+internal interface IElement_ToastInputChild
+{
+}
+
+internal enum ToastInputType
+{
+ Text,
+ Selection
}
\ No newline at end of file
diff --git a/components/Notifications/src/Toasts/Elements/Element_ToastSelection.cs b/components/Notifications/src/Toasts/Elements/Element_ToastSelection.cs
index 4092ad554..b42ff9777 100644
--- a/components/Notifications/src/Toasts/Elements/Element_ToastSelection.cs
+++ b/components/Notifications/src/Toasts/Elements/Element_ToastSelection.cs
@@ -4,28 +4,27 @@
using System.Collections.Generic;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+internal sealed class Element_ToastSelection : IElement_ToastInputChild, IHaveXmlName, IHaveXmlNamedProperties
{
- internal sealed class Element_ToastSelection : IElement_ToastInputChild, IHaveXmlName, IHaveXmlNamedProperties
- {
- ///
- /// Gets or sets the id attribute for apps to retrieve back the user selected input after the app is activated. Required
- ///
- public string Id { get; set; }
+ ///
+ /// Gets or sets the id attribute for apps to retrieve back the user selected input after the app is activated. Required
+ ///
+ public string Id { get; set; }
- ///
- /// Gets or sets the text to display for this selection element.
- ///
- public string Content { get; set; }
+ ///
+ /// Gets or sets the text to display for this selection element.
+ ///
+ public string Content { get; set; }
- ///
- string IHaveXmlName.Name => "selection";
+ ///
+ string IHaveXmlName.Name => "selection";
- ///
- IEnumerable> IHaveXmlNamedProperties.EnumerateNamedProperties()
- {
- yield return new("id", Id);
- yield return new("content", Content);
- }
+ ///
+ IEnumerable> IHaveXmlNamedProperties.EnumerateNamedProperties()
+ {
+ yield return new("id", Id);
+ yield return new("content", Content);
}
}
\ No newline at end of file
diff --git a/components/Notifications/src/Toasts/Elements/Element_ToastText.cs b/components/Notifications/src/Toasts/Elements/Element_ToastText.cs
index f9b9947aa..a30b48e1e 100644
--- a/components/Notifications/src/Toasts/Elements/Element_ToastText.cs
+++ b/components/Notifications/src/Toasts/Elements/Element_ToastText.cs
@@ -4,36 +4,35 @@
using System.Collections.Generic;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+internal sealed class Element_ToastText : IElement_ToastBindingChild, IHaveXmlName, IHaveXmlNamedProperties, IHaveXmlText
{
- internal sealed class Element_ToastText : IElement_ToastBindingChild, IHaveXmlName, IHaveXmlNamedProperties, IHaveXmlText
- {
- internal const ToastTextPlacement DEFAULT_PLACEMENT = ToastTextPlacement.Inline;
+ internal const ToastTextPlacement DEFAULT_PLACEMENT = ToastTextPlacement.Inline;
- public string Text { get; set; }
+ public string Text { get; set; }
- public string Lang { get; set; }
+ public string Lang { get; set; }
- public ToastTextPlacement Placement { get; set; } = DEFAULT_PLACEMENT;
+ public ToastTextPlacement Placement { get; set; } = DEFAULT_PLACEMENT;
- ///
- string IHaveXmlName.Name => "text";
+ ///
+ string IHaveXmlName.Name => "text";
- ///
- IEnumerable> IHaveXmlNamedProperties.EnumerateNamedProperties()
- {
- yield return new("lang", Lang);
+ ///
+ IEnumerable> IHaveXmlNamedProperties.EnumerateNamedProperties()
+ {
+ yield return new("lang", Lang);
- if (Placement != DEFAULT_PLACEMENT)
- {
- yield return new("placement", Placement.ToPascalCaseString());
- }
+ if (Placement != DEFAULT_PLACEMENT)
+ {
+ yield return new("placement", Placement.ToPascalCaseString());
}
}
+}
- internal enum ToastTextPlacement
- {
- Inline,
- Attribution
- }
+internal enum ToastTextPlacement
+{
+ Inline,
+ Attribution
}
\ No newline at end of file
diff --git a/components/Notifications/src/Toasts/Elements/Element_ToastVisual.cs b/components/Notifications/src/Toasts/Elements/Element_ToastVisual.cs
index 0baf45b1a..a199e9fb4 100644
--- a/components/Notifications/src/Toasts/Elements/Element_ToastVisual.cs
+++ b/components/Notifications/src/Toasts/Elements/Element_ToastVisual.cs
@@ -5,35 +5,34 @@
using System;
using System.Collections.Generic;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+internal sealed class Element_ToastVisual : IHaveXmlName, IHaveXmlNamedProperties, IHaveXmlChildren
{
- internal sealed class Element_ToastVisual : IHaveXmlName, IHaveXmlNamedProperties, IHaveXmlChildren
- {
- internal const bool DEFAULT_ADD_IMAGE_QUERY = false;
+ internal const bool DEFAULT_ADD_IMAGE_QUERY = false;
- public bool? AddImageQuery { get; set; }
+ public bool? AddImageQuery { get; set; }
- public Uri BaseUri { get; set; }
+ public Uri BaseUri { get; set; }
- public string Language { get; set; }
+ public string Language { get; set; }
- public int? Version { get; set; }
+ public int? Version { get; set; }
- public IList Bindings { get; private set; } = new List();
+ public IList Bindings { get; private set; } = new List();
- ///
- string IHaveXmlName.Name => "visual";
+ ///
+ string IHaveXmlName.Name => "visual";
- ///
- IEnumerable IHaveXmlChildren.Children => Bindings;
+ ///
+ IEnumerable IHaveXmlChildren.Children => Bindings;
- ///
- IEnumerable> IHaveXmlNamedProperties.EnumerateNamedProperties()
- {
- yield return new("addImageQuery", AddImageQuery);
- yield return new("baseUri", BaseUri);
- yield return new("lang", Language);
- yield return new("version", Version);
- }
+ ///
+ IEnumerable> IHaveXmlNamedProperties.EnumerateNamedProperties()
+ {
+ yield return new("addImageQuery", AddImageQuery);
+ yield return new("baseUri", BaseUri);
+ yield return new("lang", Language);
+ yield return new("version", Version);
}
}
\ No newline at end of file
diff --git a/components/Notifications/src/Toasts/Elements/IElement_ToastActivatable.cs b/components/Notifications/src/Toasts/Elements/IElement_ToastActivatable.cs
index bc4a7d293..3a5ed0de6 100644
--- a/components/Notifications/src/Toasts/Elements/IElement_ToastActivatable.cs
+++ b/components/Notifications/src/Toasts/Elements/IElement_ToastActivatable.cs
@@ -2,14 +2,13 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+internal interface IElement_ToastActivatable
{
- internal interface IElement_ToastActivatable
- {
- Element_ToastActivationType ActivationType { get; set; }
+ Element_ToastActivationType ActivationType { get; set; }
- string ProtocolActivationTargetApplicationPfn { get; set; }
+ string ProtocolActivationTargetApplicationPfn { get; set; }
- ToastAfterActivationBehavior AfterActivationBehavior { get; set; }
- }
+ ToastAfterActivationBehavior AfterActivationBehavior { get; set; }
}
\ No newline at end of file
diff --git a/components/Notifications/src/Toasts/IToastActions.cs b/components/Notifications/src/Toasts/IToastActions.cs
index 4b7627307..a4520592d 100644
--- a/components/Notifications/src/Toasts/IToastActions.cs
+++ b/components/Notifications/src/Toasts/IToastActions.cs
@@ -4,16 +4,15 @@
using System.Collections.Generic;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// Actions to display on a Toast notification. One of or .
+///
+public interface IToastActions
{
///
- /// Actions to display on a Toast notification. One of or .
+ /// Gets custom context menu items, providing additional actions when the user right clicks the Toast notification. New in Anniversary Update
///
- public interface IToastActions
- {
- ///
- /// Gets custom context menu items, providing additional actions when the user right clicks the Toast notification. New in Anniversary Update
- ///
- IList ContextMenuItems { get; }
- }
-}
\ No newline at end of file
+ IList ContextMenuItems { get; }
+}
diff --git a/components/Notifications/src/Toasts/IToastActivateableBuilder.cs b/components/Notifications/src/Toasts/IToastActivateableBuilder.cs
index 319575498..68d162498 100644
--- a/components/Notifications/src/Toasts/IToastActivateableBuilder.cs
+++ b/components/Notifications/src/Toasts/IToastActivateableBuilder.cs
@@ -4,88 +4,87 @@
using System;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// Interfaces for classes that can have activation info added to them.
+///
+/// The type of the host object.
+internal interface IToastActivateableBuilder
{
///
- /// Interfaces for classes that can have activation info added to them.
+ /// Adds a key (without value) to the activation arguments that will be returned when the content is clicked.
///
- /// The type of the host object.
- internal interface IToastActivateableBuilder
- {
- ///
- /// Adds a key (without value) to the activation arguments that will be returned when the content is clicked.
- ///
- /// The key.
- /// The current instance of the object.
- T AddArgument(string key);
+ /// The key.
+ /// The current instance of the object.
+ T AddArgument(string key);
- ///
- /// Adds a key/value to the activation arguments that will be returned when the content is clicked.
- ///
- /// The key for this value.
- /// The value itself.
- /// The current instance of the object.
- T AddArgument(string key, string value);
+ ///
+ /// Adds a key/value to the activation arguments that will be returned when the content is clicked.
+ ///
+ /// The key for this value.
+ /// The value itself.
+ /// The current instance of the object.
+ T AddArgument(string key, string value);
- ///
- /// Adds a key/value to the activation arguments that will be returned when the content is clicked.
- ///
- /// The key for this value.
- /// The value itself.
- /// The current instance of the object.
- T AddArgument(string key, int value);
+ ///
+ /// Adds a key/value to the activation arguments that will be returned when the content is clicked.
+ ///
+ /// The key for this value.
+ /// The value itself.
+ /// The current instance of the object.
+ T AddArgument(string key, int value);
- ///
- /// Adds a key/value to the activation arguments that will be returned when the content is clicked.
- ///
- /// The key for this value.
- /// The value itself.
- /// The current instance of the object.
- T AddArgument(string key, double value);
+ ///
+ /// Adds a key/value to the activation arguments that will be returned when the content is clicked.
+ ///
+ /// The key for this value.
+ /// The value itself.
+ /// The current instance of the object.
+ T AddArgument(string key, double value);
- ///
- /// Adds a key/value to the activation arguments that will be returned when the content is clicked.
- ///
- /// The key for this value.
- /// The value itself.
- /// The current instance of the object.
- T AddArgument(string key, float value);
+ ///
+ /// Adds a key/value to the activation arguments that will be returned when the content is clicked.
+ ///
+ /// The key for this value.
+ /// The value itself.
+ /// The current instance of the object.
+ T AddArgument(string key, float value);
- ///
- /// Adds a key/value to the activation arguments that will be returned when the content is clicked.
- ///
- /// The key for this value.
- /// The value itself.
- /// The current instance of the object.
- T AddArgument(string key, bool value);
+ ///
+ /// Adds a key/value to the activation arguments that will be returned when the content is clicked.
+ ///
+ /// The key for this value.
+ /// The value itself.
+ /// The current instance of the object.
+ T AddArgument(string key, bool value);
- ///
- /// Adds a key/value to the activation arguments that will be returned when the content is clicked.
- ///
- /// The key for this value.
- /// The value itself. Note that the enums are stored using their numeric value, so be aware that changing your enum number values might break existing activation of toasts currently in Action Center.
- /// The current instance of the object.
- T AddArgument(string key, Enum value);
+ ///
+ /// Adds a key/value to the activation arguments that will be returned when the content is clicked.
+ ///
+ /// The key for this value.
+ /// The value itself. Note that the enums are stored using their numeric value, so be aware that changing your enum number values might break existing activation of toasts currently in Action Center.
+ /// The current instance of the object.
+ T AddArgument(string key, Enum value);
- ///
- /// Configures the content to use background activation when it is clicked.
- ///
- /// The current instance of the object.
- T SetBackgroundActivation();
+ ///
+ /// Configures the content to use background activation when it is clicked.
+ ///
+ /// The current instance of the object.
+ T SetBackgroundActivation();
- ///
- /// Configures the content to use protocol activation when it is clicked.
- ///
- /// The protocol to launch.
- /// The current instance of the object.
- T SetProtocolActivation(Uri protocol);
+ ///
+ /// Configures the content to use protocol activation when it is clicked.
+ ///
+ /// The protocol to launch.
+ /// The current instance of the object.
+ T SetProtocolActivation(Uri protocol);
- ///
- /// Configures the content to use protocol activation when it is clicked.
- ///
- /// The protocol to launch.
- /// New in Creators Update: The target PFN, so that regardless of whether multiple apps are registered to handle the same protocol uri, your desired app will always be launched.
- /// The current instance of the object.
- T SetProtocolActivation(Uri protocol, string targetApplicationPfn);
- }
+ ///
+ /// Configures the content to use protocol activation when it is clicked.
+ ///
+ /// The protocol to launch.
+ /// New in Creators Update: The target PFN, so that regardless of whether multiple apps are registered to handle the same protocol uri, your desired app will always be launched.
+ /// The current instance of the object.
+ T SetProtocolActivation(Uri protocol, string targetApplicationPfn);
}
diff --git a/components/Notifications/src/Toasts/IToastBindingGenericChild.cs b/components/Notifications/src/Toasts/IToastBindingGenericChild.cs
index 444cefbe6..43c783158 100644
--- a/components/Notifications/src/Toasts/IToastBindingGenericChild.cs
+++ b/components/Notifications/src/Toasts/IToastBindingGenericChild.cs
@@ -2,13 +2,12 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// Elements that can be direct children of , including ( , , and ).
+///
+public interface IToastBindingGenericChild
{
- ///
- /// Elements that can be direct children of , including ( , , and ).
- ///
- public interface IToastBindingGenericChild
- {
- // Blank interface simply for compile-enforcing the child types in the list.
- }
+ // Blank interface simply for compile-enforcing the child types in the list.
}
\ No newline at end of file
diff --git a/components/Notifications/src/Toasts/IToastButton.cs b/components/Notifications/src/Toasts/IToastButton.cs
index 0f52fee31..58159c250 100644
--- a/components/Notifications/src/Toasts/IToastButton.cs
+++ b/components/Notifications/src/Toasts/IToastButton.cs
@@ -2,23 +2,22 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// One of , , or .
+///
+public interface IToastButton
{
///
- /// One of , , or .
+ /// Gets or sets an optional image icon for the button to display (required for buttons adjacent to inputs like quick reply).
///
- public interface IToastButton
- {
- ///
- /// Gets or sets an optional image icon for the button to display (required for buttons adjacent to inputs like quick reply).
- ///
- string ImageUri { get; set; }
+ string ImageUri { get; set; }
- ///
- /// Gets or sets an identifier used in telemetry to identify your category of action. This should be something
- /// like "Delete", "Reply", or "Archive". In the upcoming toast telemetry dashboard in Dev Center, you will
- /// be able to view how frequently your actions are being clicked.
- ///
- string HintActionId { get; set; }
- }
+ ///
+ /// Gets or sets an identifier used in telemetry to identify your category of action. This should be something
+ /// like "Delete", "Reply", or "Archive". In the upcoming toast telemetry dashboard in Dev Center, you will
+ /// be able to view how frequently your actions are being clicked.
+ ///
+ string HintActionId { get; set; }
}
\ No newline at end of file
diff --git a/components/Notifications/src/Toasts/IToastInput.cs b/components/Notifications/src/Toasts/IToastInput.cs
index 7b13e568d..954f89d11 100644
--- a/components/Notifications/src/Toasts/IToastInput.cs
+++ b/components/Notifications/src/Toasts/IToastInput.cs
@@ -2,12 +2,11 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// An input element on a Toast notification. One of or .
+///
+public interface IToastInput
{
- ///
- /// An input element on a Toast notification. One of or .
- ///
- public interface IToastInput
- {
- }
}
\ No newline at end of file
diff --git a/components/Notifications/src/Toasts/ToastActionsCustom.cs b/components/Notifications/src/Toasts/ToastActionsCustom.cs
index a40f8d702..65ebbb1b5 100644
--- a/components/Notifications/src/Toasts/ToastActionsCustom.cs
+++ b/components/Notifications/src/Toasts/ToastActionsCustom.cs
@@ -5,90 +5,89 @@
using System;
using System.Collections.Generic;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// Create your own custom actions, using controls like , , and .
+///
+public sealed class ToastActionsCustom : IToastActions
{
///
- /// Create your own custom actions, using controls like , , and .
+ /// Gets inputs like and . Only up to 5 inputs can be added; after that, an exception is thrown.
+ ///
+ public IList Inputs { get; private set; } = new LimitedList(5);
+
+ ///
+ /// Gets buttons displayed after all the inputs (or adjacent to inputs if used as quick reply buttons). Only up to 5 buttons can be added (or fewer if you are also including context menu items). After that, an exception is thrown. You can add , , or
+ ///
+ public IList Buttons { get; private set; } = new LimitedList(5);
+
+ ///
+ /// Gets custom context menu items, providing additional actions when the user right clicks the Toast notification.
+ /// You can only have up to 5 buttons and context menu items *combined*. Thus, if you have one context menu item,
+ /// you can only have four buttons, etc. New in Anniversary Update:
///
- public sealed class ToastActionsCustom : IToastActions
+ public IList ContextMenuItems { get; private set; } = new List();
+
+ internal Element_ToastActions ConvertToElement()
{
- ///
- /// Gets inputs like and . Only up to 5 inputs can be added; after that, an exception is thrown.
- ///
- public IList Inputs { get; private set; } = new LimitedList(5);
-
- ///
- /// Gets buttons displayed after all the inputs (or adjacent to inputs if used as quick reply buttons). Only up to 5 buttons can be added (or fewer if you are also including context menu items). After that, an exception is thrown. You can add , , or
- ///
- public IList Buttons { get; private set; } = new LimitedList(5);
-
- ///
- /// Gets custom context menu items, providing additional actions when the user right clicks the Toast notification.
- /// You can only have up to 5 buttons and context menu items *combined*. Thus, if you have one context menu item,
- /// you can only have four buttons, etc. New in Anniversary Update:
- ///
- public IList ContextMenuItems { get; private set; } = new List();
-
- internal Element_ToastActions ConvertToElement()
+ if (Buttons.Count + ContextMenuItems.Count > 5)
{
- if (Buttons.Count + ContextMenuItems.Count > 5)
- {
- throw new InvalidOperationException("You have too many buttons/context menu items. You can only have up to 5 total.");
- }
+ throw new InvalidOperationException("You have too many buttons/context menu items. You can only have up to 5 total.");
+ }
- var el = new Element_ToastActions();
+ var el = new Element_ToastActions();
- foreach (var input in Inputs)
- {
- el.Children.Add(ConvertToInputElement(input));
- }
+ foreach (var input in Inputs)
+ {
+ el.Children.Add(ConvertToInputElement(input));
+ }
- foreach (var button in this.Buttons)
- {
- el.Children.Add(ConvertToActionElement(button));
- }
+ foreach (var button in this.Buttons)
+ {
+ el.Children.Add(ConvertToActionElement(button));
+ }
- foreach (var item in ContextMenuItems)
- {
- el.Children.Add(item.ConvertToElement());
- }
+ foreach (var item in ContextMenuItems)
+ {
+ el.Children.Add(item.ConvertToElement());
+ }
+
+ return el;
+ }
- return el;
+ private static Element_ToastAction ConvertToActionElement(IToastButton button)
+ {
+ if (button is ToastButton)
+ {
+ return (button as ToastButton).ConvertToElement();
}
- private static Element_ToastAction ConvertToActionElement(IToastButton button)
+ if (button is ToastButtonDismiss)
{
- if (button is ToastButton)
- {
- return (button as ToastButton).ConvertToElement();
- }
-
- if (button is ToastButtonDismiss)
- {
- return (button as ToastButtonDismiss).ConvertToElement();
- }
-
- if (button is ToastButtonSnooze)
- {
- return (button as ToastButtonSnooze).ConvertToElement();
- }
-
- throw new NotImplementedException("Unknown button child: " + button.GetType());
+ return (button as ToastButtonDismiss).ConvertToElement();
}
- private static Element_ToastInput ConvertToInputElement(IToastInput input)
+ if (button is ToastButtonSnooze)
{
- if (input is ToastTextBox)
- {
- return (input as ToastTextBox).ConvertToElement();
- }
+ return (button as ToastButtonSnooze).ConvertToElement();
+ }
- if (input is ToastSelectionBox)
- {
- return (input as ToastSelectionBox).ConvertToElement();
- }
+ throw new NotImplementedException("Unknown button child: " + button.GetType());
+ }
- throw new NotImplementedException("Unknown input child: " + input.GetType());
+ private static Element_ToastInput ConvertToInputElement(IToastInput input)
+ {
+ if (input is ToastTextBox)
+ {
+ return (input as ToastTextBox).ConvertToElement();
+ }
+
+ if (input is ToastSelectionBox)
+ {
+ return (input as ToastSelectionBox).ConvertToElement();
}
+
+ throw new NotImplementedException("Unknown input child: " + input.GetType());
}
}
\ No newline at end of file
diff --git a/components/Notifications/src/Toasts/ToastActionsSnoozeAndDismiss.cs b/components/Notifications/src/Toasts/ToastActionsSnoozeAndDismiss.cs
index 13d5a76ff..3e61b53a6 100644
--- a/components/Notifications/src/Toasts/ToastActionsSnoozeAndDismiss.cs
+++ b/components/Notifications/src/Toasts/ToastActionsSnoozeAndDismiss.cs
@@ -5,37 +5,36 @@
using System;
using System.Collections.Generic;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// Automatically constructs a selection box for snooze intervals, and snooze/dismiss buttons, all automatically localized, and snoozing logic is automatically handled by the system.
+///
+public sealed class ToastActionsSnoozeAndDismiss : IToastActions
{
///
- /// Automatically constructs a selection box for snooze intervals, and snooze/dismiss buttons, all automatically localized, and snoozing logic is automatically handled by the system.
+ /// Gets custom context menu items, providing additional actions when the user right clicks the Toast notification.
+ /// You can only have up to 5 items. New in Anniversary Update
///
- public sealed class ToastActionsSnoozeAndDismiss : IToastActions
- {
- ///
- /// Gets custom context menu items, providing additional actions when the user right clicks the Toast notification.
- /// You can only have up to 5 items. New in Anniversary Update
- ///
- public IList ContextMenuItems { get; private set; } = new List();
+ public IList ContextMenuItems { get; private set; } = new List();
- internal Element_ToastActions ConvertToElement()
+ internal Element_ToastActions ConvertToElement()
+ {
+ if (ContextMenuItems.Count > 5)
{
- if (ContextMenuItems.Count > 5)
- {
- throw new InvalidOperationException("You have too many context menu items. You can only have up to 5.");
- }
-
- var el = new Element_ToastActions()
- {
- SystemCommands = ToastSystemCommand.SnoozeAndDismiss
- };
+ throw new InvalidOperationException("You have too many context menu items. You can only have up to 5.");
+ }
- foreach (var item in ContextMenuItems)
- {
- el.Children.Add(item.ConvertToElement());
- }
+ var el = new Element_ToastActions()
+ {
+ SystemCommands = ToastSystemCommand.SnoozeAndDismiss
+ };
- return el;
+ foreach (var item in ContextMenuItems)
+ {
+ el.Children.Add(item.ConvertToElement());
}
+
+ return el;
}
}
\ No newline at end of file
diff --git a/components/Notifications/src/Toasts/ToastActivationOptions.cs b/components/Notifications/src/Toasts/ToastActivationOptions.cs
index 81609903a..aa0d25d01 100644
--- a/components/Notifications/src/Toasts/ToastActivationOptions.cs
+++ b/components/Notifications/src/Toasts/ToastActivationOptions.cs
@@ -4,35 +4,34 @@
using System;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// New in Creators Update: Additional options relating to activation.
+///
+public sealed class ToastActivationOptions
{
///
- /// New in Creators Update: Additional options relating to activation.
+ /// Gets or sets the target PFN if you are using . You can optionally specify, so that regardless of whether multiple apps are registered to handle the same protocol uri, your desired app will always be launched.
///
- public sealed class ToastActivationOptions
- {
- ///
- /// Gets or sets the target PFN if you are using . You can optionally specify, so that regardless of whether multiple apps are registered to handle the same protocol uri, your desired app will always be launched.
- ///
- public string ProtocolActivationTargetApplicationPfn { get; set; }
+ public string ProtocolActivationTargetApplicationPfn { get; set; }
- ///
- /// Gets or sets the behavior that the toast should use when the user invokes this action.
- /// Note that this option only works on and .
- /// Desktop-only, supported in builds 16251 or higher. New in Fall Creators Update
- ///
- public ToastAfterActivationBehavior AfterActivationBehavior { get; set; } = ToastAfterActivationBehavior.Default;
+ ///
+ /// Gets or sets the behavior that the toast should use when the user invokes this action.
+ /// Note that this option only works on and .
+ /// Desktop-only, supported in builds 16251 or higher. New in Fall Creators Update
+ ///
+ public ToastAfterActivationBehavior AfterActivationBehavior { get; set; } = ToastAfterActivationBehavior.Default;
- internal void PopulateElement(IElement_ToastActivatable el)
+ internal void PopulateElement(IElement_ToastActivatable el)
+ {
+ // If protocol PFN is specified but protocol activation isn't used, throw exception
+ if (ProtocolActivationTargetApplicationPfn != null && el.ActivationType != Element_ToastActivationType.Protocol)
{
- // If protocol PFN is specified but protocol activation isn't used, throw exception
- if (ProtocolActivationTargetApplicationPfn != null && el.ActivationType != Element_ToastActivationType.Protocol)
- {
- throw new InvalidOperationException($"You cannot specify {nameof(ProtocolActivationTargetApplicationPfn)} without using ActivationType of Protocol.");
- }
-
- el.ProtocolActivationTargetApplicationPfn = ProtocolActivationTargetApplicationPfn;
- el.AfterActivationBehavior = AfterActivationBehavior;
+ throw new InvalidOperationException($"You cannot specify {nameof(ProtocolActivationTargetApplicationPfn)} without using ActivationType of Protocol.");
}
+
+ el.ProtocolActivationTargetApplicationPfn = ProtocolActivationTargetApplicationPfn;
+ el.AfterActivationBehavior = AfterActivationBehavior;
}
}
\ No newline at end of file
diff --git a/components/Notifications/src/Toasts/ToastArguments.cs b/components/Notifications/src/Toasts/ToastArguments.cs
index de9862c11..7b294ca6d 100644
--- a/components/Notifications/src/Toasts/ToastArguments.cs
+++ b/components/Notifications/src/Toasts/ToastArguments.cs
@@ -7,423 +7,422 @@
using System.Collections.Generic;
using System.Linq;
-namespace CommunityToolkit.Notifications
-{
- ///
- /// A class that supports serializing simple key/value pairs into a format that's friendly for being used within toast notifications. The serialized format is similar to a query string, however optimized for being placed within an XML property (uses semicolons instead of ampersands since those don't need to be XML-escaped, doesn't url-encode all special characters since not being used within a URL, etc).
- ///
- public sealed class ToastArguments : IEnumerable>
- {
- private Dictionary _dictionary = new Dictionary();
+namespace CommunityToolkit.Notifications;
- internal ToastArguments Clone()
- {
- return new ToastArguments()
- {
- _dictionary = new Dictionary(_dictionary)
- };
- }
+///
+/// A class that supports serializing simple key/value pairs into a format that's friendly for being used within toast notifications. The serialized format is similar to a query string, however optimized for being placed within an XML property (uses semicolons instead of ampersands since those don't need to be XML-escaped, doesn't url-encode all special characters since not being used within a URL, etc).
+///
+public sealed partial class ToastArguments : IEnumerable>
+{
+ private Dictionary _dictionary = new Dictionary();
- ///
- /// Gets the value of the specified key. Throws if the key could not be found.
- ///
- /// The key to find.
- /// The value of the specified key.
- public string this[string key]
+ internal ToastArguments Clone()
+ {
+ return new ToastArguments()
{
- get
- {
- if (key == null)
- {
- throw new ArgumentNullException(nameof(key));
- }
-
- if (TryGetValue(key, out string value))
- {
- return value;
- }
-
- throw new KeyNotFoundException($"A key with name '{key}' could not be found.");
- }
-
- set
- {
- if (key == null)
- {
- throw new ArgumentNullException(nameof(key));
- }
-
- _dictionary[key] = value;
- }
- }
+ _dictionary = new Dictionary(_dictionary)
+ };
+ }
- ///
- /// Attempts to get the value of the specified key. If no key exists, returns false.
- ///
- /// The key to find.
- /// The key's value will be written here if found.
- /// True if found the key and set the value, otherwise false.
- public bool TryGetValue(string key, out string value)
+ ///
+ /// Gets the value of the specified key. Throws if the key could not be found.
+ ///
+ /// The key to find.
+ /// The value of the specified key.
+ public string this[string key]
+ {
+ get
{
if (key == null)
{
throw new ArgumentNullException(nameof(key));
}
- return _dictionary.TryGetValue(key, out value);
- }
-
- ///
- /// Attempts to get the value of the specified key. If no key exists, returns false.
- ///
- /// The enum to parse.
- /// The key to find.
- /// The key's value will be written here if found.
- /// True if found the key and set the value, otherwise false.
- public bool TryGetValue(string key, out T value)
- where T : struct, Enum
- {
- if (TryGetValue(key, out string strValue))
+ if (TryGetValue(key, out string value))
{
- return Enum.TryParse(strValue, out value);
+ return value;
}
- value = default(T);
- return false;
+ throw new KeyNotFoundException($"A key with name '{key}' could not be found.");
}
- ///
- /// Gets the value of the specified key, or throws if key didn't exist.
- ///
- /// The key to get.
- /// The value of the key.
- public string Get(string key)
+ set
{
if (key == null)
{
throw new ArgumentNullException(nameof(key));
}
- if (_dictionary.TryGetValue(key, out string value))
- {
- return value;
- }
-
- throw new KeyNotFoundException();
+ _dictionary[key] = value;
}
+ }
- ///
- /// Gets the value of the specified key, or throws if key didn't exist.
- ///
- /// The key to get.
- /// The value of the key.
- public int GetInt(string key)
+ ///
+ /// Attempts to get the value of the specified key. If no key exists, returns false.
+ ///
+ /// The key to find.
+ /// The key's value will be written here if found.
+ /// True if found the key and set the value, otherwise false.
+ public bool TryGetValue(string key, out string value)
+ {
+ if (key == null)
{
- return int.Parse(Get(key));
+ throw new ArgumentNullException(nameof(key));
}
- ///
- /// Gets the value of the specified key, or throws if key didn't exist.
- ///
- /// The key to get.
- /// The value of the key.
- public double GetDouble(string key)
- {
- return double.Parse(Get(key));
- }
+ return _dictionary.TryGetValue(key, out value);
+ }
- ///
- /// Gets the value of the specified key, or throws if key didn't exist.
- ///
- /// The key to get.
- /// The value of the key.
- public float GetFloat(string key)
+ ///
+ /// Attempts to get the value of the specified key. If no key exists, returns false.
+ ///
+ /// The enum to parse.
+ /// The key to find.
+ /// The key's value will be written here if found.
+ /// True if found the key and set the value, otherwise false.
+ public bool TryGetValue(string key, out T value)
+ where T : struct, Enum
+ {
+ if (TryGetValue(key, out string strValue))
{
- return float.Parse(Get(key));
+ return Enum.TryParse(strValue, out value);
}
- ///
- /// Gets the value of the specified key, or throws if key didn't exist.
- ///
- /// The key to get.
- /// The value of the key.
- public byte GetByte(string key)
- {
- return byte.Parse(Get(key));
- }
+ value = default(T);
+ return false;
+ }
- ///
- /// Gets the value of the specified key, or throws if key didn't exist.
- ///
- /// The key to get.
- /// The value of the key.
- public bool GetBool(string key)
+ ///
+ /// Gets the value of the specified key, or throws if key didn't exist.
+ ///
+ /// The key to get.
+ /// The value of the key.
+ public string Get(string key)
+ {
+ if (key == null)
{
- return Get(key) == "1" ? true : false;
+ throw new ArgumentNullException(nameof(key));
}
- ///
- /// Gets the value of the specified key, or throws if key didn't exist.
- ///
- /// The enum to parse.
- /// The key to get.
- /// The value of the key.
- public T GetEnum(string key)
- where T : struct, Enum
+ if (_dictionary.TryGetValue(key, out string value))
{
- if (TryGetValue(key, out T value))
- {
- return value;
- }
-
- throw new KeyNotFoundException();
+ return value;
}
- ///
- /// Gets the number of key/value pairs contained in the toast arguments.
- ///
- public int Count => _dictionary.Count;
-
- ///
- /// Adds a key. If there is an existing key, it is replaced.
- ///
- /// The key.
- /// The current object.
- public ToastArguments Add(string key)
- {
- if (key == null)
- {
- throw new ArgumentNullException(nameof(key));
- }
+ throw new KeyNotFoundException();
+ }
- _dictionary[key] = null;
+ ///
+ /// Gets the value of the specified key, or throws if key didn't exist.
+ ///
+ /// The key to get.
+ /// The value of the key.
+ public int GetInt(string key)
+ {
+ return int.Parse(Get(key));
+ }
- return this;
- }
+ ///
+ /// Gets the value of the specified key, or throws if key didn't exist.
+ ///
+ /// The key to get.
+ /// The value of the key.
+ public double GetDouble(string key)
+ {
+ return double.Parse(Get(key));
+ }
- ///
- /// Adds a key and optional value. If there is an existing key, it is replaced.
- ///
- /// The key.
- /// The optional value of the key.
- /// The current object.
- public ToastArguments Add(string key, string value)
- {
- if (key == null)
- {
- throw new ArgumentNullException(nameof(key));
- }
+ ///
+ /// Gets the value of the specified key, or throws if key didn't exist.
+ ///
+ /// The key to get.
+ /// The value of the key.
+ public float GetFloat(string key)
+ {
+ return float.Parse(Get(key));
+ }
- _dictionary[key] = value;
+ ///
+ /// Gets the value of the specified key, or throws if key didn't exist.
+ ///
+ /// The key to get.
+ /// The value of the key.
+ public byte GetByte(string key)
+ {
+ return byte.Parse(Get(key));
+ }
- return this;
- }
+ ///
+ /// Gets the value of the specified key, or throws if key didn't exist.
+ ///
+ /// The key to get.
+ /// The value of the key.
+ public bool GetBool(string key)
+ {
+ return Get(key) == "1" ? true : false;
+ }
- ///
- /// Adds a key and value. If there is an existing key, it is replaced.
- ///
- /// The key.
- /// The value of the key.
- /// The current object.
- public ToastArguments Add(string key, int value)
+ ///
+ /// Gets the value of the specified key, or throws if key didn't exist.
+ ///
+ /// The enum to parse.
+ /// The key to get.
+ /// The value of the key.
+ public T GetEnum(string key)
+ where T : struct, Enum
+ {
+ if (TryGetValue(key, out T value))
{
- return AddHelper(key, value);
+ return value;
}
- ///
- /// Adds a key and value. If there is an existing key, it is replaced.
- ///
- /// The key.
- /// The value of the key.
- /// The current object.
- public ToastArguments Add(string key, double value)
- {
- return AddHelper(key, value);
- }
+ throw new KeyNotFoundException();
+ }
- ///
- /// Adds a key and value. If there is an existing key, it is replaced.
- ///
- /// The key.
- /// The value of the key.
- /// The current object.
- public ToastArguments Add(string key, float value)
- {
- return AddHelper(key, value);
- }
+ ///
+ /// Gets the number of key/value pairs contained in the toast arguments.
+ ///
+ public int Count => _dictionary.Count;
- ///
- /// Adds a key and value. If there is an existing key, it is replaced.
- ///
- /// The key.
- /// The value of the key.
- /// The current object.
- public ToastArguments Add(string key, bool value)
+ ///
+ /// Adds a key. If there is an existing key, it is replaced.
+ ///
+ /// The key.
+ /// The current object.
+ public ToastArguments Add(string key)
+ {
+ if (key == null)
{
- return Add(key, value ? "1" : "0"); // Encode as 1 or 0 to save string space
+ throw new ArgumentNullException(nameof(key));
}
- ///
- /// Adds a key and value. If there is an existing key, it is replaced.
- ///
- /// The key.
- /// The value of the key. Note that the enums are stored using their numeric value, so be aware that changing your enum number values might break existing activation of toasts currently in Action Center.
- /// The current object.
- public ToastArguments Add(string key, Enum value)
+ _dictionary[key] = null;
+
+ return this;
+ }
+
+ ///
+ /// Adds a key and optional value. If there is an existing key, it is replaced.
+ ///
+ /// The key.
+ /// The optional value of the key.
+ /// The current object.
+ public ToastArguments Add(string key, string value)
+ {
+ if (key == null)
{
- return Add(key, (int)(object)value);
+ throw new ArgumentNullException(nameof(key));
}
- private ToastArguments AddHelper(string key, object value)
- {
- if (key == null)
- {
- throw new ArgumentNullException(nameof(key));
- }
+ _dictionary[key] = value;
- _dictionary[key] = value.ToString();
+ return this;
+ }
- return this;
- }
+ ///
+ /// Adds a key and value. If there is an existing key, it is replaced.
+ ///
+ /// The key.
+ /// The value of the key.
+ /// The current object.
+ public ToastArguments Add(string key, int value)
+ {
+ return AddHelper(key, value);
+ }
- ///
- /// Determines if the specified key is present.
- ///
- /// The key to look for.
- /// True if the key is present, otherwise false.
- public bool Contains(string key)
- {
- if (key == null)
- {
- throw new ArgumentNullException(nameof(key));
- }
+ ///
+ /// Adds a key and value. If there is an existing key, it is replaced.
+ ///
+ /// The key.
+ /// The value of the key.
+ /// The current object.
+ public ToastArguments Add(string key, double value)
+ {
+ return AddHelper(key, value);
+ }
- return _dictionary.ContainsKey(key);
- }
+ ///
+ /// Adds a key and value. If there is an existing key, it is replaced.
+ ///
+ /// The key.
+ /// The value of the key.
+ /// The current object.
+ public ToastArguments Add(string key, float value)
+ {
+ return AddHelper(key, value);
+ }
- ///
- /// Determines if specified key and value are present.
- ///
- /// The key to look for.
- /// The value to look for when the key has been matched.
- /// True if the key and value were found, else false.
- public bool Contains(string key, string value)
- {
- if (key == null)
- {
- throw new ArgumentNullException(nameof(key));
- }
+ ///
+ /// Adds a key and value. If there is an existing key, it is replaced.
+ ///
+ /// The key.
+ /// The value of the key.
+ /// The current object.
+ public ToastArguments Add(string key, bool value)
+ {
+ return Add(key, value ? "1" : "0"); // Encode as 1 or 0 to save string space
+ }
- return _dictionary.TryGetValue(key, out string actualValue) && actualValue == value;
- }
+ ///
+ /// Adds a key and value. If there is an existing key, it is replaced.
+ ///
+ /// The key.
+ /// The value of the key. Note that the enums are stored using their numeric value, so be aware that changing your enum number values might break existing activation of toasts currently in Action Center.
+ /// The current object.
+ public ToastArguments Add(string key, Enum value)
+ {
+ return Add(key, (int)(object)value);
+ }
- ///
- /// Removes the specified key and its associated value.
- ///
- /// The key to remove.
- /// True if the key was removed, else false.
- public bool Remove(string key)
+ private ToastArguments AddHelper(string key, object value)
+ {
+ if (key == null)
{
- if (key == null)
- {
- throw new ArgumentNullException(nameof(key));
- }
+ throw new ArgumentNullException(nameof(key));
+ }
+
+ _dictionary[key] = value.ToString();
- return _dictionary.Remove(key);
+ return this;
+ }
+
+ ///
+ /// Determines if the specified key is present.
+ ///
+ /// The key to look for.
+ /// True if the key is present, otherwise false.
+ public bool Contains(string key)
+ {
+ if (key == null)
+ {
+ throw new ArgumentNullException(nameof(key));
}
- private static string Encode(string str)
+ return _dictionary.ContainsKey(key);
+ }
+
+ ///
+ /// Determines if specified key and value are present.
+ ///
+ /// The key to look for.
+ /// The value to look for when the key has been matched.
+ /// True if the key and value were found, else false.
+ public bool Contains(string key, string value)
+ {
+ if (key == null)
{
- return str
- .Replace("%", "%25")
- .Replace(";", "%3B")
- .Replace("=", "%3D");
+ throw new ArgumentNullException(nameof(key));
}
- private static string Decode(string str)
+ return _dictionary.TryGetValue(key, out string actualValue) && actualValue == value;
+ }
+
+ ///
+ /// Removes the specified key and its associated value.
+ ///
+ /// The key to remove.
+ /// True if the key was removed, else false.
+ public bool Remove(string key)
+ {
+ if (key == null)
{
- return str
- .Replace("%25", "%")
- .Replace("%3B", ";")
- .Replace("%3D", "=");
+ throw new ArgumentNullException(nameof(key));
}
- ///
- /// Parses a string that was generated using ToastArguments into a object.
- ///
- /// The toast arguments string to deserialize.
- /// The parsed toast arguments.
- public static ToastArguments Parse(string toastArgumentsStr)
+ return _dictionary.Remove(key);
+ }
+
+ private static string Encode(string str)
+ {
+ return str
+ .Replace("%", "%25")
+ .Replace(";", "%3B")
+ .Replace("=", "%3D");
+ }
+
+ private static string Decode(string str)
+ {
+ return str
+ .Replace("%25", "%")
+ .Replace("%3B", ";")
+ .Replace("%3D", "=");
+ }
+
+ ///
+ /// Parses a string that was generated using ToastArguments into a object.
+ ///
+ /// The toast arguments string to deserialize.
+ /// The parsed toast arguments.
+ public static ToastArguments Parse(string toastArgumentsStr)
+ {
+ if (string.IsNullOrWhiteSpace(toastArgumentsStr))
{
- if (string.IsNullOrWhiteSpace(toastArgumentsStr))
- {
- return new ToastArguments();
- }
+ return new ToastArguments();
+ }
+
+ string[] pairs = toastArgumentsStr.Split(';');
+
+ ToastArguments answer = new ToastArguments();
- string[] pairs = toastArgumentsStr.Split(';');
+ foreach (string pair in pairs)
+ {
+ string name;
+ string value;
- ToastArguments answer = new ToastArguments();
+ int indexOfEquals = pair.IndexOf('=');
- foreach (string pair in pairs)
+ if (indexOfEquals == -1)
+ {
+ name = Decode(pair);
+ value = null;
+ }
+ else
{
- string name;
- string value;
-
- int indexOfEquals = pair.IndexOf('=');
-
- if (indexOfEquals == -1)
- {
- name = Decode(pair);
- value = null;
- }
- else
- {
- name = Decode(pair.Substring(0, indexOfEquals));
- value = Decode(pair.Substring(indexOfEquals + 1));
- }
-
- answer.Add(name, value);
+ name = Decode(pair.Substring(0, indexOfEquals));
+ value = Decode(pair.Substring(indexOfEquals + 1));
}
- return answer;
+ answer.Add(name, value);
}
- ///
- /// Serializes the key-value pairs into a string that can be used within a toast notification.
- ///
- /// A string that can be used within a toast notification.
- public sealed override string ToString()
- {
- return string.Join(Separator, this.Select(pair => EncodePair(pair.Key, pair.Value)));
- }
+ return answer;
+ }
- internal static string EncodePair(string key, string value)
- {
- // Key
- return Encode(key) +
+ ///
+ /// Serializes the key-value pairs into a string that can be used within a toast notification.
+ ///
+ /// A string that can be used within a toast notification.
+ public sealed override string ToString()
+ {
+ return string.Join(Separator, this.Select(pair => EncodePair(pair.Key, pair.Value)));
+ }
- // Write value if not null
- ((value == null) ? string.Empty : ("=" + Encode(value)));
- }
+ internal static string EncodePair(string key, string value)
+ {
+ // Key
+ return Encode(key) +
- internal const string Separator = ";";
+ // Write value if not null
+ ((value == null) ? string.Empty : ("=" + Encode(value)));
+ }
- ///
- /// Gets an enumerator to enumerate the arguments. Note that order of the arguments is NOT preserved.
- ///
- /// An enumeartor of the key/value pairs.
- public IEnumerator> GetEnumerator()
- {
- return _dictionary.GetEnumerator();
- }
+ internal const string Separator = ";";
- ///
- /// Gets an enumerator to enumerate the query string parameters.
- ///
- /// An enumeartor of the key/value pairs.
- IEnumerator IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
+ ///
+ /// Gets an enumerator to enumerate the arguments. Note that order of the arguments is NOT preserved.
+ ///
+ /// An enumeartor of the key/value pairs.
+ public IEnumerator> GetEnumerator()
+ {
+ return _dictionary.GetEnumerator();
+ }
+
+ ///
+ /// Gets an enumerator to enumerate the query string parameters.
+ ///
+ /// An enumeartor of the key/value pairs.
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
}
}
diff --git a/components/Notifications/src/Toasts/ToastAudio.cs b/components/Notifications/src/Toasts/ToastAudio.cs
index 1f7f3a949..a284bdf7f 100644
--- a/components/Notifications/src/Toasts/ToastAudio.cs
+++ b/components/Notifications/src/Toasts/ToastAudio.cs
@@ -4,36 +4,35 @@
using System;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// Specify audio to be played when the Toast notification is received.
+///
+public sealed class ToastAudio
{
///
- /// Specify audio to be played when the Toast notification is received.
+ /// Gets or sets the media file to play in place of the default sound.
///
- public sealed class ToastAudio
- {
- ///
- /// Gets or sets the media file to play in place of the default sound.
- ///
- public Uri Src { get; set; }
+ public Uri Src { get; set; }
- ///
- /// Gets or sets a value indicating whether sound should repeat as long as the Toast is shown; false to play only once (default).
- ///
- public bool Loop { get; set; } = Element_ToastAudio.DEFAULT_LOOP;
+ ///
+ /// Gets or sets a value indicating whether sound should repeat as long as the Toast is shown; false to play only once (default).
+ ///
+ public bool Loop { get; set; } = Element_ToastAudio.DEFAULT_LOOP;
- ///
- /// Gets or sets a value indicating whether sound is muted; false to allow the Toast notification sound to play (default).
- ///
- public bool Silent { get; set; } = Element_ToastAudio.DEFAULT_SILENT;
+ ///
+ /// Gets or sets a value indicating whether sound is muted; false to allow the Toast notification sound to play (default).
+ ///
+ public bool Silent { get; set; } = Element_ToastAudio.DEFAULT_SILENT;
- internal Element_ToastAudio ConvertToElement()
+ internal Element_ToastAudio ConvertToElement()
+ {
+ return new Element_ToastAudio()
{
- return new Element_ToastAudio()
- {
- Src = Src,
- Loop = Loop,
- Silent = Silent
- };
- }
+ Src = Src,
+ Loop = Loop,
+ Silent = Silent
+ };
}
}
\ No newline at end of file
diff --git a/components/Notifications/src/Toasts/ToastBindingGeneric.cs b/components/Notifications/src/Toasts/ToastBindingGeneric.cs
index 7ea818807..39b01820b 100644
--- a/components/Notifications/src/Toasts/ToastBindingGeneric.cs
+++ b/components/Notifications/src/Toasts/ToastBindingGeneric.cs
@@ -6,94 +6,93 @@
using System.Collections.Generic;
using CommunityToolkit.Notifications.Adaptive;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// Generic Toast binding, where you provide text, images, and other visual elements for your Toast notification.
+///
+public sealed class ToastBindingGeneric
{
///
- /// Generic Toast binding, where you provide text, images, and other visual elements for your Toast notification.
+ /// Gets the contents of the body of the Toast, which can include , ,
+ /// and (added in Anniversary Update). Also, elements must come
+ /// before any other elements. If an element is placed after any other element, an exception
+ /// will be thrown when you try to retrieve the Toast XML content. And finally, certain properties
+ /// like HintStyle aren't supported on the root children text elements, and only work inside an .
+ /// If you use on devices without the Anniversary Update, the group content will simply be dropped.
///
- public sealed class ToastBindingGeneric
- {
- ///
- /// Gets the contents of the body of the Toast, which can include , ,
- /// and (added in Anniversary Update). Also, elements must come
- /// before any other elements. If an element is placed after any other element, an exception
- /// will be thrown when you try to retrieve the Toast XML content. And finally, certain properties
- /// like HintStyle aren't supported on the root children text elements, and only work inside an .
- /// If you use on devices without the Anniversary Update, the group content will simply be dropped.
- ///
- public IList Children { get; private set; } = new List();
+ public IList Children { get; private set; } = new List();
- ///
- /// Gets or sets an optional override of the logo displayed on the Toast notification.
- ///
- public ToastGenericAppLogo AppLogoOverride { get; set; }
+ ///
+ /// Gets or sets an optional override of the logo displayed on the Toast notification.
+ ///
+ public ToastGenericAppLogo AppLogoOverride { get; set; }
- ///
- /// Gets or sets an optional hero image (a visually impactful image displayed on the Toast notification).
- /// On devices without the Anniversary Update, the hero image will simply be ignored.
- ///
- public ToastGenericHeroImage HeroImage { get; set; }
+ ///
+ /// Gets or sets an optional hero image (a visually impactful image displayed on the Toast notification).
+ /// On devices without the Anniversary Update, the hero image will simply be ignored.
+ ///
+ public ToastGenericHeroImage HeroImage { get; set; }
- ///
- /// Gets or sets an optional text element that is displayed as attribution text. On devices without
- /// the Anniversary Update, this text will appear as if it's another
- /// element at the end of your Children list.
- ///
- public ToastGenericAttributionText Attribution { get; set; }
+ ///
+ /// Gets or sets an optional text element that is displayed as attribution text. On devices without
+ /// the Anniversary Update, this text will appear as if it's another
+ /// element at the end of your Children list.
+ ///
+ public ToastGenericAttributionText Attribution { get; set; }
- ///
- /// Gets or sets the target locale of the XML payload, specified as BCP-47 language tags such as "en-US"
- /// or "fr-FR". This locale is overridden by any locale specified in binding or 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.
- ///
- public string Language { get; set; }
+ ///
+ /// Gets or sets the target locale of the XML payload, specified as BCP-47 language tags such as "en-US"
+ /// or "fr-FR". This locale is overridden by any locale specified in binding or 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.
+ ///
+ public string Language { get; set; }
- ///
- /// Gets or sets a default base URI that is combined with relative URIs in image source attributes.
- ///
- public Uri BaseUri { get; set; }
+ ///
+ /// Gets or sets a default base URI that is combined with relative URIs in image source attributes.
+ ///
+ public Uri BaseUri { get; set; }
- ///
- /// Gets or sets a value whether Windows is allowed to append a query string to the image URI supplied in the Toast 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.
- ///
- public bool? AddImageQuery { get; set; }
+ ///
+ /// Gets or sets a value whether Windows is allowed to append a query string to the image URI supplied in the Toast 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.
+ ///
+ public bool? AddImageQuery { get; set; }
- internal Element_ToastBinding ConvertToElement()
+ internal Element_ToastBinding ConvertToElement()
+ {
+ Element_ToastBinding binding = new Element_ToastBinding(ToastTemplateType.ToastGeneric)
{
- Element_ToastBinding binding = new Element_ToastBinding(ToastTemplateType.ToastGeneric)
- {
- BaseUri = BaseUri,
- AddImageQuery = AddImageQuery,
- Language = Language
- };
+ BaseUri = BaseUri,
+ AddImageQuery = AddImageQuery,
+ Language = Language
+ };
- // Add children
- foreach (var child in Children)
- {
- var el = (IElement_ToastBindingChild)AdaptiveHelper.ConvertToElement(child);
- binding.Children.Add(el);
- }
-
- // Add attribution
- if (Attribution != null)
- {
- binding.Children.Add(Attribution.ConvertToElement());
- }
+ // Add children
+ foreach (var child in Children)
+ {
+ var el = (IElement_ToastBindingChild)AdaptiveHelper.ConvertToElement(child);
+ binding.Children.Add(el);
+ }
- // If there's hero, add it
- if (HeroImage != null)
- {
- binding.Children.Add(HeroImage.ConvertToElement());
- }
+ // Add attribution
+ if (Attribution != null)
+ {
+ binding.Children.Add(Attribution.ConvertToElement());
+ }
- // If there's app logo, add it
- if (AppLogoOverride != null)
- {
- binding.Children.Add(AppLogoOverride.ConvertToElement());
- }
+ // If there's hero, add it
+ if (HeroImage != null)
+ {
+ binding.Children.Add(HeroImage.ConvertToElement());
+ }
- return binding;
+ // If there's app logo, add it
+ if (AppLogoOverride != null)
+ {
+ binding.Children.Add(AppLogoOverride.ConvertToElement());
}
+
+ return binding;
}
}
\ No newline at end of file
diff --git a/components/Notifications/src/Toasts/ToastBindingShoulderTap.cs b/components/Notifications/src/Toasts/ToastBindingShoulderTap.cs
index 0097eb721..eb596ed3c 100644
--- a/components/Notifications/src/Toasts/ToastBindingShoulderTap.cs
+++ b/components/Notifications/src/Toasts/ToastBindingShoulderTap.cs
@@ -4,53 +4,52 @@
using System;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// Specifies content you want to appear in a My People shoulder tap notification. For more info, see the My People notifications documentation. New in Fall Creators Update.
+///
+public sealed class ToastBindingShoulderTap
{
///
- /// Specifies content you want to appear in a My People shoulder tap notification. For more info, see the My People notifications documentation. New in Fall Creators Update.
+ /// Gets or sets the image to be displayed in the shoulder tap notification. Required.
+ ///
+ public ToastShoulderTapImage Image { get; set; }
+
+ ///
+ /// Gets or sets the target locale of the XML payload, specified as BCP-47 language tags such as "en-US"
+ /// or "fr-FR". This locale is overridden by any locale specified in binding or 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.
+ ///
+ public string Language { get; set; }
+
+ ///
+ /// Gets or sets a default base URI that is combined with relative URIs in image source attributes.
///
- public sealed class ToastBindingShoulderTap
+ public Uri BaseUri { get; set; }
+
+ ///
+ /// Gets or sets a value whether Windows is allowed to append a query string to the image URI supplied in the Toast 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.
+ ///
+ public bool? AddImageQuery { get; set; }
+
+ internal Element_ToastBinding ConvertToElement()
{
- ///
- /// Gets or sets the image to be displayed in the shoulder tap notification. Required.
- ///
- public ToastShoulderTapImage Image { get; set; }
-
- ///
- /// Gets or sets the target locale of the XML payload, specified as BCP-47 language tags such as "en-US"
- /// or "fr-FR". This locale is overridden by any locale specified in binding or 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.
- ///
- public string Language { get; set; }
-
- ///
- /// Gets or sets a default base URI that is combined with relative URIs in image source attributes.
- ///
- public Uri BaseUri { get; set; }
-
- ///
- /// Gets or sets a value whether Windows is allowed to append a query string to the image URI supplied in the Toast 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.
- ///
- public bool? AddImageQuery { get; set; }
-
- internal Element_ToastBinding ConvertToElement()
+ Element_ToastBinding binding = new Element_ToastBinding(ToastTemplateType.ToastGeneric)
+ {
+ ExperienceType = "shoulderTap",
+ BaseUri = BaseUri,
+ AddImageQuery = AddImageQuery,
+ Language = Language
+ };
+
+ // If there's an image, add it
+ if (Image != null)
{
- Element_ToastBinding binding = new Element_ToastBinding(ToastTemplateType.ToastGeneric)
- {
- ExperienceType = "shoulderTap",
- BaseUri = BaseUri,
- AddImageQuery = AddImageQuery,
- Language = Language
- };
-
- // If there's an image, add it
- if (Image != null)
- {
- binding.Children.Add(Image.ConvertToElement());
- }
-
- return binding;
+ binding.Children.Add(Image.ConvertToElement());
}
+
+ return binding;
}
}
\ No newline at end of file
diff --git a/components/Notifications/src/Toasts/ToastButton.cs b/components/Notifications/src/Toasts/ToastButton.cs
index e0db4f7cf..92d150e0f 100644
--- a/components/Notifications/src/Toasts/ToastButton.cs
+++ b/components/Notifications/src/Toasts/ToastButton.cs
@@ -5,442 +5,441 @@
using System;
using System.Collections.Generic;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// A button that the user can click on a Toast notification.
+///
+public sealed class ToastButton :
+ IToastActivateableBuilder,
+ IToastButton
{
- ///
- /// A button that the user can click on a Toast notification.
- ///
- public sealed class ToastButton :
- IToastActivateableBuilder,
- IToastButton
- {
- private Dictionary _arguments = new Dictionary();
+ private Dictionary _arguments = new Dictionary();
- private bool _usingCustomArguments;
+ private bool _usingCustomArguments;
- private bool _usingSnoozeActivation;
- private string _snoozeSelectionBoxId;
+ private bool _usingSnoozeActivation;
+ private string _snoozeSelectionBoxId;
- private bool _usingDismissActivation;
+ private bool _usingDismissActivation;
- internal bool NeedsContent()
- {
- // Snooze/dismiss buttons don't need content (the system will auto-add the localized strings).
- return !_usingDismissActivation && !_usingSnoozeActivation;
- }
+ internal bool NeedsContent()
+ {
+ // Snooze/dismiss buttons don't need content (the system will auto-add the localized strings).
+ return !_usingDismissActivation && !_usingSnoozeActivation;
+ }
- ///
- /// Initializes a new instance of the class.
- ///
- /// The text to display on the button.
- /// App-defined string of arguments that the app can later retrieve once it is activated when the user clicks the button.
- public ToastButton(string content, string arguments)
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The text to display on the button.
+ /// App-defined string of arguments that the app can later retrieve once it is activated when the user clicks the button.
+ public ToastButton(string content, string arguments)
+ {
+ if (content == null)
{
- if (content == null)
- {
- throw new ArgumentNullException(nameof(content));
- }
-
- if (arguments == null)
- {
- throw new ArgumentNullException(nameof(arguments));
- }
-
- Content = content;
- Arguments = arguments;
-
- _usingCustomArguments = arguments.Length > 0;
+ throw new ArgumentNullException(nameof(content));
}
- ///
- /// Initializes a new instance of the class.
- ///
- public ToastButton()
+ if (arguments == null)
{
- // Arguments are required (we'll initialize to empty string which is fine).
- Arguments = string.Empty;
+ throw new ArgumentNullException(nameof(arguments));
}
- ///
- /// Gets the text to display on the button. Required
- ///
- public string Content { get; private set; }
-
- ///
- /// Gets app-defined string of arguments that the app can later retrieve once it is
- /// activated when the user clicks the button. Required
- ///
- public string Arguments { get; internal set; }
-
- ///
- /// Gets or sets what type of activation this button will use when clicked. Defaults to Foreground.
- ///
- public ToastActivationType ActivationType { get; set; } = ToastActivationType.Foreground;
-
- ///
- /// Gets or sets additional options relating to activation of the toast button. New in Creators Update
- ///
- public ToastActivationOptions ActivationOptions { get; set; }
-
- ///
- /// Gets or sets an optional image icon for the button to display (required for buttons adjacent to inputs like quick reply).
- ///
- public string ImageUri { get; set; }
-
- ///
- /// Gets or sets the ID of an existing in order to have this button display
- /// to the right of the input, achieving a quick reply scenario.
- ///
- public string TextBoxId { get; set; }
-
- ///
- /// Gets or sets an identifier used in telemetry to identify your category of action. This should be something
- /// like "Delete", "Reply", or "Archive". In the upcoming toast telemetry dashboard in Dev Center, you will
- /// be able to view how frequently your actions are being clicked.
- ///
- public string HintActionId { get; set; }
-
- ///
- /// Sets the text to display on the button.
- ///
- /// The text to display on the button.
- /// The current instance of the .
- public ToastButton SetContent(string content)
- {
- Content = content;
- return this;
- }
+ Content = content;
+ Arguments = arguments;
- ///
- /// Adds a key (without value) to the activation arguments that will be returned when the toast notification or its buttons are clicked.
- ///
- /// The key.
- /// The current instance of
- public ToastButton AddArgument(string key)
- {
- return AddArgumentHelper(key, null);
- }
+ _usingCustomArguments = arguments.Length > 0;
+ }
- ///
- /// Adds a key/value to the activation arguments that will be returned when the toast notification or its buttons are clicked.
- ///
- /// The key for this value.
- /// The value itself.
- /// The current instance of
- public ToastButton AddArgument(string key, string value)
- {
- return AddArgumentHelper(key, value);
- }
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public ToastButton()
+ {
+ // Arguments are required (we'll initialize to empty string which is fine).
+ Arguments = string.Empty;
+ }
- ///
- /// Adds a key/value to the activation arguments that will be returned when the toast notification or its buttons are clicked.
- ///
- /// The key for this value.
- /// The value itself.
- /// The current instance of
- public ToastButton AddArgument(string key, int value)
- {
- return AddArgumentHelper(key, value.ToString());
- }
+ ///
+ /// Gets the text to display on the button. Required
+ ///
+ public string Content { get; private set; }
- ///
- /// Adds a key/value to the activation arguments that will be returned when the toast notification or its buttons are clicked.
- ///
- /// The key for this value.
- /// The value itself.
- /// The current instance of
- public ToastButton AddArgument(string key, double value)
- {
- return AddArgumentHelper(key, value.ToString());
- }
+ ///
+ /// Gets app-defined string of arguments that the app can later retrieve once it is
+ /// activated when the user clicks the button. Required
+ ///
+ public string Arguments { get; internal set; }
- ///
- /// Adds a key/value to the activation arguments that will be returned when the toast notification or its buttons are clicked.
- ///
- /// The key for this value.
- /// The value itself.
- /// The current instance of
- public ToastButton AddArgument(string key, float value)
- {
- return AddArgumentHelper(key, value.ToString());
- }
+ ///
+ /// Gets or sets what type of activation this button will use when clicked. Defaults to Foreground.
+ ///
+ public ToastActivationType ActivationType { get; set; } = ToastActivationType.Foreground;
- ///
- /// Adds a key/value to the activation arguments that will be returned when the toast notification or its buttons are clicked.
- ///
- /// The key for this value.
- /// The value itself.
- /// The current instance of
- public ToastButton AddArgument(string key, bool value)
- {
- return AddArgumentHelper(key, value ? "1" : "0"); // Encode as 1 or 0 to save string space
- }
+ ///
+ /// Gets or sets additional options relating to activation of the toast button. New in Creators Update
+ ///
+ public ToastActivationOptions ActivationOptions { get; set; }
- ///
- /// Adds a key/value to the activation arguments that will be returned when the toast notification or its buttons are clicked.
- ///
- /// The key for this value.
- /// The value itself. Note that the enums are stored using their numeric value, so be aware that changing your enum number values might break existing activation of toasts currently in Action Center.
- /// The current instance of
- public ToastButton AddArgument(string key, Enum value)
- {
- return AddArgumentHelper(key, ((int)(object)value).ToString());
- }
+ ///
+ /// Gets or sets an optional image icon for the button to display (required for buttons adjacent to inputs like quick reply).
+ ///
+ public string ImageUri { get; set; }
- private ToastButton AddArgumentHelper(string key, string value)
- {
- if (key == null)
- {
- throw new ArgumentNullException(nameof(key));
- }
+ ///
+ /// Gets or sets the ID of an existing in order to have this button display
+ /// to the right of the input, achieving a quick reply scenario.
+ ///
+ public string TextBoxId { get; set; }
- if (_usingCustomArguments)
- {
- throw new InvalidOperationException("You cannot use the AddArgument methods if you've set the Arguments property. Use the default ToastButton constructor instead.");
- }
+ ///
+ /// Gets or sets an identifier used in telemetry to identify your category of action. This should be something
+ /// like "Delete", "Reply", or "Archive". In the upcoming toast telemetry dashboard in Dev Center, you will
+ /// be able to view how frequently your actions are being clicked.
+ ///
+ public string HintActionId { get; set; }
- if (ActivationType == ToastActivationType.Protocol)
- {
- throw new InvalidOperationException("You cannot use the AddArgument methods when using protocol activation.");
- }
+ ///
+ /// Sets the text to display on the button.
+ ///
+ /// The text to display on the button.
+ /// The current instance of the .
+ public ToastButton SetContent(string content)
+ {
+ Content = content;
+ return this;
+ }
- if (_usingDismissActivation || _usingSnoozeActivation)
- {
- throw new InvalidOperationException("You cannot use the AddArgument methods when using dismiss or snooze activation.");
- }
+ ///
+ /// Adds a key (without value) to the activation arguments that will be returned when the toast notification or its buttons are clicked.
+ ///
+ /// The key.
+ /// The current instance of
+ public ToastButton AddArgument(string key)
+ {
+ return AddArgumentHelper(key, null);
+ }
- bool alreadyExists = _arguments.ContainsKey(key);
+ ///
+ /// Adds a key/value to the activation arguments that will be returned when the toast notification or its buttons are clicked.
+ ///
+ /// The key for this value.
+ /// The value itself.
+ /// The current instance of
+ public ToastButton AddArgument(string key, string value)
+ {
+ return AddArgumentHelper(key, value);
+ }
- _arguments[key] = value;
+ ///
+ /// Adds a key/value to the activation arguments that will be returned when the toast notification or its buttons are clicked.
+ ///
+ /// The key for this value.
+ /// The value itself.
+ /// The current instance of
+ public ToastButton AddArgument(string key, int value)
+ {
+ return AddArgumentHelper(key, value.ToString());
+ }
- Arguments = alreadyExists ? SerializeArgumentsHelper(_arguments) : AddArgumentHelper(Arguments, key, value);
+ ///
+ /// Adds a key/value to the activation arguments that will be returned when the toast notification or its buttons are clicked.
+ ///
+ /// The key for this value.
+ /// The value itself.
+ /// The current instance of
+ public ToastButton AddArgument(string key, double value)
+ {
+ return AddArgumentHelper(key, value.ToString());
+ }
- return this;
- }
+ ///
+ /// Adds a key/value to the activation arguments that will be returned when the toast notification or its buttons are clicked.
+ ///
+ /// The key for this value.
+ /// The value itself.
+ /// The current instance of
+ public ToastButton AddArgument(string key, float value)
+ {
+ return AddArgumentHelper(key, value.ToString());
+ }
- private string SerializeArgumentsHelper(IDictionary arguments)
- {
- var args = new ToastArguments();
+ ///
+ /// Adds a key/value to the activation arguments that will be returned when the toast notification or its buttons are clicked.
+ ///
+ /// The key for this value.
+ /// The value itself.
+ /// The current instance of
+ public ToastButton AddArgument(string key, bool value)
+ {
+ return AddArgumentHelper(key, value ? "1" : "0"); // Encode as 1 or 0 to save string space
+ }
- foreach (var a in arguments)
- {
- args.Add(a.Key, a.Value);
- }
+ ///
+ /// Adds a key/value to the activation arguments that will be returned when the toast notification or its buttons are clicked.
+ ///
+ /// The key for this value.
+ /// The value itself. Note that the enums are stored using their numeric value, so be aware that changing your enum number values might break existing activation of toasts currently in Action Center.
+ /// The current instance of
+ public ToastButton AddArgument(string key, Enum value)
+ {
+ return AddArgumentHelper(key, ((int)(object)value).ToString());
+ }
- return args.ToString();
+ private ToastButton AddArgumentHelper(string key, string value)
+ {
+ if (key == null)
+ {
+ throw new ArgumentNullException(nameof(key));
}
- private string AddArgumentHelper(string existing, string key, string value)
+ if (_usingCustomArguments)
{
- string pair = ToastArguments.EncodePair(key, value);
-
- if (string.IsNullOrEmpty(existing))
- {
- return pair;
- }
- else
- {
- return existing + ToastArguments.Separator + pair;
- }
+ throw new InvalidOperationException("You cannot use the AddArgument methods if you've set the Arguments property. Use the default ToastButton constructor instead.");
}
- ///
- /// Configures the button to launch the specified url when the button is clicked.
- ///
- /// The protocol to launch.
- /// The current instance of
- public ToastButton SetProtocolActivation(Uri protocol)
+ if (ActivationType == ToastActivationType.Protocol)
{
- return SetProtocolActivation(protocol, default);
+ throw new InvalidOperationException("You cannot use the AddArgument methods when using protocol activation.");
}
- ///
- /// Configures the button to launch the specified url when the button is clicked.
- ///
- /// The protocol to launch.
- /// New in Creators Update: The target PFN, so that regardless of whether multiple apps are registered to handle the same protocol uri, your desired app will always be launched.
- /// The current instance of
- public ToastButton SetProtocolActivation(Uri protocol, string targetApplicationPfn)
+ if (_usingDismissActivation || _usingSnoozeActivation)
{
- if (_arguments.Count > 0)
- {
- throw new InvalidOperationException("SetProtocolActivation cannot be used in conjunction with AddArgument");
- }
+ throw new InvalidOperationException("You cannot use the AddArgument methods when using dismiss or snooze activation.");
+ }
- Arguments = protocol.ToString();
- ActivationType = ToastActivationType.Protocol;
+ bool alreadyExists = _arguments.ContainsKey(key);
- if (targetApplicationPfn != null)
- {
- if (ActivationOptions == null)
- {
- ActivationOptions = new ToastActivationOptions();
- }
+ _arguments[key] = value;
- ActivationOptions.ProtocolActivationTargetApplicationPfn = targetApplicationPfn;
- }
+ Arguments = alreadyExists ? SerializeArgumentsHelper(_arguments) : AddArgumentHelper(Arguments, key, value);
- return this;
- }
+ return this;
+ }
- ///
- /// Configures the button to use background activation when the button is clicked.
- ///
- /// The current instance of
- public ToastButton SetBackgroundActivation()
- {
- ActivationType = ToastActivationType.Background;
- return this;
- }
+ private string SerializeArgumentsHelper(IDictionary arguments)
+ {
+ var args = new ToastArguments();
- ///
- /// Sets the behavior that the toast should use when the user invokes this button. Desktop-only, supported in builds 16251 or higher. New in Fall Creators Update.
- ///
- /// The behavior that the toast should use when the user invokes this button.
- /// The current instance of
- public ToastButton SetAfterActivationBehavior(ToastAfterActivationBehavior afterActivationBehavior)
+ foreach (var a in arguments)
{
- if (ActivationOptions == null)
- {
- ActivationOptions = new ToastActivationOptions();
- }
+ args.Add(a.Key, a.Value);
+ }
- ActivationOptions.AfterActivationBehavior = afterActivationBehavior;
+ return args.ToString();
+ }
- return this;
- }
+ private string AddArgumentHelper(string existing, string key, string value)
+ {
+ string pair = ToastArguments.EncodePair(key, value);
- ///
- /// Configures the button to use system snooze activation when the button is clicked, using the default system snooze time.
- ///
- /// The current instance of
- public ToastButton SetSnoozeActivation()
+ if (string.IsNullOrEmpty(existing))
{
- return SetSnoozeActivation(null);
+ return pair;
}
-
- ///
- /// Configures the button to use system snooze activation when the button is clicked, with a snooze time defined by the specified selection box.
- ///
- /// The ID of an existing which allows the user to pick a custom snooze time. The ID's of the s inside the selection box must represent the snooze interval in minutes. For example, if the user selects an item that has an ID of "120", then the notification will be snoozed for 2 hours. When the user clicks this button, if you specified a SelectionBoxId, the system will parse the ID of the selected item and snooze by that amount of minutes.
- /// The current instance of
- public ToastButton SetSnoozeActivation(string selectionBoxId)
+ else
{
- if (_arguments.Count > 0)
- {
- throw new InvalidOperationException($"{nameof(SetSnoozeActivation)} cannot be used in conjunction with ${nameof(AddArgument)}.");
- }
+ return existing + ToastArguments.Separator + pair;
+ }
+ }
- _usingSnoozeActivation = true;
- _snoozeSelectionBoxId = selectionBoxId;
+ ///
+ /// Configures the button to launch the specified url when the button is clicked.
+ ///
+ /// The protocol to launch.
+ /// The current instance of
+ public ToastButton SetProtocolActivation(Uri protocol)
+ {
+ return SetProtocolActivation(protocol, default);
+ }
- return this;
+ ///
+ /// Configures the button to launch the specified url when the button is clicked.
+ ///
+ /// The protocol to launch.
+ /// New in Creators Update: The target PFN, so that regardless of whether multiple apps are registered to handle the same protocol uri, your desired app will always be launched.
+ /// The current instance of
+ public ToastButton SetProtocolActivation(Uri protocol, string targetApplicationPfn)
+ {
+ if (_arguments.Count > 0)
+ {
+ throw new InvalidOperationException("SetProtocolActivation cannot be used in conjunction with AddArgument");
}
- ///
- /// Configures the button to use system dismiss activation when the button is clicked (the toast will simply dismiss rather than activating).
- ///
- /// The current instance of
- public ToastButton SetDismissActivation()
+ Arguments = protocol.ToString();
+ ActivationType = ToastActivationType.Protocol;
+
+ if (targetApplicationPfn != null)
{
- if (_arguments.Count > 0)
+ if (ActivationOptions == null)
{
- throw new InvalidOperationException($"{nameof(SetDismissActivation)} cannot be used in conjunction with ${nameof(AddArgument)}.");
+ ActivationOptions = new ToastActivationOptions();
}
- _usingDismissActivation = true;
- return this;
+ ActivationOptions.ProtocolActivationTargetApplicationPfn = targetApplicationPfn;
}
- ///
- /// Sets an identifier used in telemetry to identify your category of action. This should be something like "Delete", "Reply", or "Archive". In the upcoming toast telemetry dashboard in Dev Center, you will be able to view how frequently your actions are being clicked.
- ///
- /// An identifier used in telemetry to identify your category of action.
- /// The current instance of
- public ToastButton SetHintActionId(string actionId)
- {
- HintActionId = actionId;
- return this;
- }
+ return this;
+ }
+
+ ///
+ /// Configures the button to use background activation when the button is clicked.
+ ///
+ /// The current instance of
+ public ToastButton SetBackgroundActivation()
+ {
+ ActivationType = ToastActivationType.Background;
+ return this;
+ }
- ///
- /// Sets an optional image icon for the button to display (required for buttons adjacent to inputs like quick reply).
- ///
- /// An optional image icon for the button to display.
- /// The current instance of
- public ToastButton SetImageUri(Uri imageUri)
+ ///
+ /// Sets the behavior that the toast should use when the user invokes this button. Desktop-only, supported in builds 16251 or higher. New in Fall Creators Update.
+ ///
+ /// The behavior that the toast should use when the user invokes this button.
+ /// The current instance of
+ public ToastButton SetAfterActivationBehavior(ToastAfterActivationBehavior afterActivationBehavior)
+ {
+ if (ActivationOptions == null)
{
- ImageUri = imageUri.ToString();
- return this;
+ ActivationOptions = new ToastActivationOptions();
}
- ///
- /// Sets the ID of an existing in order to have this button display to the right of the input, achieving a quick reply scenario.
- ///
- /// The ID of an existing .
- /// The current instance of
- public ToastButton SetTextBoxId(string textBoxId)
+ ActivationOptions.AfterActivationBehavior = afterActivationBehavior;
+
+ return this;
+ }
+
+ ///
+ /// Configures the button to use system snooze activation when the button is clicked, using the default system snooze time.
+ ///
+ /// The current instance of
+ public ToastButton SetSnoozeActivation()
+ {
+ return SetSnoozeActivation(null);
+ }
+
+ ///
+ /// Configures the button to use system snooze activation when the button is clicked, with a snooze time defined by the specified selection box.
+ ///
+ /// The ID of an existing which allows the user to pick a custom snooze time. The ID's of the s inside the selection box must represent the snooze interval in minutes. For example, if the user selects an item that has an ID of "120", then the notification will be snoozed for 2 hours. When the user clicks this button, if you specified a SelectionBoxId, the system will parse the ID of the selected item and snooze by that amount of minutes.
+ /// The current instance of
+ public ToastButton SetSnoozeActivation(string selectionBoxId)
+ {
+ if (_arguments.Count > 0)
{
- TextBoxId = textBoxId;
- return this;
+ throw new InvalidOperationException($"{nameof(SetSnoozeActivation)} cannot be used in conjunction with ${nameof(AddArgument)}.");
}
- internal bool CanAddArguments()
+ _usingSnoozeActivation = true;
+ _snoozeSelectionBoxId = selectionBoxId;
+
+ return this;
+ }
+
+ ///
+ /// Configures the button to use system dismiss activation when the button is clicked (the toast will simply dismiss rather than activating).
+ ///
+ /// The current instance of
+ public ToastButton SetDismissActivation()
+ {
+ if (_arguments.Count > 0)
{
- return ActivationType != ToastActivationType.Protocol && !_usingCustomArguments && !_usingDismissActivation && !_usingSnoozeActivation;
+ throw new InvalidOperationException($"{nameof(SetDismissActivation)} cannot be used in conjunction with ${nameof(AddArgument)}.");
}
- internal bool ContainsArgument(string key)
+ _usingDismissActivation = true;
+ return this;
+ }
+
+ ///
+ /// Sets an identifier used in telemetry to identify your category of action. This should be something like "Delete", "Reply", or "Archive". In the upcoming toast telemetry dashboard in Dev Center, you will be able to view how frequently your actions are being clicked.
+ ///
+ /// An identifier used in telemetry to identify your category of action.
+ /// The current instance of
+ public ToastButton SetHintActionId(string actionId)
+ {
+ HintActionId = actionId;
+ return this;
+ }
+
+ ///
+ /// Sets an optional image icon for the button to display (required for buttons adjacent to inputs like quick reply).
+ ///
+ /// An optional image icon for the button to display.
+ /// The current instance of
+ public ToastButton SetImageUri(Uri imageUri)
+ {
+ ImageUri = imageUri.ToString();
+ return this;
+ }
+
+ ///
+ /// Sets the ID of an existing in order to have this button display to the right of the input, achieving a quick reply scenario.
+ ///
+ /// The ID of an existing .
+ /// The current instance of
+ public ToastButton SetTextBoxId(string textBoxId)
+ {
+ TextBoxId = textBoxId;
+ return this;
+ }
+
+ internal bool CanAddArguments()
+ {
+ return ActivationType != ToastActivationType.Protocol && !_usingCustomArguments && !_usingDismissActivation && !_usingSnoozeActivation;
+ }
+
+ internal bool ContainsArgument(string key)
+ {
+ return _arguments.ContainsKey(key);
+ }
+
+ internal Element_ToastAction ConvertToElement()
+ {
+ var el = new Element_ToastAction()
{
- return _arguments.ContainsKey(key);
- }
+ Content = Content,
+ ImageUri = ImageUri,
+ InputId = TextBoxId,
+ HintActionId = HintActionId
+ };
- internal Element_ToastAction ConvertToElement()
+ if (_usingSnoozeActivation)
{
- var el = new Element_ToastAction()
- {
- Content = Content,
- ImageUri = ImageUri,
- InputId = TextBoxId,
- HintActionId = HintActionId
- };
+ el.ActivationType = Element_ToastActivationType.System;
+ el.Arguments = "snooze";
- if (_usingSnoozeActivation)
+ if (_snoozeSelectionBoxId != null)
{
- el.ActivationType = Element_ToastActivationType.System;
- el.Arguments = "snooze";
-
- if (_snoozeSelectionBoxId != null)
- {
- el.InputId = _snoozeSelectionBoxId;
- }
-
- // Content needs to be specified as empty for auto-generated Snooze content
- if (el.Content == null)
- {
- el.Content = string.Empty;
- }
+ el.InputId = _snoozeSelectionBoxId;
}
- else if (_usingDismissActivation)
+
+ // Content needs to be specified as empty for auto-generated Snooze content
+ if (el.Content == null)
{
- el.ActivationType = Element_ToastActivationType.System;
- el.Arguments = "dismiss";
-
- // Content needs to be specified as empty for auto-generated Dismiss content
- if (el.Content == null)
- {
- el.Content = string.Empty;
- }
+ el.Content = string.Empty;
}
- else
+ }
+ else if (_usingDismissActivation)
+ {
+ el.ActivationType = Element_ToastActivationType.System;
+ el.Arguments = "dismiss";
+
+ // Content needs to be specified as empty for auto-generated Dismiss content
+ if (el.Content == null)
{
- el.ActivationType = Element_Toast.ConvertActivationType(ActivationType);
- el.Arguments = Arguments;
+ el.Content = string.Empty;
}
+ }
+ else
+ {
+ el.ActivationType = Element_Toast.ConvertActivationType(ActivationType);
+ el.Arguments = Arguments;
+ }
- ActivationOptions?.PopulateElement(el);
+ ActivationOptions?.PopulateElement(el);
- return el;
- }
+ return el;
}
}
diff --git a/components/Notifications/src/Toasts/ToastButtonDismiss.cs b/components/Notifications/src/Toasts/ToastButtonDismiss.cs
index 9a92683b5..e3df03cb1 100644
--- a/components/Notifications/src/Toasts/ToastButtonDismiss.cs
+++ b/components/Notifications/src/Toasts/ToastButtonDismiss.cs
@@ -4,64 +4,63 @@
using System;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// A button that, when clicked, is interpreted as a "dismiss" by the system, and the Toast is dismissed just like if the user swiped the Toast away.
+///
+public sealed class ToastButtonDismiss : IToastButton
{
///
- /// A button that, when clicked, is interpreted as a "dismiss" by the system, and the Toast is dismissed just like if the user swiped the Toast away.
+ /// Gets custom text displayed on the button that overrides the default localized "Dismiss" text.
///
- public sealed class ToastButtonDismiss : IToastButton
- {
- ///
- /// Gets custom text displayed on the button that overrides the default localized "Dismiss" text.
- ///
- public string CustomContent { get; private set; }
+ public string CustomContent { get; private set; }
- ///
- /// Gets or sets an optional image icon for the button to display.
- ///
- public string ImageUri { get; set; }
+ ///
+ /// Gets or sets an optional image icon for the button to display.
+ ///
+ public string ImageUri { get; set; }
- ///
- /// Gets or sets an identifier used in telemetry to identify your category of action. This should be something
- /// like "Delete", "Reply", or "Archive". In the upcoming toast telemetry dashboard in Dev Center, you will
- /// be able to view how frequently your actions are being clicked.
- ///
- public string HintActionId { get; set; }
+ ///
+ /// Gets or sets an identifier used in telemetry to identify your category of action. This should be something
+ /// like "Delete", "Reply", or "Archive". In the upcoming toast telemetry dashboard in Dev Center, you will
+ /// be able to view how frequently your actions are being clicked.
+ ///
+ public string HintActionId { get; set; }
- ///
- /// Initializes a new instance of the class.
- ///
- public ToastButtonDismiss()
- {
- }
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public ToastButtonDismiss()
+ {
+ }
- ///
- /// Initializes a new instance of the class.
- /// Constructs a system-handled dismiss button that displays your text on the button.
- ///
- /// The text you want displayed on the button.
- public ToastButtonDismiss(string customContent)
+ ///
+ /// Initializes a new instance of the class.
+ /// Constructs a system-handled dismiss button that displays your text on the button.
+ ///
+ /// The text you want displayed on the button.
+ public ToastButtonDismiss(string customContent)
+ {
+ if (customContent == null)
{
- if (customContent == null)
- {
- throw new ArgumentNullException(nameof(customContent));
- }
-
- CustomContent = customContent;
+ throw new ArgumentNullException(nameof(customContent));
}
- internal Element_ToastAction ConvertToElement()
+ CustomContent = customContent;
+ }
+
+ internal Element_ToastAction ConvertToElement()
+ {
+ return new Element_ToastAction()
{
- return new Element_ToastAction()
- {
- Content = this.CustomContent == null ? string.Empty : this.CustomContent, // If not using custom content, we need to provide empty string, otherwise Toast doesn't get displayed
- Arguments = "dismiss",
- ActivationType = Element_ToastActivationType.System,
- ImageUri = ImageUri,
- HintActionId = HintActionId
+ Content = this.CustomContent == null ? string.Empty : this.CustomContent, // If not using custom content, we need to provide empty string, otherwise Toast doesn't get displayed
+ Arguments = "dismiss",
+ ActivationType = Element_ToastActivationType.System,
+ ImageUri = ImageUri,
+ HintActionId = HintActionId
- // InputId is useless since dismiss button can't be placed to the right of text box (shell doesn't display it)
- };
- }
+ // InputId is useless since dismiss button can't be placed to the right of text box (shell doesn't display it)
+ };
}
}
\ No newline at end of file
diff --git a/components/Notifications/src/Toasts/ToastButtonSnooze.cs b/components/Notifications/src/Toasts/ToastButtonSnooze.cs
index f2f29283a..d9f33c574 100644
--- a/components/Notifications/src/Toasts/ToastButtonSnooze.cs
+++ b/components/Notifications/src/Toasts/ToastButtonSnooze.cs
@@ -4,74 +4,73 @@
using System;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// A system-handled snooze button that automatically handles snoozing of a Toast notification.
+///
+public sealed class ToastButtonSnooze : IToastButton
{
///
- /// A system-handled snooze button that automatically handles snoozing of a Toast notification.
+ /// Gets custom text displayed on the button that overrides the default localized "Snooze" text.
///
- public sealed class ToastButtonSnooze : IToastButton
- {
- ///
- /// Gets custom text displayed on the button that overrides the default localized "Snooze" text.
- ///
- public string CustomContent { get; private set; }
+ public string CustomContent { get; private set; }
- ///
- /// Gets or sets an optional image icon for the button to display.
- ///
- public string ImageUri { get; set; }
+ ///
+ /// Gets or sets an optional image icon for the button to display.
+ ///
+ public string ImageUri { get; set; }
- ///
- /// Gets or sets the ID of an existing in order to allow the
- /// user to pick a custom snooze time. Optional. The ID's of the s
- /// inside the selection box must represent the snooze interval in minutes. For example,
- /// if the user selects an item that has an ID of "120", then the notification will be snoozed
- /// for 2 hours. When the user clicks this button, if you specified a SelectionBoxId, the system
- /// will parse the ID of the selected item and snooze by that amount of minutes. If you didn't specify
- /// a SelectionBoxId, the system will snooze by the default system snooze time.
- ///
- public string SelectionBoxId { get; set; }
+ ///
+ /// Gets or sets the ID of an existing in order to allow the
+ /// user to pick a custom snooze time. Optional. The ID's of the s
+ /// inside the selection box must represent the snooze interval in minutes. For example,
+ /// if the user selects an item that has an ID of "120", then the notification will be snoozed
+ /// for 2 hours. When the user clicks this button, if you specified a SelectionBoxId, the system
+ /// will parse the ID of the selected item and snooze by that amount of minutes. If you didn't specify
+ /// a SelectionBoxId, the system will snooze by the default system snooze time.
+ ///
+ public string SelectionBoxId { get; set; }
- ///
- /// Gets or sets an identifier used in telemetry to identify your category of action. This should be something
- /// like "Delete", "Reply", or "Archive". In the upcoming toast telemetry dashboard in Dev Center, you will
- /// be able to view how frequently your actions are being clicked.
- ///
- public string HintActionId { get; set; }
+ ///
+ /// Gets or sets an identifier used in telemetry to identify your category of action. This should be something
+ /// like "Delete", "Reply", or "Archive". In the upcoming toast telemetry dashboard in Dev Center, you will
+ /// be able to view how frequently your actions are being clicked.
+ ///
+ public string HintActionId { get; set; }
- ///
- /// Initializes a new instance of the class.
- ///
- public ToastButtonSnooze()
- {
- }
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public ToastButtonSnooze()
+ {
+ }
- ///
- /// Initializes a new instance of the class.
- /// Initializes a system-handled snooze button that displays your text on the button and automatically handles snoozing.
- ///
- /// The text you want displayed on the button.
- public ToastButtonSnooze(string customContent)
+ ///
+ /// Initializes a new instance of the class.
+ /// Initializes a system-handled snooze button that displays your text on the button and automatically handles snoozing.
+ ///
+ /// The text you want displayed on the button.
+ public ToastButtonSnooze(string customContent)
+ {
+ if (customContent == null)
{
- if (customContent == null)
- {
- throw new ArgumentNullException(nameof(customContent));
- }
-
- CustomContent = customContent;
+ throw new ArgumentNullException(nameof(customContent));
}
- internal Element_ToastAction ConvertToElement()
+ CustomContent = customContent;
+ }
+
+ internal Element_ToastAction ConvertToElement()
+ {
+ return new Element_ToastAction()
{
- return new Element_ToastAction()
- {
- Content = CustomContent ?? string.Empty, // If not using custom content, we need to provide empty string, otherwise Toast doesn't get displayed
- Arguments = "snooze",
- ActivationType = Element_ToastActivationType.System,
- InputId = SelectionBoxId,
- ImageUri = ImageUri,
- HintActionId = HintActionId
- };
- }
+ Content = CustomContent ?? string.Empty, // If not using custom content, we need to provide empty string, otherwise Toast doesn't get displayed
+ Arguments = "snooze",
+ ActivationType = Element_ToastActivationType.System,
+ InputId = SelectionBoxId,
+ ImageUri = ImageUri,
+ HintActionId = HintActionId
+ };
}
}
\ No newline at end of file
diff --git a/components/Notifications/src/Toasts/ToastCommon.cs b/components/Notifications/src/Toasts/ToastCommon.cs
index 088ec6ca0..76f4937fe 100644
--- a/components/Notifications/src/Toasts/ToastCommon.cs
+++ b/components/Notifications/src/Toasts/ToastCommon.cs
@@ -2,42 +2,41 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// Decides the type of activation that will be used when the user interacts with the Toast notification.
+///
+public enum ToastActivationType
{
///
- /// Decides the type of activation that will be used when the user interacts with the Toast notification.
+ /// Default value. Your foreground app is launched.
///
- public enum ToastActivationType
- {
- ///
- /// Default value. Your foreground app is launched.
- ///
- Foreground,
+ Foreground,
- ///
- /// Your corresponding background task (assuming you set everything up) is triggered, and you can execute code in the background (like sending the user's quick reply message) without interrupting the user.
- ///
- Background,
+ ///
+ /// Your corresponding background task (assuming you set everything up) is triggered, and you can execute code in the background (like sending the user's quick reply message) without interrupting the user.
+ ///
+ Background,
- ///
- /// Launch a different app using protocol activation.
- ///
- Protocol
- }
+ ///
+ /// Launch a different app using protocol activation.
+ ///
+ Protocol
+}
+///
+/// Specifies the behavior that the toast should use when the user takes action on the toast.
+///
+public enum ToastAfterActivationBehavior
+{
///
- /// Specifies the behavior that the toast should use when the user takes action on the toast.
+ /// Default behavior. The toast will be dismissed when the user takes action on the toast.
///
- public enum ToastAfterActivationBehavior
- {
- ///
- /// Default behavior. The toast will be dismissed when the user takes action on the toast.
- ///
- Default,
+ Default,
- ///
- /// After the user clicks a button on your toast, the notification will remain present, in a "pending update" visual state. You should immediately update your toast from a background task so that the user does not see this "pending update" visual state for too long.
- ///
- PendingUpdate
- }
+ ///
+ /// After the user clicks a button on your toast, the notification will remain present, in a "pending update" visual state. You should immediately update your toast from a background task so that the user does not see this "pending update" visual state for too long.
+ ///
+ PendingUpdate
}
\ No newline at end of file
diff --git a/components/Notifications/src/Toasts/ToastContent.cs b/components/Notifications/src/Toasts/ToastContent.cs
index d361cca3e..a99d5674a 100644
--- a/components/Notifications/src/Toasts/ToastContent.cs
+++ b/components/Notifications/src/Toasts/ToastContent.cs
@@ -7,181 +7,180 @@
using Windows.Data.Xml.Dom;
using Windows.UI.Notifications;
-namespace CommunityToolkit.Notifications
+namespace CommunityToolkit.Notifications;
+
+///
+/// Base Toast element, which contains at least a visual element.
+///
+public sealed class ToastContent : INotificationContent
{
///
- /// Base Toast element, which contains at least a visual element.
+ /// Gets or sets the visual element (Required).
///
- public sealed class ToastContent : INotificationContent
- {
- ///
- /// Gets or sets the visual element (Required).
- ///
- public ToastVisual Visual { get; set; }
-
- ///
- /// Gets or sets custom audio options.
- ///
- public ToastAudio Audio { get; set; }
-
- ///
- /// Gets or sets optional custom actions with buttons and inputs (using )
- /// or optionally use the system-default snooze/dismiss controls (with ).
- ///
- public IToastActions Actions { get; set; }
-
- ///
- /// Gets or sets an optional header for the toast notification. Requires Creators Update
- ///
- public ToastHeader Header { get; set; }
-
- ///
- /// Gets or sets the scenario, to make the Toast behave like an alarm, reminder, or more.
- ///
- public ToastScenario Scenario { get; set; }
-
- ///
- /// Gets or sets the amount of time the Toast should display. You typically should use the
- /// Scenario attribute instead, which impacts how long a Toast stays on screen.
- ///
- public ToastDuration Duration { get; set; }
-
- ///
- /// Gets or sets a string that is passed to the application when it is activated by the Toast.
- /// The format and contents of this string are defined by the app for its own use. When the user
- /// taps or clicks the Toast to launch its associated app, the launch string provides the context
- /// to the app that allows it to show the user a view relevant to the Toast content, rather than
- /// launching in its default way.
- ///
- public string Launch { get; set; }
-
- ///
- /// Gets or sets what activation type will be used when the user clicks the body of this Toast.
- ///
- public ToastActivationType ActivationType { get; set; }
-
- ///
- /// Gets or sets additional options relating to activation of the toast notification. Requires Creators Updated
- ///
- public ToastActivationOptions ActivationOptions { get; set; }
-
- ///
- /// Gets or sets an optional custom time to use for the notification's timestamp, visible within Action Center.
- /// If provided, this date/time will be used on the notification instead of the date/time that the notification was received.
- /// Requires Creators Update
- ///
- public DateTimeOffset? DisplayTimestamp { get; set; }
-
- ///
- /// Gets or sets an identifier used in telemetry to identify your category of toast notification. This should be something
- /// like "NewMessage", "AppointmentReminder", "Promo30Off", or "PleaseRate". In the upcoming toast telemetry dashboard
- /// in Dev Center, you will be able to view activation info filtered by toast identifier.
- ///
- public string HintToastId { get; set; }
-
- ///
- /// Gets or sets the person that this toast is related to. For more info, see the My People documentation. New in Fall Creators Update.
- ///
- public ToastPeople HintPeople { get; set; }
-
- ///
- /// Gets a dictionary where you can assign additional properties.
- ///
- public IDictionary AdditionalProperties { get; } = new Dictionary();
-
- ///
- /// Retrieves the notification XML content as a string, so that it can be sent with a HTTP POST in a push notification.
- ///
- /// The notification XML content as a string.
- public string GetContent()
- {
- return ConvertToElement().GetContent();
- }
+ public ToastVisual Visual { get; set; }
+ ///
+ /// Gets or sets custom audio options.
+ ///
+ public ToastAudio Audio { get; set; }
- ///
- /// Retrieves the notification XML content as a WinRT XmlDocument, so that it can be used with a local Toast notification's constructor on either or .
- ///
- /// The notification XML content as a WinRT XmlDocument.
- public XmlDocument GetXml()
- {
- XmlDocument doc = new XmlDocument();
- doc.LoadXml(GetContent());
+ ///
+ /// Gets or sets optional custom actions with buttons and inputs (using )
+ /// or optionally use the system-default snooze/dismiss controls (with ).
+ ///
+ public IToastActions Actions { get; set; }
- return doc;
- }
+ ///
+ /// Gets or sets an optional header for the toast notification. Requires Creators Update
+ ///
+ public ToastHeader Header { get; set; }
- internal Element_Toast ConvertToElement()
- {
- if (ActivationOptions != null)
- {
- if (ActivationOptions.AfterActivationBehavior != ToastAfterActivationBehavior.Default)
- {
- throw new InvalidOperationException("ToastContent does not support a custom AfterActivationBehavior. Please ensure ActivationOptions.AfterActivationBehavior is set to Default.");
- }
- }
+ ///
+ /// Gets or sets the scenario, to make the Toast behave like an alarm, reminder, or more.
+ ///
+ public ToastScenario Scenario { get; set; }
- DateTimeOffset? strippedDisplayTimestamp = null;
- if (DisplayTimestamp != null)
- {
- // We need to make sure we don't include more than 3 decimal points on seconds
- // The Millisecond value itself is limited to 3 decimal points, thus by doing the following
- // we bypass the more granular value that can come from Ticks and ensure we only have 3 decimals at most.
- var val = DisplayTimestamp.Value;
- strippedDisplayTimestamp = new DateTimeOffset(val.Year, val.Month, val.Day, val.Hour, val.Minute, val.Second, val.Millisecond, val.Offset);
- }
+ ///
+ /// Gets or sets the amount of time the Toast should display. You typically should use the
+ /// Scenario attribute instead, which impacts how long a Toast stays on screen.
+ ///
+ public ToastDuration Duration { get; set; }
- var toast = new Element_Toast()
- {
- ActivationType = Element_Toast.ConvertActivationType(ActivationType),
- Duration = Duration,
- Launch = Launch,
- Scenario = Scenario,
- DisplayTimestamp = strippedDisplayTimestamp,
- HintToastId = HintToastId,
- AdditionalProperties = (Dictionary)AdditionalProperties
- };
-
- ActivationOptions?.PopulateElement(toast);
-
- if (Visual != null)
- {
- toast.Visual = Visual.ConvertToElement();
- }
+ ///
+ /// Gets or sets a string that is passed to the application when it is activated by the Toast.
+ /// The format and contents of this string are defined by the app for its own use. When the user
+ /// taps or clicks the Toast to launch its associated app, the launch string provides the context
+ /// to the app that allows it to show the user a view relevant to the Toast content, rather than
+ /// launching in its default way.
+ ///
+ public string Launch { get; set; }
- if (Audio != null)
- {
- toast.Audio = Audio.ConvertToElement();
- }
+ ///
+ /// Gets or sets what activation type will be used when the user clicks the body of this Toast.
+ ///
+ public ToastActivationType ActivationType { get; set; }
- if (Actions != null)
- {
- toast.Actions = ConvertToActionsElement(Actions);
- }
+ ///
+ /// Gets or sets additional options relating to activation of the toast notification. Requires Creators Updated
+ ///
+ public ToastActivationOptions ActivationOptions { get; set; }
+
+ ///
+ /// Gets or sets an optional custom time to use for the notification's timestamp, visible within Action Center.
+ /// If provided, this date/time will be used on the notification instead of the date/time that the notification was received.
+ /// Requires Creators Update
+ ///
+ public DateTimeOffset? DisplayTimestamp { get; set; }
+
+ ///
+ /// Gets or sets an identifier used in telemetry to identify your category of toast notification. This should be something
+ /// like "NewMessage", "AppointmentReminder", "Promo30Off", or "PleaseRate". In the upcoming toast telemetry dashboard
+ /// in Dev Center, you will be able to view activation info filtered by toast identifier.
+ ///
+ public string HintToastId { get; set; }
+
+ ///
+ /// Gets or sets the person that this toast is related to. For more info, see the My People documentation. New in Fall Creators Update.
+ ///
+ public ToastPeople HintPeople { get; set; }
+
+ ///
+ /// Gets a dictionary where you can assign additional properties.
+ ///
+ public IDictionary AdditionalProperties { get; } = new Dictionary