Multi-Platform Package Manager for Stable Diffusion
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
using Avalonia.Input;
|
|
|
|
|
|
|
|
namespace StabilityMatrix.Avalonia.Extensions;
|
|
|
|
|
|
|
|
public static class DataObjectExtensions
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Get Context from IDataObject, set by Xaml Behaviors
|
|
|
|
/// </summary>
|
|
|
|
public static T? GetContext<T>(this IDataObject dataObject)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if (dataObject.Get("Context") is T context)
|
|
|
|
{
|
|
|
|
return context;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (COMException)
|
|
|
|
{
|
|
|
|
return default;
|
|
|
|
}
|
|
|
|
|
|
|
|
return default;
|
|
|
|
}
|
|
|
|
}
|