tidy up
This commit is contained in:
@@ -8,9 +8,11 @@ public class TemplateFactory(IEnumerable<IContentTemplateDescriptor> descriptors
|
|||||||
{
|
{
|
||||||
public object? Create(object key)
|
public object? Create(object key)
|
||||||
{
|
{
|
||||||
if (descriptors.FirstOrDefault(x => x.Key == key) is IContentTemplateDescriptor descriptor)
|
if (descriptors.FirstOrDefault(x => x.Key == key)
|
||||||
|
is IContentTemplateDescriptor descriptor)
|
||||||
{
|
{
|
||||||
if (provider.GetRequiredKeyedService(descriptor.TemplateType, descriptor.Key) is { } template)
|
if (provider.GetRequiredKeyedService(descriptor.TemplateType,
|
||||||
|
descriptor.Key) is { } template)
|
||||||
{
|
{
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,12 @@ using Hyperbar.UI.Windows;
|
|||||||
|
|
||||||
namespace Hyperbar.Widget.MediaController.Windows;
|
namespace Hyperbar.Widget.MediaController.Windows;
|
||||||
|
|
||||||
public sealed partial class MediaButtonView :
|
public partial class MediaButtonView :
|
||||||
UserControl
|
UserControl
|
||||||
{
|
{
|
||||||
public MediaButtonView() =>
|
public MediaButtonView() =>
|
||||||
this.InitializeComponent(ref _contentLoaded);
|
this.InitializeComponent(ref _contentLoaded);
|
||||||
|
|
||||||
private IMediaButtonViewModel ViewModel => (IMediaButtonViewModel)DataContext;
|
protected IMediaButtonViewModel ViewModel =>
|
||||||
|
(IMediaButtonViewModel)DataContext;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ namespace Hyperbar.Widget.MediaController.Windows;
|
|||||||
public class MediaControllerHandler(IMediator mediator,
|
public class MediaControllerHandler(IMediator mediator,
|
||||||
IServiceScopeProvider<MediaController> scopeProvider,
|
IServiceScopeProvider<MediaController> scopeProvider,
|
||||||
ICache<MediaController, MediaControllerViewModel> cache) :
|
ICache<MediaController, MediaControllerViewModel> cache) :
|
||||||
INotificationHandler<Created<MediaController>>,
|
INotificationHandler<Create<MediaController>>,
|
||||||
INotificationHandler<Removed<MediaController>>
|
INotificationHandler<Remove<MediaController>>
|
||||||
{
|
{
|
||||||
public async Task Handle(Created<MediaController> notification,
|
public async Task Handle(Create<MediaController> notification,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (notification.Value is MediaController mediaController &&
|
if (notification.Value is MediaController mediaController &&
|
||||||
@@ -18,17 +18,17 @@ public class MediaControllerHandler(IMediator mediator,
|
|||||||
factory.Create(mediaController) is MediaControllerViewModel viewModel)
|
factory.Create(mediaController) is MediaControllerViewModel viewModel)
|
||||||
{
|
{
|
||||||
cache.Add(mediaController, viewModel);
|
cache.Add(mediaController, viewModel);
|
||||||
await mediator.PublishAsync(new Created<MediaControllerViewModel>(viewModel), cancellationToken);
|
await mediator.PublishAsync(new Create<MediaControllerViewModel>(viewModel), cancellationToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Handle(Removed<MediaController> notification, CancellationToken cancellationToken)
|
public async Task Handle(Remove<MediaController> notification, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (notification.Value is MediaController mediaController &&
|
if (notification.Value is MediaController mediaController &&
|
||||||
cache.TryGetValue(mediaController, out MediaControllerViewModel? viewModel) &&
|
cache.TryGetValue(mediaController, out MediaControllerViewModel? viewModel) &&
|
||||||
viewModel is not null)
|
viewModel is not null)
|
||||||
{
|
{
|
||||||
await mediator.PublishAsync(new Removed<MediaControllerViewModel>(viewModel), cancellationToken);
|
await mediator.PublishAsync(new Remove<MediaControllerViewModel>(viewModel), cancellationToken);
|
||||||
cache.Remove(mediaController);
|
cache.Remove(mediaController);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class MediaControllerService(IMediator mediator,
|
|||||||
{
|
{
|
||||||
if (factory.Create(session) is MediaController mediaController)
|
if (factory.Create(session) is MediaController mediaController)
|
||||||
{
|
{
|
||||||
await mediator.PublishAsync(new Created<MediaController>(mediaController));
|
await mediator.PublishAsync(new Create<MediaController>(mediaController));
|
||||||
cache.Add(new KeyValuePair<GlobalSystemMediaTransportControlsSession, MediaController>(session,
|
cache.Add(new KeyValuePair<GlobalSystemMediaTransportControlsSession, MediaController>(session,
|
||||||
mediaController));
|
mediaController));
|
||||||
}
|
}
|
||||||
@@ -53,7 +53,7 @@ public class MediaControllerService(IMediator mediator,
|
|||||||
{
|
{
|
||||||
if (!sessions.Any(x => x.SourceAppUserModelId == session.Key.SourceAppUserModelId))
|
if (!sessions.Any(x => x.SourceAppUserModelId == session.Key.SourceAppUserModelId))
|
||||||
{
|
{
|
||||||
await mediator.PublishAsync(new Removed<MediaController>(session.Value));
|
await mediator.PublishAsync(new Remove<MediaController>(session.Value));
|
||||||
cache.Remove(session);
|
cache.Remove(session);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
HorizontalAlignment="Right"
|
HorizontalAlignment="Right"
|
||||||
HorizontalContentAlignment="Right"
|
HorizontalContentAlignment="Right"
|
||||||
ItemTemplateSelector="{Binding Converter={windows:DataTemplateConverter}}"
|
ItemTemplateSelector="{Binding Converter={windows:DataTemplateConverter}}"
|
||||||
ItemsSource="{Binding}">
|
ItemsSource="{x:Bind ViewModel}">
|
||||||
<ItemsControl.ItemsPanel>
|
<ItemsControl.ItemsPanel>
|
||||||
<ItemsPanelTemplate>
|
<ItemsPanelTemplate>
|
||||||
<StackPanel Orientation="Horizontal" Spacing="8" />
|
<StackPanel Orientation="Horizontal" Spacing="8" />
|
||||||
|
|||||||
@@ -3,9 +3,12 @@ using Hyperbar.UI.Windows;
|
|||||||
|
|
||||||
namespace Hyperbar.Widget.MediaController.Windows;
|
namespace Hyperbar.Widget.MediaController.Windows;
|
||||||
|
|
||||||
public sealed partial class MediaControllerView :
|
public partial class MediaControllerView :
|
||||||
UserControl
|
UserControl
|
||||||
{
|
{
|
||||||
public MediaControllerView() =>
|
public MediaControllerView() =>
|
||||||
this.InitializeComponent(ref _contentLoaded);
|
this.InitializeComponent(ref _contentLoaded);
|
||||||
|
|
||||||
|
protected MediaControllerViewModel ViewModel =>
|
||||||
|
(MediaControllerViewModel)DataContext;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,12 @@ using Hyperbar.UI.Windows;
|
|||||||
|
|
||||||
namespace Hyperbar.Widget.MediaController.Windows;
|
namespace Hyperbar.Widget.MediaController.Windows;
|
||||||
|
|
||||||
public sealed partial class MediaControllerWidgetView :
|
public partial class MediaControllerWidgetView :
|
||||||
UserControl
|
UserControl
|
||||||
{
|
{
|
||||||
public MediaControllerWidgetView() =>
|
public MediaControllerWidgetView() =>
|
||||||
this.InitializeComponent(ref _contentLoaded);
|
this.InitializeComponent(ref _contentLoaded);
|
||||||
|
|
||||||
|
protected MediaControllerWidgetViewModel ViewModel =>
|
||||||
|
(MediaControllerWidgetViewModel)DataContext;
|
||||||
}
|
}
|
||||||
@@ -3,11 +3,12 @@ using Hyperbar.UI.Windows;
|
|||||||
|
|
||||||
namespace Hyperbar.Widget.MediaController.Windows;
|
namespace Hyperbar.Widget.MediaController.Windows;
|
||||||
|
|
||||||
public sealed partial class MediaInformationView :
|
public partial class MediaInformationView :
|
||||||
UserControl
|
UserControl
|
||||||
{
|
{
|
||||||
public MediaInformationView() =>
|
public MediaInformationView() =>
|
||||||
this.InitializeComponent(ref _contentLoaded);
|
this.InitializeComponent(ref _contentLoaded);
|
||||||
|
|
||||||
private MediaInformationViewModel ViewModel => (MediaInformationViewModel)DataContext;
|
protected MediaInformationViewModel ViewModel =>
|
||||||
|
(MediaInformationViewModel)DataContext;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class PrimaryWidgetConfigurationHandler(IMediator mediator,
|
|||||||
if (moved.Value is PrimaryCommandConfiguration configuration &&
|
if (moved.Value is PrimaryCommandConfiguration configuration &&
|
||||||
provider.Get(configuration) is IWidgetComponentViewModel viewModel)
|
provider.Get(configuration) is IWidgetComponentViewModel viewModel)
|
||||||
{
|
{
|
||||||
await mediator.PublishAsync(new Moved<IWidgetComponentViewModel>(configuration.Order, viewModel),
|
await mediator.PublishAsync(new Move<IWidgetComponentViewModel>(configuration.Order, viewModel),
|
||||||
moved.Key.ParentId == Guid.Empty ? nameof(PrimaryWidgetViewModel) : moved.Key.ParentId,
|
moved.Key.ParentId == Guid.Empty ? nameof(PrimaryWidgetViewModel) : moved.Key.ParentId,
|
||||||
cancellationToken);
|
cancellationToken);
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ public class PrimaryWidgetConfigurationHandler(IMediator mediator,
|
|||||||
factory.Create(configuration) is IWidgetComponentViewModel viewModel)
|
factory.Create(configuration) is IWidgetComponentViewModel viewModel)
|
||||||
{
|
{
|
||||||
await mediator.PublishAsync(
|
await mediator.PublishAsync(
|
||||||
new Inserted<IWidgetComponentViewModel>(configuration.Order, viewModel),
|
new Insert<IWidgetComponentViewModel>(configuration.Order, viewModel),
|
||||||
added.Key.ParentId == Guid.Empty ? nameof(PrimaryWidgetViewModel) : added.Key.ParentId,
|
added.Key.ParentId == Guid.Empty ? nameof(PrimaryWidgetViewModel) : added.Key.ParentId,
|
||||||
cancellationToken);
|
cancellationToken);
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ public class PrimaryWidgetConfigurationHandler(IMediator mediator,
|
|||||||
provider.Get(configuration) is IWidgetComponentViewModel viewModel)
|
provider.Get(configuration) is IWidgetComponentViewModel viewModel)
|
||||||
{
|
{
|
||||||
await mediator.PublishAsync(
|
await mediator.PublishAsync(
|
||||||
new Removed<IWidgetComponentViewModel>(viewModel),
|
new Remove<IWidgetComponentViewModel>(viewModel),
|
||||||
removed.Key.ParentId == Guid.Empty ? nameof(PrimaryWidgetViewModel) : removed.Key.ParentId,
|
removed.Key.ParentId == Guid.Empty ? nameof(PrimaryWidgetViewModel) : removed.Key.ParentId,
|
||||||
cancellationToken);
|
cancellationToken);
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class WidgetComponentViewModelEnumerator(PrimaryWidgetConfiguration confi
|
|||||||
{
|
{
|
||||||
if (factory.Create(item) is IWidgetComponentViewModel viewModel)
|
if (factory.Create(item) is IWidgetComponentViewModel viewModel)
|
||||||
{
|
{
|
||||||
await mediator.PublishAsync(new Created<IWidgetComponentViewModel>(viewModel), nameof(PrimaryWidgetViewModel),
|
await mediator.PublishAsync(new Create<IWidgetComponentViewModel>(viewModel), nameof(PrimaryWidgetViewModel),
|
||||||
cancellationToken);
|
cancellationToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public class WidgetExtensionEnumerator(IFactory<Type, IWidget> factory,
|
|||||||
{
|
{
|
||||||
if (factory.Create(widgetType) is IWidget widget)
|
if (factory.Create(widgetType) is IWidget widget)
|
||||||
{
|
{
|
||||||
await mediator.PublishAsync(new Created<WidgetExtension>(new WidgetExtension(widget,
|
await mediator.PublishAsync(new Create<WidgetExtension>(new WidgetExtension(widget,
|
||||||
new WidgetAssembly(assembly))), cancellationToken);
|
new WidgetAssembly(assembly))), cancellationToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ namespace Hyperbar.Widget;
|
|||||||
public class WidgetExtensionHandler(IServiceProvider provider,
|
public class WidgetExtensionHandler(IServiceProvider provider,
|
||||||
IMediator mediator,
|
IMediator mediator,
|
||||||
IProxyServiceCollection<IWidgetBuilder> typedServices) :
|
IProxyServiceCollection<IWidgetBuilder> typedServices) :
|
||||||
INotificationHandler<Created<WidgetExtension>>
|
INotificationHandler<Create<WidgetExtension>>
|
||||||
{
|
{
|
||||||
public async Task Handle(Created<WidgetExtension> notification,
|
public async Task Handle(Create<WidgetExtension> notification,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if(notification.Value is WidgetExtension widgetExtension)
|
if(notification.Value is WidgetExtension widgetExtension)
|
||||||
@@ -22,7 +22,7 @@ public class WidgetExtensionHandler(IServiceProvider provider,
|
|||||||
});
|
});
|
||||||
|
|
||||||
IWidgetHost host = builder.Build();
|
IWidgetHost host = builder.Build();
|
||||||
await mediator.PublishAsync(new Created<IWidgetHost>(host),
|
await mediator.PublishAsync(new Create<IWidgetHost>(host),
|
||||||
cancellationToken);
|
cancellationToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
namespace Hyperbar.Widget;
|
namespace Hyperbar.Widget;
|
||||||
|
|
||||||
public class WidgetHostHandler :
|
public class WidgetHostHandler :
|
||||||
INotificationHandler<Created<IWidgetHost>>
|
INotificationHandler<Create<IWidgetHost>>
|
||||||
{
|
{
|
||||||
public async Task Handle(Created<IWidgetHost> notification,
|
public async Task Handle(Create<IWidgetHost> notification,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (notification.Value is IWidgetHost host)
|
if (notification.Value is IWidgetHost host)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ public class WidgetStartedHandler(IMediator mediator) :
|
|||||||
{
|
{
|
||||||
if (host.Services.GetService<IWidgetViewModel>() is IWidgetViewModel viewModel)
|
if (host.Services.GetService<IWidgetViewModel>() is IWidgetViewModel viewModel)
|
||||||
{
|
{
|
||||||
await mediator.PublishAsync(new Created<IWidgetViewModel>(viewModel),
|
await mediator.PublishAsync(new Create<IWidgetViewModel>(viewModel),
|
||||||
nameof(IWidgetHostViewModel), cancellationToken);
|
nameof(IWidgetHostViewModel), cancellationToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public class WidgetViewModelEnumerator(IWidgetHost host,
|
|||||||
{
|
{
|
||||||
foreach (IWidgetViewModel viewModel in viewModels)
|
foreach (IWidgetViewModel viewModel in viewModels)
|
||||||
{
|
{
|
||||||
await mediator.PublishAsync(new Created<IWidgetViewModel>(viewModel),
|
await mediator.PublishAsync(new Create<IWidgetViewModel>(viewModel),
|
||||||
nameof(IWidgetHostViewModel), cancellationToken);
|
nameof(IWidgetHostViewModel), cancellationToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ public partial class App :
|
|||||||
services.AddContentTemplate<SecondaryViewModel, SecondaryView>();
|
services.AddContentTemplate<SecondaryViewModel, SecondaryView>();
|
||||||
|
|
||||||
services.AddContentTemplate<SettingsButtonViewModel, SettingsButtonView>();
|
services.AddContentTemplate<SettingsButtonViewModel, SettingsButtonView>();
|
||||||
|
services.AddContentTemplate<SettingsView, SettingsView>("Settings");
|
||||||
|
|
||||||
services.AddTransient<IInitializer, AppInitializer>();
|
services.AddTransient<IInitializer, AppInitializer>();
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
<ItemsControl
|
<ItemsControl
|
||||||
Margin="6,0,6,0"
|
Margin="6,0,6,0"
|
||||||
ItemTemplateSelector="{Binding Converter={windows:DataTemplateConverter}}"
|
ItemTemplateSelector="{Binding Converter={windows:DataTemplateConverter}}"
|
||||||
ItemsSource="{Binding}">
|
ItemsSource="{x:Bind ViewModel, Mode=OneWay}">
|
||||||
<ItemsControl.ItemsPanel>
|
<ItemsControl.ItemsPanel>
|
||||||
<ItemsPanelTemplate>
|
<ItemsPanelTemplate>
|
||||||
<Grid>
|
<Grid>
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
|
using Hyperbar.Widget;
|
||||||
using Microsoft.UI.Xaml.Controls;
|
using Microsoft.UI.Xaml.Controls;
|
||||||
|
|
||||||
namespace Hyperbar.Windows;
|
namespace Hyperbar.Windows;
|
||||||
|
|
||||||
public sealed partial class ApplicationBarView :
|
public partial class ApplicationBarView :
|
||||||
UserControl
|
UserControl
|
||||||
{
|
{
|
||||||
public ApplicationBarView() => InitializeComponent();
|
public ApplicationBarView() =>
|
||||||
|
InitializeComponent();
|
||||||
|
protected ApplicationBarViewModel ViewModel =>
|
||||||
|
(ApplicationBarViewModel)DataContext;
|
||||||
}
|
}
|
||||||
@@ -18,6 +18,7 @@
|
|||||||
<None Remove="PrimaryView.xaml" />
|
<None Remove="PrimaryView.xaml" />
|
||||||
<None Remove="SecondaryView.xaml" />
|
<None Remove="SecondaryView.xaml" />
|
||||||
<None Remove="SettingsButtonView.xaml" />
|
<None Remove="SettingsButtonView.xaml" />
|
||||||
|
<None Remove="SettingsView.xaml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Assets\SplashScreen.scale-200.png" />
|
<Content Include="Assets\SplashScreen.scale-200.png" />
|
||||||
@@ -54,6 +55,11 @@
|
|||||||
<ProjectReference Include="..\Hyperbar.Widget\Hyperbar.Widget.csproj" />
|
<ProjectReference Include="..\Hyperbar.Widget\Hyperbar.Widget.csproj" />
|
||||||
<ProjectReference Include="..\Hyperbar\Hyperbar.csproj" />
|
<ProjectReference Include="..\Hyperbar\Hyperbar.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Page Update="SettingsView.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Page Update="SettingsButtonView.xaml">
|
<Page Update="SettingsButtonView.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<ItemsControl
|
<ItemsControl
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
ItemTemplateSelector="{Binding Converter={windows:DataTemplateConverter}}"
|
ItemTemplateSelector="{Binding Converter={windows:DataTemplateConverter}}"
|
||||||
ItemsSource="{Binding}">
|
ItemsSource="{x:Bind ViewModel}">
|
||||||
<ItemsControl.ItemsPanel>
|
<ItemsControl.ItemsPanel>
|
||||||
<ItemsPanelTemplate>
|
<ItemsPanelTemplate>
|
||||||
<ItemsStackPanel Orientation="Horizontal" />
|
<ItemsStackPanel Orientation="Horizontal" />
|
||||||
|
|||||||
@@ -1,28 +1,14 @@
|
|||||||
using Microsoft.UI.Xaml;
|
using Hyperbar.Widget;
|
||||||
using Microsoft.UI.Xaml.Controls;
|
using Microsoft.UI.Xaml.Controls;
|
||||||
using Microsoft.UI.Xaml.Controls.Primitives;
|
|
||||||
using Microsoft.UI.Xaml.Data;
|
|
||||||
using Microsoft.UI.Xaml.Input;
|
|
||||||
using Microsoft.UI.Xaml.Media;
|
|
||||||
using Microsoft.UI.Xaml.Navigation;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices.WindowsRuntime;
|
|
||||||
using Windows.Foundation;
|
|
||||||
using Windows.Foundation.Collections;
|
|
||||||
|
|
||||||
// To learn more about WinUI, the WinUI project structure,
|
namespace Hyperbar.Windows;
|
||||||
// and more about our project templates, see: http://aka.ms/winui-project-info.
|
|
||||||
|
|
||||||
namespace Hyperbar.Windows
|
public partial class PrimaryView :
|
||||||
|
UserControl
|
||||||
{
|
{
|
||||||
public sealed partial class PrimaryView : UserControl
|
public PrimaryView() =>
|
||||||
{
|
InitializeComponent();
|
||||||
public PrimaryView()
|
|
||||||
{
|
protected PrimaryViewModel ViewModel =>
|
||||||
this.InitializeComponent();
|
(PrimaryViewModel)DataContext;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:windows="using:Hyperbar.UI.Windows">
|
xmlns:windows="using:Hyperbar.UI.Windows">
|
||||||
<Grid>
|
<Grid>
|
||||||
<ItemsControl ItemTemplateSelector="{Binding Converter={windows:DataTemplateConverter}}" ItemsSource="{Binding}">
|
<ItemsControl ItemTemplateSelector="{Binding Converter={windows:DataTemplateConverter}}" ItemsSource="{x:Bind ViewModel, Mode=OneWay}">
|
||||||
<ItemsControl.ItemsPanel>
|
<ItemsControl.ItemsPanel>
|
||||||
<ItemsPanelTemplate>
|
<ItemsPanelTemplate>
|
||||||
<ItemsStackPanel Orientation="Horizontal" />
|
<ItemsStackPanel Orientation="Horizontal" />
|
||||||
|
|||||||
@@ -1,28 +1,14 @@
|
|||||||
using Microsoft.UI.Xaml;
|
using Hyperbar.Widget;
|
||||||
using Microsoft.UI.Xaml.Controls;
|
using Microsoft.UI.Xaml.Controls;
|
||||||
using Microsoft.UI.Xaml.Controls.Primitives;
|
|
||||||
using Microsoft.UI.Xaml.Data;
|
|
||||||
using Microsoft.UI.Xaml.Input;
|
|
||||||
using Microsoft.UI.Xaml.Media;
|
|
||||||
using Microsoft.UI.Xaml.Navigation;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices.WindowsRuntime;
|
|
||||||
using Windows.Foundation;
|
|
||||||
using Windows.Foundation.Collections;
|
|
||||||
|
|
||||||
// To learn more about WinUI, the WinUI project structure,
|
namespace Hyperbar.Windows;
|
||||||
// and more about our project templates, see: http://aka.ms/winui-project-info.
|
|
||||||
|
|
||||||
namespace Hyperbar.Windows
|
public partial class SecondaryView :
|
||||||
|
UserControl
|
||||||
{
|
{
|
||||||
public sealed partial class SecondaryView : UserControl
|
public SecondaryView() =>
|
||||||
{
|
InitializeComponent();
|
||||||
public SecondaryView()
|
|
||||||
{
|
protected SecondaryViewModel ViewModel =>
|
||||||
this.InitializeComponent();
|
(SecondaryViewModel)DataContext;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<UserControl
|
||||||
|
x:Class="Hyperbar.Windows.SettingsView"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
<Grid />
|
||||||
|
</UserControl>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using Microsoft.UI.Xaml.Controls;
|
||||||
|
|
||||||
|
namespace Hyperbar.Windows
|
||||||
|
{
|
||||||
|
public sealed partial class SettingsView :
|
||||||
|
UserControl
|
||||||
|
{
|
||||||
|
public SettingsView() =>
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Hyperbar.Windows
|
||||||
|
{
|
||||||
|
internal class SettingsViewModel
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
namespace Hyperbar;
|
||||||
|
|
||||||
|
public record Create<TValue>(TValue Value, object? Target = null) :
|
||||||
|
INotification;
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
namespace Hyperbar;
|
||||||
|
|
||||||
|
public record Insert<TValue>(int Index, TValue Value) : INotification;
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
namespace Hyperbar;
|
||||||
|
|
||||||
|
public record Move<TValue>(int Index, TValue Value) : INotification;
|
||||||
@@ -15,11 +15,11 @@ public partial class ObservableCollectionViewModel<TItem> :
|
|||||||
IList,
|
IList,
|
||||||
IReadOnlyList<TItem>,
|
IReadOnlyList<TItem>,
|
||||||
INotifyCollectionChanged,
|
INotifyCollectionChanged,
|
||||||
INotificationHandler<Removed<TItem>>,
|
INotificationHandler<Remove<TItem>>,
|
||||||
INotificationHandler<Created<TItem>>,
|
INotificationHandler<Create<TItem>>,
|
||||||
INotificationHandler<Inserted<TItem>>,
|
INotificationHandler<Insert<TItem>>,
|
||||||
INotificationHandler<Moved<TItem>>,
|
INotificationHandler<Move<TItem>>,
|
||||||
INotificationHandler<Replaced<TItem>>,
|
INotificationHandler<Replace<TItem>>,
|
||||||
IDisposable,
|
IDisposable,
|
||||||
IInitialization
|
IInitialization
|
||||||
where TItem :
|
where TItem :
|
||||||
@@ -206,7 +206,7 @@ public partial class ObservableCollectionViewModel<TItem> :
|
|||||||
IEnumerator IEnumerable.GetEnumerator() =>
|
IEnumerator IEnumerable.GetEnumerator() =>
|
||||||
((IEnumerable)collection).GetEnumerator();
|
((IEnumerable)collection).GetEnumerator();
|
||||||
|
|
||||||
public Task Handle(Removed<TItem> notification,
|
public Task Handle(Remove<TItem> notification,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
foreach (TItem item in this.ToList())
|
foreach (TItem item in this.ToList())
|
||||||
@@ -220,7 +220,7 @@ public partial class ObservableCollectionViewModel<TItem> :
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task Handle(Created<TItem> notification,
|
public Task Handle(Create<TItem> notification,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (notification.Value is TItem item)
|
if (notification.Value is TItem item)
|
||||||
@@ -231,7 +231,7 @@ public partial class ObservableCollectionViewModel<TItem> :
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task Handle(Inserted<TItem> notification,
|
public Task Handle(Insert<TItem> notification,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (notification.Value is TItem item)
|
if (notification.Value is TItem item)
|
||||||
@@ -242,7 +242,7 @@ public partial class ObservableCollectionViewModel<TItem> :
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task Handle(Moved<TItem> notification,
|
public Task Handle(Move<TItem> notification,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (notification.Value is TItem item)
|
if (notification.Value is TItem item)
|
||||||
@@ -253,7 +253,7 @@ public partial class ObservableCollectionViewModel<TItem> :
|
|||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task Handle(Replaced<TItem> notification,
|
public Task Handle(Replace<TItem> notification,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
if (notification.Value is TItem item)
|
if (notification.Value is TItem item)
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
|
||||||
|
namespace Hyperbar;
|
||||||
|
|
||||||
|
public record Remove<TValue>(TValue Value) : INotification;
|
||||||
|
|
||||||
|
public record Navigate(object Key) :
|
||||||
|
INotification;
|
||||||
|
|
||||||
|
public class NavigateHandler :
|
||||||
|
INotificationHandler<Navigate>
|
||||||
|
{
|
||||||
|
private readonly IEnumerable<IContentTemplateDescriptor> descriptors;
|
||||||
|
|
||||||
|
public NavigateHandler(IEnumerable<IContentTemplateDescriptor> descriptors,
|
||||||
|
IServiceProvider provider)
|
||||||
|
{
|
||||||
|
this.descriptors = descriptors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task Handle(Navigate args,
|
||||||
|
CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
if (descriptors.FirstOrDefault(x => x.Key == args.Key)
|
||||||
|
is IContentTemplateDescriptor descriptor)
|
||||||
|
{
|
||||||
|
//if (provider.GetRequiredKeyedService(descriptor.TemplateType,
|
||||||
|
// descriptor.Key) is { } template)
|
||||||
|
//{
|
||||||
|
// return template;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
namespace Hyperbar;
|
||||||
|
|
||||||
|
public record Replace<TValue>(int Index, TValue Value, object? Target = null) :
|
||||||
|
INotification;
|
||||||
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
|
|
||||||
namespace Hyperbar;
|
|
||||||
|
|
||||||
public record Created<TValue>(TValue Value, object? Target = null) :
|
|
||||||
INotification;
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
namespace Hyperbar;
|
|
||||||
|
|
||||||
public record Inserted<TValue>(int Index, TValue Value) : INotification;
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
namespace Hyperbar;
|
|
||||||
|
|
||||||
public record Moved<TValue>(int Index, TValue Value) : INotification;
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
namespace Hyperbar;
|
|
||||||
|
|
||||||
public record Removed<TValue>(TValue Value) : INotification;
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
|
|
||||||
namespace Hyperbar;
|
|
||||||
|
|
||||||
public record Replaced<TValue>(int Index, TValue Value, object? Target = null) :
|
|
||||||
INotification;
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user