UI threading work
This commit is contained in:
@@ -39,14 +39,17 @@ public partial class App :
|
||||
services.AddSingleton<IDisposer, Disposer>();
|
||||
|
||||
services.AddHostedService<AppService>();
|
||||
services.AddConfiguration<AppConfiguration>();
|
||||
|
||||
services.AddTransient<IInitializer, AppInitializer>();
|
||||
services.AddTransient<ITemplateFactory, TemplateFactory>();
|
||||
|
||||
services.AddTransient<DesktopFlyout>();
|
||||
services.AddSingleton<DesktopFlyout>();
|
||||
|
||||
services.AddContentTemplate<WidgetBarViewModel, WidgetBarView>();
|
||||
|
||||
services.AddHandler<AppConfigurationChangedHandler>();
|
||||
|
||||
//services.AddWidgetProvider<MediaControllerWidgetProvider>();
|
||||
services.AddWidgetProvider<PrimaryWidgetProvider>();
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
using Hyperbar.Windows.Controls;
|
||||
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
public class AppConfiguration
|
||||
{
|
||||
public DesktopFlyoutPlacement Placement { get; set; }
|
||||
}
|
||||
@@ -5,14 +5,15 @@ namespace Hyperbar.Windows;
|
||||
|
||||
public class AppInitializer([FromKeyedServices(nameof(WidgetBarViewModel))] WidgetBarView view,
|
||||
[FromKeyedServices(nameof(WidgetBarViewModel))] WidgetBarViewModel viewModel,
|
||||
DesktopFlyout desktopFlyout) :
|
||||
DesktopFlyout desktopFlyout,
|
||||
AppConfiguration configuration) :
|
||||
IInitializer
|
||||
{
|
||||
public Task InitializeAsync()
|
||||
{
|
||||
view.DataContext = viewModel;
|
||||
|
||||
desktopFlyout.Placement = DesktopFlyoutPlacement.Top;
|
||||
desktopFlyout.Placement = configuration.Placement;
|
||||
desktopFlyout.Content = view;
|
||||
|
||||
return Task.CompletedTask;
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using Hyperbar.Windows.Controls;
|
||||
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
|
||||
public class AppConfigurationChangedHandler(DesktopFlyout desktopFlyout,
|
||||
AppConfiguration configuration) :
|
||||
INotificationHandler<ConfigurationChanged<AppConfiguration>>
|
||||
{
|
||||
public ValueTask Handle(ConfigurationChanged<AppConfiguration> notification, CancellationToken cancellationToken)
|
||||
{
|
||||
desktopFlyout.Placement = configuration.Placement;
|
||||
return ValueTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user