naps2/NAPS2.Lib/EtoForms/ActionCommand.cs
2022-12-29 15:44:26 -08:00

31 lines
623 B
C#

using Eto.Forms;
namespace NAPS2.EtoForms;
public class ActionCommand : Command
{
public ActionCommand()
{
}
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;
}