using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Input; namespace SPC.Kiosk.Base { /// /// Commad Interfase Implementation /// public class Command : ICommand { private readonly Action _handler; private bool _isEnabled; /// /// Set Commad Handler /// /// public Command(Action handler) { _handler = handler; IsEnabled = true; } /// /// CanExecut Is Enabled /// public bool IsEnabled { get { return _isEnabled; } set { if (value != _isEnabled) { _isEnabled = value; CanExecuteChanged?.Invoke(this, EventArgs.Empty); } } } /// /// CanExecute Status Return /// /// /// public bool CanExecute(object parameter) { return IsEnabled; } /// /// CanExecuteChanged EventHandler /// public event EventHandler CanExecuteChanged; /// /// Execute with parameter /// /// public void Execute(object parameter) { IsEnabled = false; _handler(parameter); IsEnabled = true; } /// /// Execute with out parameter /// public void Execute() { IsEnabled = false; _handler(null); IsEnabled = true; } } }