ChartingCommand.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows.Input;
  6. namespace Aitex.UI.Charting.Command
  7. {
  8. /// <summary>
  9. ///
  10. /// </summary>
  11. public class ChartingCommand : ICommand
  12. {
  13. public ChartingCommand(Predicate<object> CanExecute , Action<object> Execute)
  14. {
  15. _canExecute = CanExecute;
  16. _execute = Execute;
  17. }
  18. Predicate<object> _canExecute;
  19. Action<object> _execute;
  20. /// <summary>
  21. ///
  22. /// </summary>
  23. /// <param name="parameter"></param>
  24. /// <returns></returns>
  25. public bool CanExecute(object parameter)
  26. {
  27. if (_canExecute != null)
  28. return _canExecute.Invoke(parameter);
  29. return true;
  30. }
  31. #pragma warning disable 0067
  32. public event EventHandler CanExecuteChanged;
  33. #pragma warning restore 0067
  34. public void Execute(object parameter)
  35. {
  36. if (_execute != null)
  37. _execute.Invoke(parameter);
  38. }
  39. }
  40. }