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