Files
Hyperbar/Hyperbar.Windows.Primary/WidgetComponentMapping.cs
T
2024-01-07 22:37:54 +00:00

20 lines
751 B
C#

namespace Hyperbar.Windows.Primary;
public class WidgetComponentMapping(PrimaryWidgetConfiguration configuration,
IServiceFactory service,
IMediator mediator) :
IMappingHandler<PrimaryWidgetConfiguration, IEnumerable<IWidgetComponentViewModel>>
{
public IEnumerable<IWidgetComponentViewModel> Handle()
{
foreach (IPrimaryCommandConfiguration item in configuration)
{
if (item is KeyAcceleratorCommandConfiguration keyAcceleratorCommand)
{
yield return service.Create<WidgetButtonViewModel>(keyAcceleratorCommand.Icon, new Action(async () =>
await mediator.SendAsync(new KeyAcceleratorCommand(VirtualKey.LeftWindows))));
}
}
}
}