-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNullaryCommand.cs
36 lines (28 loc) · 1010 Bytes
/
NullaryCommand.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
namespace pocketmodise {
using System;
using System.Windows.Input;
public class NullaryCommand : ICommand {
public event EventHandler CanExecuteChanged;
private readonly Action executeAction;
private readonly Func<bool> canExecutePredicate;
public NullaryCommand(Action executeAction, Func<bool> canExecutePredicate) {
this.executeAction = executeAction;
this.canExecutePredicate = canExecutePredicate;
}
public bool CanExecute(object parameter) {
return canExecutePredicate();
}
public void Execute(object parameter) {
executeAction();
}
public void RaiseCanExecuteChanged() {
OnCanExecuteChanged();
}
private void OnCanExecuteChanged() {
if (CanExecuteChanged == null) {
return;
}
CanExecuteChanged(this, EventArgs.Empty);
}
}
}