2018-05-24 01:12:18 +03:00
|
|
|
// 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.
|
2016-10-01 13:31:33 +03:00
|
|
|
|
2016-09-16 13:24:00 +03:00
|
|
|
using System;
|
2016-07-13 00:13:36 +03:00
|
|
|
|
2021-03-19 01:31:02 +03:00
|
|
|
namespace CommunityToolkit.WinUI.Notifications
|
2016-07-13 00:13:36 +03:00
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// A system-handled snooze button that automatically handles snoozing of a Toast notification.
|
|
|
|
/// </summary>
|
|
|
|
public sealed class ToastButtonSnooze : IToastButton
|
|
|
|
{
|
|
|
|
/// <summary>
|
2017-10-11 08:43:33 +03:00
|
|
|
/// Gets custom text displayed on the button that overrides the default localized "Snooze" text.
|
2016-07-13 00:13:36 +03:00
|
|
|
/// </summary>
|
|
|
|
public string CustomContent { get; private set; }
|
|
|
|
|
2017-05-08 23:03:11 +03:00
|
|
|
/// <summary>
|
2017-10-11 08:43:33 +03:00
|
|
|
/// Gets or sets an optional image icon for the button to display.
|
2017-05-08 23:03:11 +03:00
|
|
|
/// </summary>
|
|
|
|
public string ImageUri { get; set; }
|
|
|
|
|
2016-07-13 00:13:36 +03:00
|
|
|
/// <summary>
|
2017-10-11 08:43:33 +03:00
|
|
|
/// Gets or sets the ID of an existing <see cref="ToastSelectionBox"/> in order to allow the
|
|
|
|
/// user to pick a custom snooze time. Optional. The ID's of the <see cref="ToastSelectionBoxItem"/>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.
|
2016-07-13 00:13:36 +03:00
|
|
|
/// </summary>
|
|
|
|
public string SelectionBoxId { get; set; }
|
|
|
|
|
2018-01-18 21:13:50 +03:00
|
|
|
/// <summary>
|
|
|
|
/// 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.
|
|
|
|
/// </summary>
|
|
|
|
public string HintActionId { get; set; }
|
|
|
|
|
2016-07-13 00:13:36 +03:00
|
|
|
/// <summary>
|
2017-10-11 08:43:33 +03:00
|
|
|
/// Initializes a new instance of the <see cref="ToastButtonSnooze"/> class.
|
2016-07-13 00:13:36 +03:00
|
|
|
/// </summary>
|
|
|
|
public ToastButtonSnooze()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
2017-10-11 08:43:33 +03:00
|
|
|
/// Initializes a new instance of the <see cref="ToastButtonSnooze"/> class.
|
2016-07-13 00:13:36 +03:00
|
|
|
/// Initializes a system-handled snooze button that displays your text on the button and automatically handles snoozing.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="customContent">The text you want displayed on the button.</param>
|
|
|
|
public ToastButtonSnooze(string customContent)
|
|
|
|
{
|
|
|
|
if (customContent == null)
|
|
|
|
{
|
2016-09-16 13:27:04 +03:00
|
|
|
throw new ArgumentNullException(nameof(customContent));
|
2016-07-13 00:13:36 +03:00
|
|
|
}
|
|
|
|
|
2016-10-18 23:36:38 +03:00
|
|
|
CustomContent = customContent;
|
2016-07-13 00:13:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
internal Element_ToastAction ConvertToElement()
|
|
|
|
{
|
|
|
|
return new Element_ToastAction()
|
2018-01-18 21:13:50 +03:00
|
|
|
{
|
|
|
|
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
|
|
|
|
};
|
2016-07-13 00:13:36 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|