wrapped custom widget items in containers so we have more control of the surrounding, i.e. divider
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
|
||||
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
|
||||
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
|
||||
<UseWinUI>true</UseWinUI>
|
||||
<UseRidGraph>true</UseRidGraph>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Remove="MediaControllerView.xaml" />
|
||||
<None Remove="MediaControllerWidgetView.xaml" />
|
||||
<None Remove="MediaInformationView.xaml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.4.230913002" />
|
||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.755" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Hyperbar.Windows.UI\Hyperbar.Windows.UI.csproj" />
|
||||
<ProjectReference Include="..\Hyperbar\Hyperbar.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="MediaInformationView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="MediaControllerView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="MediaControllerWidgetView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
|
||||
public class MediaController :
|
||||
IInitializer
|
||||
{
|
||||
public Task InitializeAsync()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -1,14 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<UserControl
|
||||
x:Class="Hyperbar.Windows.CommandView"
|
||||
x:Class="Hyperbar.Windows.MediaController.MediaControllerView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:windows="using:Hyperbar.Windows">
|
||||
<ItemsControl ItemTemplateSelector="{Binding Mode=TwoWay, Converter={windows:DataTemplateConverter}}" ItemsSource="{Binding}">
|
||||
xmlns:ui="using:Hyperbar.Windows.UI">
|
||||
<ItemsControl ItemTemplateSelector="{Binding Mode=TwoWay, Converter={ui:DataTemplateConverter}}" ItemsSource="{Binding}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Orientation="Horizontal" />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
</ItemsControl>
|
||||
</UserControl>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,9 @@
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
namespace Hyperbar.Windows.MediaController;
|
||||
|
||||
public sealed partial class MediaControllerView :
|
||||
UserControl
|
||||
{
|
||||
public MediaControllerView() => InitializeComponent();
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
|
||||
public partial class MediaInformationViewModel :
|
||||
WidgetComponentViewModel
|
||||
{
|
||||
[ObservableProperty]
|
||||
private string title = "this is a test";
|
||||
|
||||
[ObservableProperty]
|
||||
private string description = "this is a test description";
|
||||
|
||||
public MediaInformationViewModel(ITemplateFactory templateFactory) : base(templateFactory)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class MediaControllerViewModel :
|
||||
ObservableCollectionViewModel<WidgetComponentViewModel>,
|
||||
ITemplatedViewModel
|
||||
{
|
||||
public MediaControllerViewModel(ITemplateFactory templateFactory,
|
||||
IServiceFactory serviceFactory,
|
||||
IMediator mediator) : base(serviceFactory, mediator)
|
||||
{
|
||||
TemplateFactory = templateFactory;
|
||||
|
||||
this.Add<MediaInformationViewModel>();
|
||||
this.Add<WidgetButtonViewModel>("\uEB9E");
|
||||
this.Add<WidgetButtonViewModel>("\uE768");
|
||||
this.Add<WidgetButtonViewModel>("\uE769");
|
||||
this.Add<WidgetButtonViewModel>("\uEB9D");
|
||||
}
|
||||
|
||||
public ITemplateFactory TemplateFactory { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using Hyperbar.Windows.MediaController;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
|
||||
public class MediaControllerWidgetProvider :
|
||||
IWidgetProvider
|
||||
{
|
||||
public void Create(HostBuilderContext comtext, IServiceCollection services) =>
|
||||
services.AddWidgetTemplate<MediaControllerWidgetViewModel, MediaControllerWidgetView>()
|
||||
.AddContentTemplate<MediaControllerViewModel, MediaControllerView>()
|
||||
.AddContentTemplate<MediaControllerViewModel, MediaControllerView>()
|
||||
.AddContentTemplate<MediaControllerViewModel, MediaControllerView>()
|
||||
.AddContentTemplate<MediaInformationViewModel, MediaInformationView>();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<UserControl
|
||||
x:Class="Hyperbar.Windows.MediaController.MediaControllerWidgetView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:ui="using:Hyperbar.Windows.UI">
|
||||
<FlipView
|
||||
x:Name="FlipView"
|
||||
Width="320"
|
||||
Background="Transparent"
|
||||
ItemTemplateSelector="{Binding Converter={ui:DataTemplateConverter}}"
|
||||
ItemsSource="{Binding}">
|
||||
<FlipView.ItemContainerStyle>
|
||||
<Style TargetType="FlipViewItem">
|
||||
<Setter Property="HorizontalAlignment" Value="Right" />
|
||||
<Setter Property="HorizontalContentAlignment" Value="Right" />
|
||||
|
||||
</Style>
|
||||
</FlipView.ItemContainerStyle>
|
||||
<FlipView.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel AreScrollSnapPointsRegular="False" Orientation="Horizontal" />
|
||||
</ItemsPanelTemplate>
|
||||
</FlipView.ItemsPanel>
|
||||
</FlipView>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,8 @@
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
namespace Hyperbar.Windows.MediaController;
|
||||
|
||||
public sealed partial class MediaControllerWidgetView :
|
||||
UserControl
|
||||
{
|
||||
public MediaControllerWidgetView() => InitializeComponent();
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
|
||||
public class MediaControllerWidgetViewModel(ITemplateFactory templateFactory,
|
||||
IServiceFactory serviceFactory,
|
||||
IMediator mediator,
|
||||
IEnumerable<MediaControllerViewModel> items) :
|
||||
ObservableCollectionViewModel<MediaControllerViewModel>(serviceFactory, mediator, items),
|
||||
IWidgetViewModel,
|
||||
ITemplatedViewModel
|
||||
{
|
||||
public ITemplateFactory TemplateFactory => templateFactory;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<UserControl
|
||||
x:Class="Hyperbar.Windows.MediaController.MediaInformationView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Button>sdfsdf</Button>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,9 @@
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
namespace Hyperbar.Windows.MediaController;
|
||||
|
||||
public sealed partial class MediaInformationView :
|
||||
UserControl
|
||||
{
|
||||
public MediaInformationView() => InitializeComponent();
|
||||
}
|
||||
@@ -7,7 +7,6 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Hyperbar\Hyperbar.csproj" />
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
|
||||
public class PrimaryWidgetViewModel :
|
||||
ObservableCollectionViewModel<IWidgetComponentViewModel>,
|
||||
public class PrimaryWidgetViewModel(ITemplateFactory templateFactory,
|
||||
IServiceFactory serviceFactory,
|
||||
IMediator mediator,
|
||||
IEnumerable<IWidgetComponentViewModel> items) :
|
||||
ObservableCollectionViewModel<IWidgetComponentViewModel>(serviceFactory, mediator, items),
|
||||
IWidgetViewModel,
|
||||
ITemplatedViewModel
|
||||
{
|
||||
public PrimaryWidgetViewModel(ITemplateFactory templateFactory,
|
||||
IServiceFactory serviceFactory,
|
||||
IMediator mediator,
|
||||
IEnumerable<IWidgetComponentViewModel> items) : base(serviceFactory, mediator, items)
|
||||
{
|
||||
TemplateFactory = templateFactory;
|
||||
}
|
||||
|
||||
public ITemplateFactory TemplateFactory { get; }
|
||||
public ITemplateFactory TemplateFactory => templateFactory;
|
||||
}
|
||||
@@ -14,5 +14,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Hyperbar.Windows.Interop\Hyperbar.Windows.Interop.csproj" />
|
||||
<ProjectReference Include="..\Hyperbar\Hyperbar.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,15 @@
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
namespace Hyperbar.Windows.UI;
|
||||
|
||||
public class DataTemplateConverter :
|
||||
ValueConverter<object, DataTemplateSelector>
|
||||
{
|
||||
protected override DataTemplateSelector? ConvertTo(object value,
|
||||
Type? targetType,
|
||||
object? parameter,
|
||||
string? language)
|
||||
{
|
||||
return new TemplateGenerator();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Hyperbar.Windows;
|
||||
namespace Hyperbar.Windows.UI;
|
||||
|
||||
public class TemplateFactory(IEnumerable<IContentTemplateDescriptor> descriptors,
|
||||
IServiceProvider provider) :
|
||||
+5
-5
@@ -2,7 +2,7 @@
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Markup;
|
||||
|
||||
namespace Hyperbar.Windows;
|
||||
namespace Hyperbar.Windows.UI;
|
||||
|
||||
public class TemplateGenerator : DataTemplateSelector
|
||||
{
|
||||
@@ -10,8 +10,8 @@ public class TemplateGenerator : DataTemplateSelector
|
||||
{
|
||||
string xamlString = @"
|
||||
<DataTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
|
||||
xmlns:desktop='using:Hyperbar.Windows'>
|
||||
<desktop:TemplateGeneratorControl />
|
||||
xmlns:ui='using:Hyperbar.Windows.UI'>
|
||||
<ui:TemplateGeneratorControl />
|
||||
</DataTemplate>";
|
||||
|
||||
return (DataTemplate)XamlReader.Load(xamlString);
|
||||
@@ -21,8 +21,8 @@ public class TemplateGenerator : DataTemplateSelector
|
||||
{
|
||||
string xamlString = @"
|
||||
<DataTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
|
||||
xmlns:desktop='using:Hyperbar.Windows'>
|
||||
<desktop:TemplateGeneratorControl />
|
||||
xmlns:ui='using:Hyperbar.Windows.UI'>
|
||||
<ui:TemplateGeneratorControl />
|
||||
</DataTemplate>";
|
||||
|
||||
return (DataTemplate)XamlReader.Load(xamlString);
|
||||
+5
-1
@@ -1,7 +1,7 @@
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
namespace Hyperbar.Windows;
|
||||
namespace Hyperbar.Windows.UI;
|
||||
|
||||
public class TemplateGeneratorControl :
|
||||
ContentControl
|
||||
@@ -17,5 +17,9 @@ public class TemplateGeneratorControl :
|
||||
{
|
||||
Content = templatedViewModel.TemplateFactory.Create(DataContext.GetType().Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
using Microsoft.UI.Xaml.Markup;
|
||||
|
||||
namespace Hyperbar.Windows;
|
||||
namespace Hyperbar.Windows.UI;
|
||||
|
||||
public abstract class ValueConverter<TSource, TTarget> :
|
||||
MarkupExtension,
|
||||
@@ -3,14 +3,14 @@
|
||||
x:Class="Hyperbar.Windows.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:desktop="using:Hyperbar.Windows">
|
||||
xmlns:ui="using:Hyperbar.Windows.UI">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<DataTemplate x:Key="DefaultDataTemplate">
|
||||
<desktop:TemplateGeneratorControl />
|
||||
<ui:TemplateGeneratorControl />
|
||||
</DataTemplate>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
using Hyperbar.Widget.Contextual;
|
||||
using Hyperbar.Windows.Controls;
|
||||
using Hyperbar.Windows.Controls;
|
||||
using Hyperbar.Windows.Primary;
|
||||
using Hyperbar.Windows.UI;
|
||||
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;
|
||||
|
||||
@@ -17,7 +15,7 @@ public partial class App :
|
||||
public App() => InitializeComponent();
|
||||
|
||||
protected override async void OnLaunched(LaunchActivatedEventArgs args)
|
||||
{
|
||||
{
|
||||
base.OnLaunched(args);
|
||||
|
||||
DispatcherQueueSynchronizationContext context = new(DispatcherQueue.GetForCurrentThread());
|
||||
@@ -44,21 +42,23 @@ public partial class App :
|
||||
services.AddTransient<ITemplateFactory, TemplateFactory>();
|
||||
|
||||
services.AddTransient<DesktopFlyout>();
|
||||
services.AddContentTemplate<CommandViewModel, CommandView>();
|
||||
|
||||
// services.AddWidgetProvider<ContextualWidgetProvider>();
|
||||
services.AddContentTemplate<WidgetBarViewModel, WidgetBarView>();
|
||||
|
||||
services.AddWidgetProvider<MediaControllerWidgetProvider>();
|
||||
services.AddWidgetProvider<PrimaryWidgetProvider>();
|
||||
|
||||
services.AddTransient(provider =>
|
||||
{
|
||||
static IEnumerable<IWidgetViewModel> Resolve(IServiceProvider services)
|
||||
static IEnumerable<WidgetContainerViewModel> Resolve(IServiceProvider services)
|
||||
{
|
||||
foreach (IWidgetContext widgetContext in services.GetServices<IWidgetContext>())
|
||||
{
|
||||
if (widgetContext.ServiceProvider.GetService<IWidgetViewModel>() is
|
||||
IWidgetViewModel viewModel)
|
||||
if (widgetContext.ServiceProvider.GetServices<IWidgetViewModel>() is
|
||||
IEnumerable<IWidgetViewModel> viewModels)
|
||||
{
|
||||
yield return viewModel;
|
||||
yield return (WidgetContainerViewModel)ActivatorUtilities.CreateInstance(widgetContext.ServiceProvider,
|
||||
typeof(WidgetContainerViewModel), viewModels);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Remove="Views\WidgetButtonView.xaml" />
|
||||
<None Remove="Views\WidgetContainerView.xaml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Assets\SplashScreen.scale-200.png" />
|
||||
@@ -38,10 +39,16 @@
|
||||
<ProjectReference Include="..\Hyperbar.Windows.Contextual\Hyperbar.Widget.Contextual.csproj" />
|
||||
<ProjectReference Include="..\Hyperbar.Windows.Controls\Hyperbar.Windows.Controls.csproj" />
|
||||
<ProjectReference Include="..\Hyperbar.Windows.Interop\Hyperbar.Windows.Interop.csproj" />
|
||||
<ProjectReference Include="..\Hyperbar.Windows.MediaController\Hyperbar.Windows.MediaController.csproj" />
|
||||
<ProjectReference Include="..\Hyperbar.Windows.Primary\Hyperbar.Widget.Primary.csproj" />
|
||||
<ProjectReference Include="..\Hyperbar.Windows.UI\Hyperbar.Windows.UI.csproj" />
|
||||
<ProjectReference Include="..\Hyperbar\Hyperbar.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="Views\WidgetContainerView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="Views\WidgetButtonView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
||||
@@ -3,8 +3,8 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
public class AppInitializer([FromKeyedServices(nameof(CommandViewModel))] CommandView view,
|
||||
[FromKeyedServices(nameof(CommandViewModel))] CommandViewModel viewModel,
|
||||
public class AppInitializer([FromKeyedServices(nameof(WidgetBarViewModel))] WidgetBarView view,
|
||||
[FromKeyedServices(nameof(WidgetBarViewModel))] WidgetBarViewModel viewModel,
|
||||
DesktopFlyout desktopFlyout) :
|
||||
IInitializer
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Hyperbar.Windows.Interop;
|
||||
using Hyperbar.Windows.Primary;
|
||||
using Hyperbar.Windows.UI;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
@@ -28,20 +28,23 @@ namespace Hyperbar.Windows
|
||||
})
|
||||
.ConfigureServices((context, isolatedServices) =>
|
||||
{
|
||||
isolatedServices.AddHostedService<WidgetService>();
|
||||
|
||||
isolatedServices.AddSingleton<IServiceFactory>(provider =>
|
||||
new ServiceFactory((type, parameters) => ActivatorUtilities.CreateInstance(provider, type, parameters!)));
|
||||
|
||||
isolatedServices.AddSingleton<IVirtualKeyboard, VirtualKeyboard>();
|
||||
|
||||
isolatedServices.AddSingleton<IMediator, Mediator>();
|
||||
isolatedServices.AddHandler<KeyAcceleratorHandler>();
|
||||
isolatedServices.AddHandler<ProcesssAcceleratorHandler>();
|
||||
isolatedServices.AddTransient<IWidgetView, WidgetView>();
|
||||
isolatedServices.AddContentTemplate<WidgetButtonViewModel, WidgetButtonView>();
|
||||
isolatedServices.AddHostedService<WidgetService>();
|
||||
|
||||
isolatedServices.AddTransient<ITemplateFactory, TemplateFactory>();
|
||||
isolatedServices.AddSingleton<IMediator, Mediator>();
|
||||
|
||||
isolatedServices.AddSingleton<IVirtualKeyboard, VirtualKeyboard>();
|
||||
|
||||
isolatedServices.AddHandler<KeyAcceleratorHandler>();
|
||||
isolatedServices.AddHandler<ProcesssAcceleratorHandler>();
|
||||
|
||||
isolatedServices.AddTransient<IWidgetView, WidgetView>();
|
||||
|
||||
isolatedServices.AddContentTemplate<WidgetContainerViewModel, WidgetContainerView>();
|
||||
isolatedServices.AddContentTemplate<WidgetButtonViewModel, WidgetButtonView>();
|
||||
|
||||
builder.Create(context, isolatedServices);
|
||||
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
public class DataTemplateConverter : ValueConverter<object, DataTemplateSelector>
|
||||
{
|
||||
protected override DataTemplateSelector? ConvertTo(object value, Type? targetType, object? parameter, string? language)
|
||||
{
|
||||
return new TemplateGenerator();
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Input;
|
||||
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
public sealed partial class CommandView :
|
||||
UserControl
|
||||
{
|
||||
public CommandView() => InitializeComponent();
|
||||
|
||||
protected override void OnKeyDown(KeyRoutedEventArgs e)
|
||||
{
|
||||
base.OnKeyDown(e);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
public partial class CommandViewModel :
|
||||
ObservableCollectionViewModel<IWidgetViewModel>,
|
||||
ITemplatedViewModel
|
||||
{
|
||||
public CommandViewModel(ITemplateFactory templateFactory,
|
||||
IServiceFactory serviceFactory,
|
||||
IMediator mediator,
|
||||
IEnumerable<IWidgetViewModel> items) : base(serviceFactory, mediator, items)
|
||||
{
|
||||
TemplateFactory = templateFactory;
|
||||
}
|
||||
|
||||
public ITemplateFactory TemplateFactory { get; }
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<UserControl
|
||||
x:Class="Hyperbar.Windows.WidgetBarView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:ui="using:Hyperbar.Windows.UI">
|
||||
<ItemsControl ItemTemplateSelector="{Binding Converter={ui:DataTemplateConverter}}" ItemsSource="{Binding}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Orientation="Horizontal" />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
</ItemsControl>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,9 @@
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
public sealed partial class WidgetBarView :
|
||||
UserControl
|
||||
{
|
||||
public WidgetBarView() => InitializeComponent();
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<UserControl
|
||||
x:Class="Hyperbar.Windows.WidgetContainerView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:ui="using:Hyperbar.Windows.UI">
|
||||
<ItemsControl ItemTemplateSelector="{Binding Converter={ui:DataTemplateConverter}}" ItemsSource="{Binding}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Orientation="Horizontal" />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
</ItemsControl>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,9 @@
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
public sealed partial class WidgetContainerView :
|
||||
UserControl
|
||||
{
|
||||
public WidgetContainerView() => InitializeComponent();
|
||||
}
|
||||
@@ -3,8 +3,8 @@
|
||||
x:Class="Hyperbar.Windows.WidgetView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:windows="using:Hyperbar.Windows">
|
||||
<ItemsControl ItemTemplateSelector="{Binding Mode=TwoWay, Converter={windows:DataTemplateConverter}}" ItemsSource="{Binding}">
|
||||
xmlns:ui="using:Hyperbar.Windows.UI">
|
||||
<ItemsControl ItemTemplateSelector="{Binding Converter={ui:DataTemplateConverter}}" ItemsSource="{Binding}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Orientation="Horizontal" Spacing="8" />
|
||||
|
||||
+19
-1
@@ -15,7 +15,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hyperbar.Widget.Primary", "
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hyperbar.Windows.UI", "Hyperbar.Windows.UI\Hyperbar.Windows.UI.csproj", "{ED489968-89A5-42B5-9FC3-20DCF5D78A5E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hyperbar.Windows.Interop", "Hyperbar.Windows.Interop\Hyperbar.Windows.Interop.csproj", "{7263FB8C-4007-4581-8AD7-DCAB2AD7C444}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hyperbar.Windows.Interop", "Hyperbar.Windows.Interop\Hyperbar.Windows.Interop.csproj", "{7263FB8C-4007-4581-8AD7-DCAB2AD7C444}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hyperbar.Windows.MediaController", "Hyperbar.Windows.MediaController\Hyperbar.Windows.MediaController.csproj", "{88C3EC90-C48C-47B9-89A8-740EFFFE5AAD}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -149,6 +151,22 @@ Global
|
||||
{7263FB8C-4007-4581-8AD7-DCAB2AD7C444}.Release|x64.Build.0 = Release|Any CPU
|
||||
{7263FB8C-4007-4581-8AD7-DCAB2AD7C444}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{7263FB8C-4007-4581-8AD7-DCAB2AD7C444}.Release|x86.Build.0 = Release|Any CPU
|
||||
{88C3EC90-C48C-47B9-89A8-740EFFFE5AAD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{88C3EC90-C48C-47B9-89A8-740EFFFE5AAD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{88C3EC90-C48C-47B9-89A8-740EFFFE5AAD}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
||||
{88C3EC90-C48C-47B9-89A8-740EFFFE5AAD}.Debug|ARM64.Build.0 = Debug|Any CPU
|
||||
{88C3EC90-C48C-47B9-89A8-740EFFFE5AAD}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{88C3EC90-C48C-47B9-89A8-740EFFFE5AAD}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{88C3EC90-C48C-47B9-89A8-740EFFFE5AAD}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{88C3EC90-C48C-47B9-89A8-740EFFFE5AAD}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{88C3EC90-C48C-47B9-89A8-740EFFFE5AAD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{88C3EC90-C48C-47B9-89A8-740EFFFE5AAD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{88C3EC90-C48C-47B9-89A8-740EFFFE5AAD}.Release|ARM64.ActiveCfg = Release|Any CPU
|
||||
{88C3EC90-C48C-47B9-89A8-740EFFFE5AAD}.Release|ARM64.Build.0 = Release|Any CPU
|
||||
{88C3EC90-C48C-47B9-89A8-740EFFFE5AAD}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{88C3EC90-C48C-47B9-89A8-740EFFFE5AAD}.Release|x64.Build.0 = Release|Any CPU
|
||||
{88C3EC90-C48C-47B9-89A8-740EFFFE5AAD}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{88C3EC90-C48C-47B9-89A8-740EFFFE5AAD}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -96,7 +96,7 @@ public static class IServiceCollectionExtensions
|
||||
key ??= contentType.Name;
|
||||
|
||||
services.AddTransient(contentType);
|
||||
services.TryAddTransient(templateType);
|
||||
services.AddTransient(templateType);
|
||||
|
||||
services.AddKeyedTransient(contentType, key);
|
||||
services.AddKeyedTransient(templateType, key);
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Hyperbar;
|
||||
public class Mediator(IServiceProvider provider) :
|
||||
IMediator
|
||||
{
|
||||
private readonly ConditionalWeakTable<Type, dynamic> addedHandlers = [];
|
||||
private readonly List<KeyValuePair<Type, dynamic>> addedHandlers = [];
|
||||
|
||||
public ValueTask PublishAsync<TNotification>(TNotification notification,
|
||||
CancellationToken cancellationToken = default)
|
||||
@@ -78,7 +78,7 @@ public class Mediator(IServiceProvider provider) :
|
||||
if (interfaceType.GetGenericArguments() is { Length: 1 } arguments)
|
||||
{
|
||||
Type notificationType = arguments[0];
|
||||
addedHandlers.Add(notificationType, subject);
|
||||
addedHandlers.Add(new KeyValuePair<Type, dynamic>(notificationType, subject));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
namespace Hyperbar;
|
||||
|
||||
public interface IWidgetComponentViewModel
|
||||
{
|
||||
}
|
||||
public interface IWidgetComponentViewModel;
|
||||
@@ -1,5 +1,3 @@
|
||||
namespace Hyperbar;
|
||||
|
||||
public interface IWidgetView
|
||||
{
|
||||
}
|
||||
public interface IWidgetView;
|
||||
@@ -1,5 +1,3 @@
|
||||
namespace Hyperbar;
|
||||
|
||||
public interface IWidgetViewModel
|
||||
{
|
||||
}
|
||||
public interface IWidgetViewModel;
|
||||
@@ -2,12 +2,14 @@
|
||||
|
||||
namespace Hyperbar;
|
||||
|
||||
|
||||
public class ObservableCollectionViewModel<TItem> :
|
||||
ObservableCollection<TItem>,
|
||||
INotificationHandler<CollectionChanged<IEnumerable<TItem>>>
|
||||
{
|
||||
private readonly IServiceFactory serviceFactory;
|
||||
private SynchronizationContext? context;
|
||||
private readonly SynchronizationContext? context;
|
||||
|
||||
public ObservableCollectionViewModel(IServiceFactory serviceFactory,
|
||||
IMediator mediator)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
namespace Hyperbar;
|
||||
|
||||
public partial class WidgetBarViewModel(ITemplateFactory templateFactory,
|
||||
IServiceFactory serviceFactory,
|
||||
IMediator mediator,
|
||||
IEnumerable<WidgetContainerViewModel> items) :
|
||||
ObservableCollectionViewModel<WidgetContainerViewModel>(serviceFactory, mediator, items),
|
||||
ITemplatedViewModel
|
||||
{
|
||||
public ITemplateFactory TemplateFactory => templateFactory;
|
||||
}
|
||||
@@ -4,7 +4,7 @@ using CommunityToolkit.Mvvm.Input;
|
||||
namespace Hyperbar;
|
||||
|
||||
public partial class WidgetButtonViewModel :
|
||||
WidgetComponentViewModelBase
|
||||
WidgetComponentViewModel
|
||||
{
|
||||
[ObservableProperty]
|
||||
private string? icon;
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Hyperbar;
|
||||
|
||||
public partial class WidgetComponentViewModelBase(ITemplateFactory templateFactory) :
|
||||
public partial class WidgetComponentViewModel(ITemplateFactory templateFactory) :
|
||||
ObservableObject,
|
||||
IWidgetComponentViewModel,
|
||||
ITemplatedViewModel
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
namespace Hyperbar;
|
||||
|
||||
public class WidgetContainerViewModel(ITemplateFactory templateFactory,
|
||||
IServiceFactory serviceFactory,
|
||||
IMediator mediator,
|
||||
IEnumerable<IWidgetViewModel> items) :
|
||||
ObservableCollectionViewModel<IWidgetViewModel>(serviceFactory, mediator, items),
|
||||
ITemplatedViewModel
|
||||
{
|
||||
public ITemplateFactory TemplateFactory => templateFactory;
|
||||
}
|
||||
Reference in New Issue
Block a user