30 lines
769 B
C#
30 lines
769 B
C#
using System;
|
|
using System.Windows.Input;
|
|
|
|
namespace NotifyIconWpf.Sample.Windowless
|
|
{
|
|
/// <summary>
|
|
/// Simplistic delegate command for the demo.
|
|
/// </summary>
|
|
public class DelegateCommand : ICommand
|
|
{
|
|
public Action CommandAction { get; set; }
|
|
public Func<bool> CanExecuteFunc { get; set; }
|
|
|
|
public void Execute(object parameter)
|
|
{
|
|
CommandAction();
|
|
}
|
|
|
|
public bool CanExecute(object parameter)
|
|
{
|
|
return CanExecuteFunc == null || CanExecuteFunc();
|
|
}
|
|
|
|
public event EventHandler CanExecuteChanged
|
|
{
|
|
add { CommandManager.RequerySuggested += value; }
|
|
remove { CommandManager.RequerySuggested -= value; }
|
|
}
|
|
}
|
|
} |