using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Input; namespace Aitex.UI.RecipeEditor { public class DelegatedCommand : ICommand { public DelegatedCommand(Predicate CanExecute, Action Execute) { _canExecute = CanExecute; _execute = Execute; } Predicate _canExecute; Action _execute; /// /// /// /// /// public bool CanExecute(object parameter) { if (_canExecute != null) return _canExecute.Invoke(parameter); return true; } public event EventHandler CanExecuteChanged; public void Execute(object parameter) { if (_execute != null) _execute.Invoke(parameter); } public void RaiseCanExecuteChanged() { if (CanExecuteChanged != null) CanExecuteChanged(this, EventArgs.Empty); } } }