3 using System.Windows.Input;
5 namespace SiliconStudio.Presentation.
Commands
7 internal class SystemCommand : ICommand
9 private readonly Func<Window, bool> canExecute;
10 private readonly Action<Window> execute;
12 internal SystemCommand(Func<Window, bool> canExecute, Action<Window> execute)
14 if (canExecute == null)
throw new ArgumentNullException(
"canExecute");
15 if (execute == null)
throw new ArgumentNullException(
"execute");
16 this.canExecute = canExecute;
17 this.execute = execute;
20 public bool CanExecute(
object parameter)
22 var window = parameter as
Window;
23 return window != null && canExecute(window);
26 public void Execute(
object parameter)
28 var window = parameter as
Window;
29 if (window == null)
throw new ArgumentException(
string.Format(
"The parameter of this command must be an instance of 'Window'."));
33 public event EventHandler CanExecuteChanged;