This commit is contained in:
Frank Skare
2021-06-22 19:10:27 +02:00
parent 6634ef094c
commit bac8b2b96c
15 changed files with 363 additions and 271 deletions

27
src/WPF/RelayCommand.cs Normal file
View File

@@ -0,0 +1,27 @@

using System;
using System.Windows.Input;
namespace mpvnet
{
public class RelayCommand : ICommand
{
public event EventHandler CanExecuteChanged;
Action<object> ExecuteAction;
Predicate<object> CanExecutePredicate;
public RelayCommand(Action<object> executeAction, Predicate<object> canExecutePredicate = null)
{
ExecuteAction = executeAction;
CanExecutePredicate = canExecutePredicate;
}
public bool CanExecute(object parameter) => CanExecutePredicate == null || CanExecutePredicate(parameter);
public void Execute(object parameter) => ExecuteAction(parameter);
public void OnCanExecuteChanged() => CanExecuteChanged?.Invoke(this, EventArgs.Empty);
}
}