naps2/NAPS2.Lib/EtoForms/ActionCommand.cs

31 lines
623 B
C#
Raw Permalink Normal View History

2022-08-21 03:50:38 +03:00
using Eto.Forms;
namespace NAPS2.EtoForms;
public class ActionCommand : Command
{
public ActionCommand()
{
}
2022-08-21 03:50:38 +03:00
public ActionCommand(Action action) : base((sender, args) => action())
{
}
public ActionCommand(Func<Task> action) : base(async (sender, args) => await action())
{
}
public string Text
{
get => string.IsNullOrEmpty(ToolBarText) ? MenuText : ToolBarText;
set
{
ToolBarText = value;
MenuText = value;
TextChanged?.Invoke(this, EventArgs.Empty);
}
}
public event EventHandler? TextChanged;
2022-08-21 03:50:38 +03:00
}