This commit is contained in:
2026-04-17 14:55:32 -04:00
commit bc3ac1d4c9
18017 changed files with 4371742 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
namespace DTS.Common.Interactivity
{
public class Confirmation : Notification, IConfirmation
{
/// <summary>
/// Gets or sets a value indicating that the confirmation is confirmed.
/// </summary>
public bool Confirmed { get; set; }
}
}

View File

@@ -0,0 +1,7 @@
namespace DTS.Common.Interactivity
{
public interface IConfirmation : INotification
{
bool Confirmed { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
using System;
namespace DTS.Common.Interactivity
{
public interface IInteractionRequest
{
event EventHandler<InteractionRequestedEventArgs> Raised;
}
}

View File

@@ -0,0 +1,17 @@
using System;
namespace DTS.Common.Interactivity
{
public interface IInteractionRequestAware
{
/// <summary>
/// The <see cref="INotification"/> passed when the interaction request was raised.
/// </summary>
INotification Notification { get; set; }
/// <summary>
/// An <see cref="Action"/> that can be invoked to finish the interaction.
/// </summary>
Action FinishInteraction { get; set; }
}
}

View File

@@ -0,0 +1,15 @@
namespace DTS.Common.Interactivity
{
public interface INotification
{
/// <summary>
/// Gets or sets the title to use for the notification.
/// </summary>
string Title { get; set; }
/// <summary>
/// Gets or sets the content of the notification.
/// </summary>
object Content { get; set; }
}
}

View File

@@ -0,0 +1,38 @@
using System;
namespace DTS.Common.Interactivity
{
public class InteractionRequest<T> : IInteractionRequest
where T : INotification
{
/// <summary>
/// Fired when interaction is needed.
/// </summary>
public event EventHandler<InteractionRequestedEventArgs> Raised;
/// <summary>
/// Fires the Raised event.
/// </summary>
/// <param name="context">The context for the interaction request.</param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1030:UseEventsWhereAppropriate")]
public void Raise(T context)
{
Raise(context, c => { });
}
/// <summary>
/// Fires the Raised event.
/// </summary>
/// <param name="context">The context for the interaction request.</param>
/// <param name="callback">The callback to execute when the interaction is completed.</param>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1030:UseEventsWhereAppropriate")]
public void Raise(T context, Action<T> callback)
{
var handler = Raised;
if (handler != null)
{
handler(this, new InteractionRequestedEventArgs(context, () => { if (callback != null) callback(context); }));
}
}
}
}

View File

@@ -0,0 +1,16 @@
using Microsoft.Xaml.Behaviors;
namespace DTS.Common.Interactivity
{
public class InteractionRequestTrigger : EventTrigger
{
/// <summary>
/// Specifies the name of the Event this EventTriggerBase is listening for.
/// </summary>
/// <returns>This implementation always returns the Raised event name for ease of connection with <see cref="IInteractionRequest"/>.</returns>
protected override string GetEventName()
{
return "Raised";
}
}
}

View File

@@ -0,0 +1,28 @@
using System;
namespace DTS.Common.Interactivity
{
public class InteractionRequestedEventArgs : EventArgs
{
/// <summary>
/// Constructs a new instance of <see cref="InteractionRequestedEventArgs"/>
/// </summary>
/// <param name="context"></param>
/// <param name="callback"></param>
public InteractionRequestedEventArgs(INotification context, Action callback)
{
Context = context;
Callback = callback;
}
/// <summary>
/// Gets the context for a requested interaction.
/// </summary>
public INotification Context { get; private set; }
/// <summary>
/// Gets the callback to execute when an interaction is completed.
/// </summary>
public Action Callback { get; private set; }
}
}

View File

@@ -0,0 +1,9 @@
namespace DTS.Common.Interactivity
{
public class Notification : INotification
{
public string Title { get; set; }
public object Content { get; set; }
}
}