2022-01-27 13:40:04 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
|
|
|
|
|
namespace MSFSPopoutPanelManager.WpfApp.ViewModel
|
|
|
|
|
{
|
|
|
|
|
public class DelegateCommand : ICommand
|
|
|
|
|
{
|
|
|
|
|
private readonly Action<object> _executeAction;
|
|
|
|
|
private readonly Func<object, bool> _canExecuteAction;
|
|
|
|
|
|
|
|
|
|
public DelegateCommand(Action<object> executeAction, Func<object, bool> canExecuteAction)
|
|
|
|
|
{
|
|
|
|
|
_executeAction = executeAction;
|
|
|
|
|
_canExecuteAction = canExecuteAction;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Execute(object parameter) => _executeAction(parameter);
|
|
|
|
|
|
|
|
|
|
public bool CanExecute(object parameter) => _canExecuteAction?.Invoke(parameter) ?? true;
|
|
|
|
|
|
|
|
|
|
public event EventHandler CanExecuteChanged;
|
|
|
|
|
|
|
|
|
|
public void InvokeCanExecuteChanged() => CanExecuteChanged?.Invoke(this, EventArgs.Empty);
|
|
|
|
|
}
|
2022-06-30 23:53:08 +00:00
|
|
|
|
}
|