2024-12-27 08:22:17 +03:00
|
|
|
using System.Windows.Input;
|
|
|
|
|
|
2025-01-05 17:05:23 +03:00
|
|
|
namespace Nebula.Shared.Utils;
|
2024-12-27 08:22:17 +03:00
|
|
|
|
|
|
|
|
public class DelegateCommand<T> : ICommand
|
|
|
|
|
{
|
|
|
|
|
private readonly Action<T> _func;
|
|
|
|
|
public readonly Ref<T> TRef = new();
|
|
|
|
|
|
|
|
|
|
public DelegateCommand(Action<T> func)
|
|
|
|
|
{
|
|
|
|
|
_func = func;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool CanExecute(object? parameter)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Execute(object? parameter)
|
|
|
|
|
{
|
|
|
|
|
_func(TRef.Value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public event EventHandler? CanExecuteChanged;
|
|
|
|
|
}
|