mirror of
https://github.com/ShrlAlgo/AddinManager.git
synced 2026-03-07 16:38:56 +00:00
32 lines
786 B
C#
32 lines
786 B
C#
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);
|
|
}
|
|
}
|
|
} |