main
1using System;
2
3namespace presentation.windows
4{
5 public class SimpleCommand : IObservableCommand
6 {
7 Action action = () => {};
8 Func<bool> predicate;
9
10 public SimpleCommand(Action action) : this(action, () => true) {}
11
12 public SimpleCommand(Action action, Func<bool> predicate)
13 {
14 this.action = action ?? (() => {});
15 this.predicate = predicate ?? (() => true);
16 }
17
18 public event EventHandler CanExecuteChanged = (o, e) => {};
19
20 public void Execute(object parameter)
21 {
22 action();
23 }
24
25 public bool CanExecute(object parameter)
26 {
27 return predicate();
28 }
29
30 public void notify_observers()
31 {
32 CanExecuteChanged(this, EventArgs.Empty);
33 }
34 }
35}