init
This commit is contained in:
10
Common/DTS.Common/Interactivity/Confirmation.cs
Normal file
10
Common/DTS.Common/Interactivity/Confirmation.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
7
Common/DTS.Common/Interactivity/IConfirmation.cs
Normal file
7
Common/DTS.Common/Interactivity/IConfirmation.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace DTS.Common.Interactivity
|
||||
{
|
||||
public interface IConfirmation : INotification
|
||||
{
|
||||
bool Confirmed { get; set; }
|
||||
}
|
||||
}
|
||||
9
Common/DTS.Common/Interactivity/IInteractionRequest.cs
Normal file
9
Common/DTS.Common/Interactivity/IInteractionRequest.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
|
||||
namespace DTS.Common.Interactivity
|
||||
{
|
||||
public interface IInteractionRequest
|
||||
{
|
||||
event EventHandler<InteractionRequestedEventArgs> Raised;
|
||||
}
|
||||
}
|
||||
17
Common/DTS.Common/Interactivity/IInteractionRequestAware.cs
Normal file
17
Common/DTS.Common/Interactivity/IInteractionRequestAware.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
15
Common/DTS.Common/Interactivity/INotification.cs
Normal file
15
Common/DTS.Common/Interactivity/INotification.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
38
Common/DTS.Common/Interactivity/InteractionRequest.cs
Normal file
38
Common/DTS.Common/Interactivity/InteractionRequest.cs
Normal 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); }));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
16
Common/DTS.Common/Interactivity/InteractionRequestTrigger.cs
Normal file
16
Common/DTS.Common/Interactivity/InteractionRequestTrigger.cs
Normal 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";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
}
|
||||
}
|
||||
9
Common/DTS.Common/Interactivity/Notification.cs
Normal file
9
Common/DTS.Common/Interactivity/Notification.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace DTS.Common.Interactivity
|
||||
{
|
||||
public class Notification : INotification
|
||||
{
|
||||
public string Title { get; set; }
|
||||
|
||||
public object Content { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user