58 lines
1.2 KiB
C#
58 lines
1.2 KiB
C#
using System;
|
|
using System.Windows.Input;
|
|
|
|
namespace 电子展板.Base
|
|
{
|
|
public class DelegateCommand : ICommand
|
|
{
|
|
public Action<object> ExecuteCommand = null;
|
|
|
|
public event EventHandler CanExecuteChanged;
|
|
|
|
public DelegateCommand(DelegateCommand focusAdjustToCommand)
|
|
{
|
|
}
|
|
|
|
public DelegateCommand(Action<object> Command)
|
|
{
|
|
ExecuteCommand = Command;
|
|
}
|
|
|
|
public bool CanExecute(object paramter)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public void Execute(object paramter)
|
|
{
|
|
ExecuteCommand?.Invoke(paramter);
|
|
}
|
|
}
|
|
|
|
public class DelegateCommand<T> : ICommand
|
|
{
|
|
public Action<T> ExecuteCommand = null;
|
|
|
|
public event EventHandler CanExecuteChanged;
|
|
|
|
public DelegateCommand()
|
|
{
|
|
}
|
|
|
|
public DelegateCommand(Action<T> Command)
|
|
{
|
|
ExecuteCommand = Command;
|
|
}
|
|
|
|
public bool CanExecute(object paramter)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public void Execute(object paramter)
|
|
{
|
|
ExecuteCommand?.Invoke((T)paramter);
|
|
}
|
|
}
|
|
}
|