Init
This commit is contained in:
33
Command/CommandViewModel.cs
Normal file
33
Command/CommandViewModel.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Input;
|
||||
using System.Text;
|
||||
using TradeBlotter.ViewModels;
|
||||
|
||||
namespace TradeBlotter.Command
|
||||
{
|
||||
public class CommandViewModel : ViewModelBase
|
||||
{
|
||||
public CommandViewModel(string displayName, ICommand command)
|
||||
{
|
||||
if (command == null) throw new ArgumentNullException("command");
|
||||
base.DisplayName = displayName;
|
||||
this.Command = command;
|
||||
}
|
||||
public ICommand Command
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
public override SaveParameters GetSaveParameters()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
public override void SetSaveParameters(SaveParameters saveParameters)
|
||||
{
|
||||
}
|
||||
public override bool CanPersist()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
44
Command/RelayCommand.cs
Normal file
44
Command/RelayCommand.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Input;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
|
||||
namespace TradeBlotter.Command
|
||||
{
|
||||
public class RelayCommand : ICommand
|
||||
{
|
||||
readonly Action<object> execute;
|
||||
readonly Predicate<object> canExecute;
|
||||
public RelayCommand(Action<object> execute)
|
||||
: this(execute, null)
|
||||
{
|
||||
}
|
||||
public RelayCommand(Action<object> execute, Predicate<object> canExecute)
|
||||
{
|
||||
if (execute == null) throw new ArgumentNullException("execute");
|
||||
this.execute = execute;
|
||||
this.canExecute = canExecute;
|
||||
}
|
||||
[DebuggerStepThrough]
|
||||
public bool CanExecute(object parameter)
|
||||
{
|
||||
return canExecute == null ? true : canExecute(parameter);
|
||||
}
|
||||
public event EventHandler CanExecuteChanged
|
||||
{
|
||||
add
|
||||
{
|
||||
CommandManager.RequerySuggested += value;
|
||||
}
|
||||
remove
|
||||
{
|
||||
CommandManager.RequerySuggested -= value;
|
||||
}
|
||||
}
|
||||
public void Execute(object parameter)
|
||||
{
|
||||
execute(parameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user