lots of tidying up
This commit is contained in:
@@ -6,6 +6,7 @@ using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Configuration.Json;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.UI.Dispatching;
|
||||
using Microsoft.UI.Xaml;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
@@ -21,7 +22,6 @@ public partial class App :
|
||||
protected override async void OnLaunched(LaunchActivatedEventArgs args)
|
||||
{
|
||||
base.OnLaunched(args);
|
||||
|
||||
IHost? host = new HostBuilder()
|
||||
.UseContentRoot(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
|
||||
Assembly.GetEntryAssembly()?.GetName().Name!), true)
|
||||
@@ -32,10 +32,10 @@ public partial class App :
|
||||
.ConfigureServices((context, services) =>
|
||||
{
|
||||
services.AddDefault();
|
||||
|
||||
services.AddWidget();
|
||||
services.AddHostedService<AppService>();
|
||||
|
||||
services.AddSingleton<IDispatcher, Dispatcher>();
|
||||
services.AddSingleton<IDispatcher>(new Dispatcher(DispatcherQueue.GetForCurrentThread()));
|
||||
services.AddTransient<ITemplateFactory, TemplateFactory>();
|
||||
|
||||
services.AddHandler<AppConfigurationChangedHandler>();
|
||||
@@ -48,20 +48,26 @@ public partial class App :
|
||||
|
||||
services.AddSingleton<DesktopBar>();
|
||||
services.AddContentTemplate<WidgetBarViewModel, WidgetBarView>();
|
||||
services.AddContentTemplate<WidgetContainerViewModel, WidgetContainerView>();
|
||||
|
||||
services.AddTransient<IProxyServiceCollection<IWidgetBuilder>>(provider =>
|
||||
new ProxyServiceCollection<IWidgetBuilder>(services =>
|
||||
{
|
||||
services.AddSingleton<IDispatcher, Dispatcher>();
|
||||
services.AddTransient<ITemplateFactory, TemplateFactory>();
|
||||
services.AddScoped<IVirtualKeyboard, VirtualKeyboard>();
|
||||
services.AddSingleton<IDispatcher>(new Dispatcher(DispatcherQueue.GetForCurrentThread()));
|
||||
|
||||
services.AddTransient<IFactory<IWidgetHost, WidgetContainerViewModel?>,
|
||||
WidgetContainerFactory>();
|
||||
|
||||
services.AddTransient<ITemplateFactory, TemplateFactory>();
|
||||
|
||||
services.AddScoped<IVirtualKeyboard, VirtualKeyboard>();
|
||||
services.AddHandler<KeyAcceleratorHandler>();
|
||||
services.AddHandler<StartProcessHandler>();
|
||||
|
||||
services.AddHandler<WidgetViewModelEnumerator>();
|
||||
|
||||
services.AddTransient<IWidgetView, WidgetView>();
|
||||
|
||||
services.AddContentTemplate<WidgetContainerViewModel, WidgetContainerView>();
|
||||
services.AddContentTemplate<WidgetButtonViewModel, WidgetButtonView>();
|
||||
services.AddContentTemplate<WidgetSplitButtonViewModel, WidgetSplitButtonView>();
|
||||
}));
|
||||
|
||||
@@ -3,12 +3,9 @@ using Microsoft.UI.Dispatching;
|
||||
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
public class Dispatcher :
|
||||
public class Dispatcher(DispatcherQueue dispatcherQueue) :
|
||||
IDispatcher
|
||||
{
|
||||
private DispatcherQueue dispatcherQueue;
|
||||
|
||||
public Dispatcher() => dispatcherQueue = DispatcherQueue.GetForCurrentThread();
|
||||
|
||||
public async Task InvokeAsync(Action action) => await dispatcherQueue.EnqueueAsync(action.Invoke);
|
||||
public async Task InvokeAsync(Action action) =>
|
||||
await dispatcherQueue.EnqueueAsync(action.Invoke);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
x:Class="Hyperbar.Windows.WidgetContainerView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:interactions="using:Microsoft.Xaml.Interactions.Core"
|
||||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:ui="using:Hyperbar.Windows.UI">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
@@ -10,7 +12,7 @@
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Rectangle
|
||||
Width="10"
|
||||
Width="1"
|
||||
Height="40"
|
||||
Margin="6,2,6,2"
|
||||
Fill="Red" />
|
||||
@@ -23,6 +25,11 @@
|
||||
<StackPanel Orientation="Horizontal" />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<interactions:EventTriggerBehavior EventName="Loaded">
|
||||
<interactions:InvokeCommandAction Command="{Binding Initialize}" />
|
||||
</interactions:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</ItemsControl>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@@ -3,17 +3,26 @@
|
||||
x:Class="Hyperbar.Windows.WidgetView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:interactions="using:Microsoft.Xaml.Interactions.Core"
|
||||
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
|
||||
xmlns:ui="using:Hyperbar.Windows.UI">
|
||||
<ItemsControl ItemTemplateSelector="{Binding Converter={ui:DataTemplateConverter}}" ItemsSource="{Binding}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Orientation="Horizontal" Spacing="8" />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemContainerTransitions>
|
||||
<TransitionCollection>
|
||||
<AddDeleteThemeTransition />
|
||||
</TransitionCollection>
|
||||
</ItemsControl.ItemContainerTransitions>
|
||||
</ItemsControl>
|
||||
<Grid>
|
||||
<ItemsControl ItemTemplateSelector="{Binding Converter={ui:DataTemplateConverter}}" ItemsSource="{Binding Mode=TwoWay}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Orientation="Horizontal" Spacing="8" />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemContainerTransitions>
|
||||
<TransitionCollection>
|
||||
<AddDeleteThemeTransition />
|
||||
</TransitionCollection>
|
||||
</ItemsControl.ItemContainerTransitions>
|
||||
<interactivity:Interaction.Behaviors>
|
||||
<interactions:EventTriggerBehavior EventName="Loaded">
|
||||
<interactions:InvokeCommandAction Command="{Binding Initialize}" />
|
||||
</interactions:EventTriggerBehavior>
|
||||
</interactivity:Interaction.Behaviors>
|
||||
</ItemsControl>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
Reference in New Issue
Block a user