Rip out Microsoft's configuration and replace because it simply doesn't support polymorphism.... we are getting advanced boys!!!
This commit is contained in:
@@ -4,8 +4,10 @@ using Hyperbar.Windows.Primary;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.UI.Dispatching;
|
||||
using Microsoft.UI.Xaml;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
@@ -18,8 +20,7 @@ public partial class App :
|
||||
{
|
||||
base.OnLaunched(args);
|
||||
|
||||
var context = new DispatcherQueueSynchronizationContext(
|
||||
DispatcherQueue.GetForCurrentThread());
|
||||
DispatcherQueueSynchronizationContext context = new(DispatcherQueue.GetForCurrentThread());
|
||||
SynchronizationContext.SetSynchronizationContext(context);
|
||||
|
||||
IHost? host = Host.CreateDefaultBuilder()
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Hyperbar.Windows
|
||||
|
||||
isolatedServices.AddSingleton<IMediator, Mediator>();
|
||||
isolatedServices.AddHandler<KeyAcceleratorHandler>();
|
||||
|
||||
isolatedServices.AddHandler<ProcesssAcceleratorHandler>();
|
||||
isolatedServices.AddTransient<IWidgetView, WidgetView>();
|
||||
isolatedServices.AddContentTemplate<WidgetButtonViewModel, WidgetButtonView>();
|
||||
|
||||
|
||||
@@ -1,14 +1,26 @@
|
||||
using Hyperbar.Windows.Interop;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
public class KeyAcceleratorHandler(IVirtualKeyboard virtualKeyboard) :
|
||||
IRequestHandler<KeyAcceleratorCommand>
|
||||
IRequestHandler<KeyAcceleratorRequest>
|
||||
{
|
||||
public ValueTask<Unit> Handle(KeyAcceleratorCommand command,
|
||||
public ValueTask<Unit> Handle(KeyAcceleratorRequest request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
virtualKeyboard.Send((int)command.Key);
|
||||
{
|
||||
virtualKeyboard.Send((int)request.Key, request.Modifiers?.Select(modifier => (int)modifier).ToArray() ?? []);
|
||||
return default;
|
||||
}
|
||||
}
|
||||
|
||||
public class ProcesssAcceleratorHandler :
|
||||
IRequestHandler<ProcessRequest>
|
||||
{
|
||||
public ValueTask<Unit> Handle(ProcessRequest request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
Process.Start(request.Process);
|
||||
return default;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,13 +10,14 @@
|
||||
<SolidColorBrush x:Key="ButtonBorderBrushPressed" Color="Transparent" />
|
||||
<SolidColorBrush x:Key="ButtonBorderBrushDisabled" Color="Transparent" />
|
||||
<Thickness x:Key="ButtonPadding">0</Thickness>
|
||||
<x:Double x:Key="ButtonWidth">32</x:Double>
|
||||
<x:Double x:Key="ButtonHeight">32</x:Double>
|
||||
<x:Double x:Key="ButtonWidth">40</x:Double>
|
||||
<x:Double x:Key="ButtonHeight">40</x:Double>
|
||||
</UserControl.Resources>
|
||||
<Button
|
||||
Width="{StaticResource ButtonWidth}"
|
||||
Height="{StaticResource ButtonHeight}"
|
||||
Padding="0"
|
||||
Padding="{StaticResource ButtonPadding}"
|
||||
FontSize="16"
|
||||
Command="{Binding Click}"
|
||||
Content="{Binding Icon}"
|
||||
FontFamily="{StaticResource SymbolThemeFontFamily}" />
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Input;
|
||||
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
@@ -6,5 +7,13 @@ public sealed partial class WidgetView :
|
||||
UserControl,
|
||||
IWidgetView
|
||||
{
|
||||
public WidgetView() => InitializeComponent();
|
||||
public WidgetView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnKeyDown(KeyRoutedEventArgs e)
|
||||
{
|
||||
base.OnKeyDown(e);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user