5 using SiliconStudio.Presentation.Services;
6 using SiliconStudio.Presentation.ViewModel;
8 namespace SiliconStudio.Presentation.
Commands
16 private readonly Func<bool> canExecute;
17 private readonly Action<object> action;
25 : base(serviceProvider)
28 throw new ArgumentNullException(
"action");
30 this.action = x => action();
40 : base(serviceProvider)
42 this.canExecute = canExecute;
44 throw new ArgumentNullException(
"action");
46 this.action = x => action();
55 : base(serviceProvider)
58 throw new ArgumentNullException(
"action");
70 : base(serviceProvider)
73 throw new ArgumentNullException(
"action");
76 this.canExecute = canExecute;
84 public override void Execute(
object parameter)
97 var result = base.CanExecute(parameter);
98 return result && canExecute != null ? canExecute() : result;
109 private readonly Action<T> action;
110 private readonly Func<bool> canExecute;
118 : base(serviceProvider)
120 this.action = action;
130 : base(serviceProvider)
132 this.action = action;
133 this.canExecute = canExecute;
140 public override void Execute(
object parameter)
142 if ((typeof(T).IsValueType || parameter != null) && !(parameter is T))
143 throw new ArgumentException(
@"Unexpected parameter type in the command.",
"parameter");
145 action((T)parameter);
156 var result = base.CanExecute(parameter);
157 return result && canExecute != null ? canExecute() : result;
AnonymousCommand(IViewModelServiceProvider serviceProvider, Action< object > action, Func< bool > canExecute)
Initializes a new instance of the AnonymousCommand class.
An implementation of CommandBase that route Execute calls to a given anonymous method.
override void Execute(object parameter)
Executes the command, and thus the anonymous method provided to the constructor.
AnonymousCommand(IViewModelServiceProvider serviceProvider, Action< T > action)
Initializes a new instance of the AnonymousCommand{T} class.
A service provider class for view model objects.
override bool CanExecute(object parameter)
Indicates whether the command can be executed. Returns true if CommandBase.IsEnabled is true and eith...
AnonymousCommand(IViewModelServiceProvider serviceProvider, Action< object > action)
Initializes a new instance of the AnonymousCommand class.
override bool CanExecute(object parameter)
Indicates whether the command can be executed. Returns true if CommandBase.IsEnabled is true and eith...
AnonymousCommand(IViewModelServiceProvider serviceProvider, Action action)
Initializes a new instance of the AnonymousCommand class.
AnonymousCommand(IViewModelServiceProvider serviceProvider, Action< T > action, Func< bool > canExecute)
Initializes a new instance of the AnonymousCommand{T} class.
override void Execute(object parameter)
Executes the command, and thus the anonymous method provided to the constructor.
An abstract class that is the base implementation of the ICommandBase interface.
AnonymousCommand(IViewModelServiceProvider serviceProvider, Action action, Func< bool > canExecute)
Initializes a new instance of the AnonymousCommand class.