wired up key commands
This commit is contained in:
@@ -40,8 +40,8 @@ public partial class App :
|
||||
services.AddTransient<DesktopFlyout>();
|
||||
services.AddContentTemplate<CommandViewModel, CommandView>();
|
||||
|
||||
services.AddWidget<ContextualWidgetBuilder>();
|
||||
services.AddWidget<PrimaryWidgetBuilder>();
|
||||
services.AddWidgetProvider<ContextualWidgetProvider>();
|
||||
services.AddWidgetProvider<PrimaryWidgetProvider>();
|
||||
|
||||
services.AddTransient(provider =>
|
||||
{
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
using Hyperbar.Windows.Win32;
|
||||
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
public class KeyAcceleratorCommandHandler(IVirtualKeyboard virtualKeyboard) :
|
||||
ICommandHandler<KeyAcceleratorCommand>
|
||||
{
|
||||
public ValueTask<Unit> Handle(KeyAcceleratorCommand command,
|
||||
CancellationToken cancellationToken)
|
||||
{ virtualKeyboard.Send((int)command.Key);
|
||||
return default;
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
|
||||
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
|
||||
<RootNamespace>Hyperbar.Windows</RootNamespace>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<Platforms>x86;x64;ARM64</Platforms>
|
||||
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Hyperbar.Extensions;
|
||||
using Hyperbar.Windows.Win32;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
@@ -6,17 +7,21 @@ namespace Hyperbar.Windows
|
||||
{
|
||||
public static class IServiceCollectionExtensions
|
||||
{
|
||||
public static IServiceCollection AddWidget<TCommandBuilder>(this IServiceCollection services)
|
||||
where TCommandBuilder :
|
||||
IWidgetBuilder, new()
|
||||
public static IServiceCollection AddWidgetProvider<TWidgetProvider>(this IServiceCollection services)
|
||||
where TWidgetProvider :
|
||||
IWidgetProvider, new()
|
||||
{
|
||||
TCommandBuilder builder = new();
|
||||
TWidgetProvider builder = new();
|
||||
IHost? host = new HostBuilder()
|
||||
.ConfigureServices(isolatedServices =>
|
||||
{
|
||||
|
||||
isolatedServices.AddSingleton<IServiceFactory>(provider =>
|
||||
new ServiceFactory((type, parameters) => ActivatorUtilities.CreateInstance(provider, type, parameters!)));
|
||||
|
||||
isolatedServices.AddSingleton<IVirtualKeyboard, VirtualKeyboard>();
|
||||
|
||||
isolatedServices.AddSingleton<IMediator, Mediator>();
|
||||
isolatedServices.AddHandler<KeyAcceleratorCommandHandler>();
|
||||
|
||||
isolatedServices.AddTransient<IWidgetView, WidgetView>();
|
||||
isolatedServices.AddContentTemplate<WidgetButtonViewModel, WidgetButtonView>();
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
public class KeyAcceleratorCommandHandler :
|
||||
ICommandHandler<KeyAcceleratorCommand>
|
||||
{
|
||||
public ValueTask<Unit> Handle(KeyAcceleratorCommand command,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user