fixed fetching configuration from root
This commit is contained in:
@@ -5,6 +5,6 @@ public class PrimaryWidgetConfiguration :
|
|||||||
{
|
{
|
||||||
public static PrimaryWidgetConfiguration Defaults => new()
|
public static PrimaryWidgetConfiguration Defaults => new()
|
||||||
{
|
{
|
||||||
new KeyAcceleratorCommandConfiguration { Icon = "Test", Key = "Test", Modifiers = ["Test", "Test"] }
|
new KeyAcceleratorCommandConfiguration { Icon = "\uE720", Key = "Test", Modifiers = ["Test", "Test"] }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -5,21 +5,26 @@ public class WidgetComponentMappingFactory :
|
|||||||
{
|
{
|
||||||
private readonly PrimaryWidgetConfiguration configuration;
|
private readonly PrimaryWidgetConfiguration configuration;
|
||||||
private readonly IServiceFactory service;
|
private readonly IServiceFactory service;
|
||||||
|
private readonly IMediator mediator;
|
||||||
|
|
||||||
public WidgetComponentMappingFactory(PrimaryWidgetConfiguration configuration,
|
public WidgetComponentMappingFactory(PrimaryWidgetConfiguration configuration,
|
||||||
IServiceFactory service)
|
IServiceFactory service,
|
||||||
|
IMediator mediator)
|
||||||
{
|
{
|
||||||
this.configuration = configuration;
|
this.configuration = configuration;
|
||||||
this.service = service;
|
this.service = service;
|
||||||
|
this.mediator = mediator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<IWidgetComponentViewModel> Create()
|
public IEnumerable<IWidgetComponentViewModel> Create()
|
||||||
{
|
{
|
||||||
foreach (IPrimaryCommandConfiguration item in configuration)
|
foreach (IPrimaryCommandConfiguration item in configuration)
|
||||||
{
|
{
|
||||||
|
if (item is KeyAcceleratorCommandConfiguration keyAcceleratorCommand)
|
||||||
|
{
|
||||||
|
yield return service.Create<WidgetButtonViewModel>(keyAcceleratorCommand.Icon, new Action(() =>
|
||||||
|
mediator.Send(new KeyAcceleratorCommand(VirtualKey.LeftWindows))));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Enumerable.Empty<IWidgetComponentViewModel>();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
using Hyperbar.Extensions;
|
using Hyperbar.Extensions;
|
||||||
using Hyperbar.Windows.Interop;
|
using Hyperbar.Windows.Interop;
|
||||||
using Hyperbar.Windows.Primary;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
|
|
||||||
namespace Hyperbar.Windows
|
namespace Hyperbar.Windows
|
||||||
{
|
{
|
||||||
@@ -45,11 +43,8 @@ namespace Hyperbar.Windows
|
|||||||
builder.Create(context, isolatedServices);
|
builder.Create(context, isolatedServices);
|
||||||
}).Build();
|
}).Build();
|
||||||
|
|
||||||
|
|
||||||
services.AddTransient<IWidgetContext>(provider => new WidgetContext(host.Services));
|
services.AddTransient<IWidgetContext>(provider => new WidgetContext(host.Services));
|
||||||
host.Start();
|
services.AddTransient(provider => host);
|
||||||
|
|
||||||
var d = host.Services.GetService<IOptionsMonitor<PrimaryWidgetConfiguration>>();
|
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,12 +9,15 @@
|
|||||||
<SolidColorBrush x:Key="ButtonBorderBrushPointerOver" Color="Transparent" />
|
<SolidColorBrush x:Key="ButtonBorderBrushPointerOver" Color="Transparent" />
|
||||||
<SolidColorBrush x:Key="ButtonBorderBrushPressed" Color="Transparent" />
|
<SolidColorBrush x:Key="ButtonBorderBrushPressed" Color="Transparent" />
|
||||||
<SolidColorBrush x:Key="ButtonBorderBrushDisabled" 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="ButtonWidth">32</x:Double>
|
||||||
<x:Double x:Key="ButtonHeight">32</x:Double>
|
<x:Double x:Key="ButtonHeight">32</x:Double>
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
<Button
|
<Button
|
||||||
Width="{StaticResource ButtonWidth}"
|
Width="{StaticResource ButtonWidth}"
|
||||||
Height="{StaticResource ButtonHeight}"
|
Height="{StaticResource ButtonHeight}"
|
||||||
|
Padding="0"
|
||||||
Command="{Binding Click}"
|
Command="{Binding Click}"
|
||||||
Content="{Binding Icon}" />
|
Content="{Binding Icon}"
|
||||||
|
FontFamily="{StaticResource SymbolThemeFontFamily}" />
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@@ -106,8 +106,9 @@ public static class IServiceCollectionExtensions
|
|||||||
{
|
{
|
||||||
services.Configure<TConfiguration>(configuration);
|
services.Configure<TConfiguration>(configuration);
|
||||||
services.AddSingleton<IConfigureOptions<TConfiguration>>(new ConfigureNamedOptions<TConfiguration>("", args => { }));
|
services.AddSingleton<IConfigureOptions<TConfiguration>>(new ConfigureNamedOptions<TConfiguration>("", args => { }));
|
||||||
services.AddTransient(provider => provider.GetService<IOptionsMonitor<TConfiguration>>()!.CurrentValue);
|
services.AddTransient(provider => {
|
||||||
|
|
||||||
|
return provider.GetService<IOptionsMonitor<TConfiguration>>()!.CurrentValue; });
|
||||||
|
|
||||||
services.AddSingleton<IConfigurationWriter<TConfiguration>>(provider =>
|
services.AddSingleton<IConfigurationWriter<TConfiguration>>(provider =>
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user