| 1 | using System; |
| 2 | using System.Collections.Generic; |
| 3 | using System.Linq; |
| 4 | using System.Text; |
| 5 | using System.Threading.Tasks; |
| 6 | using System.Windows.Input; |
| 7 | |
| 8 | namespace UI.Controls |
| 9 | { |
| 10 | public class Command : ICommand |
| 11 | { |
| 12 | private Action<object> _action; |
| 13 | |
| 14 | public Command(Action<object> action) |
| 15 | { |
| 16 | _action = action; |
| 17 | } |
| 18 | |
| 19 | |
| 20 | #region ICommand Members |
| 21 | public bool CanExecute(object parameter) |
| 22 | { |
| 23 | return true; |
| 24 | } |
| 25 | public event EventHandler CanExecuteChanged; |
| 26 | public void Execute(object parameter) |
| 27 | { |
| 28 | _action(parameter); |
| 29 | OnExecuted(); |
| 30 | } |
| 31 | public delegate void ExecutedHandler(object parameter); |
| 32 | public event ExecutedHandler Executed; |
| 33 | public void OnExecuted() |
| 34 | { |
| 35 | Executed?.Invoke(null); |
| 36 | } |
| 37 | #endregion |
| 38 | } |
| 39 | } |