Files
AddinManager/AddInManager/RelayCommand.cs

32 lines
786 B
C#
Raw Normal View History

2025-09-04 09:53:20 +08:00
using System;
using System.Windows.Input;
namespace AddInManager
{
internal class RelayCommand : ICommand
{
private Action<object> execute;
private Func<object, bool> canExecute;
public event EventHandler CanExecuteChanged;
public RelayCommand(Action<object> execute, Func<object, bool> canExecute = null)
{
if (execute == null)
throw new System.ArgumentNullException();
this.execute = execute;
this.canExecute = canExecute;
}
public bool CanExecute(object parameter)
{
return canExecute == null || canExecute(parameter);
}
public void Execute(object parameter)
{
execute(parameter);
}
}
}