Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
CommandElement.cs
1using System.Windows.Input;
2
4{
5 internal static class CommandElement
6 {
7 public static void OnCommandChanging(BindableObject bo, object o, object _)
8 {
9 ICommandElement CommandElement = (ICommandElement)bo;
10
11 if (o is ICommand OldCommand)
12 OldCommand.CanExecuteChanged -= CommandElement.CanExecuteChanged;
13 }
14
15 public static void OnCommandChanged(BindableObject bo, object _, object n)
16 {
17 ICommandElement CommandElement = (ICommandElement)bo;
18
19 if (n is ICommand NewCommand)
20 NewCommand.CanExecuteChanged += CommandElement.CanExecuteChanged;
21
22 CommandElement.CanExecuteChanged(bo, EventArgs.Empty);
23 }
24
25 public static void OnCommandParameterChanged(BindableObject bo, object _, object __)
26 {
27 ICommandElement CommandElement = (ICommandElement)bo;
28
29 CommandElement.CanExecuteChanged(bo, EventArgs.Empty);
30 }
31
32 public static bool GetCanExecute(ICommandElement CommandElement)
33 {
34 if (CommandElement.Command == null)
35 return true;
36
37 return CommandElement.Command.CanExecute(CommandElement.CommandParameter);
38 }
39 }
40}