break widget related stuff into its own project as the main HB project was just becoming too bloated
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Hyperbar\Hyperbar.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
|
|
||||||
|
namespace Hyperbar.Widget;
|
||||||
|
|
||||||
|
public static class IServiceCollectionExtensions
|
||||||
|
{
|
||||||
|
public static IServiceCollection AddWidget(this IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddTransient<IInitializer, WidgetInitializer>();
|
||||||
|
services.AddTransient<IFactory<Type, IWidget>, WidgetFactory>();
|
||||||
|
|
||||||
|
services.AddHandler<WidgetEnumeratorHandler>();
|
||||||
|
services.AddHandler<WidgetAssemblyHandler>();
|
||||||
|
services.AddHandler<WidgetHandler>();
|
||||||
|
services.AddHandler<WidgetHostHandler>();
|
||||||
|
|
||||||
|
services.AddTransient<IFactory<IWidgetHost, WidgetContainerViewModel?>, WidgetContainerFactory>();
|
||||||
|
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IServiceCollection AddWidgetTemplate<TWidgetContent>(this IServiceCollection services)
|
||||||
|
where TWidgetContent :
|
||||||
|
IWidgetViewModel
|
||||||
|
{
|
||||||
|
Type contentType = typeof(TWidgetContent);
|
||||||
|
Type templateType = typeof(IWidgetView);
|
||||||
|
|
||||||
|
string key = contentType.Name;
|
||||||
|
|
||||||
|
services.AddTransient(typeof(IWidgetViewModel), contentType);
|
||||||
|
services.TryAddTransient(templateType, provider => provider.GetService<IWidgetView>()!);
|
||||||
|
|
||||||
|
services.AddKeyedTransient(typeof(IWidgetViewModel), key, contentType);
|
||||||
|
services.TryAddKeyedTransient(key, (provider, key) => provider.GetService<IWidgetView>()!);
|
||||||
|
|
||||||
|
services.AddTransient<IContentTemplateDescriptor>(provider => new ContentTemplateDescriptor { ContentType = contentType, TemplateType = templateType, Key = key });
|
||||||
|
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IServiceCollection AddWidgetTemplate<TWidgetContent,
|
||||||
|
TWidgetTemplate>(this IServiceCollection services)
|
||||||
|
where TWidgetContent :
|
||||||
|
IWidgetViewModel
|
||||||
|
{
|
||||||
|
Type contentType = typeof(TWidgetContent);
|
||||||
|
Type templateType = typeof(TWidgetTemplate);
|
||||||
|
|
||||||
|
string key = contentType.Name;
|
||||||
|
|
||||||
|
services.AddTransient(typeof(IWidgetViewModel), contentType);
|
||||||
|
services.TryAddTransient(templateType);
|
||||||
|
|
||||||
|
services.AddKeyedTransient(typeof(IWidgetViewModel), key, contentType);
|
||||||
|
services.TryAddKeyedTransient(templateType, key);
|
||||||
|
|
||||||
|
services.AddTransient<IContentTemplateDescriptor>(provider =>
|
||||||
|
new ContentTemplateDescriptor { ContentType = contentType,
|
||||||
|
TemplateType = templateType, Key = key });
|
||||||
|
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace Hyperbar;
|
namespace Hyperbar.Widget;
|
||||||
|
|
||||||
public interface IWidget
|
public interface IWidget
|
||||||
{
|
{
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
namespace Hyperbar;
|
namespace Hyperbar.Widget;
|
||||||
|
|
||||||
public interface IWidgetBuilder
|
public interface IWidgetBuilder
|
||||||
{
|
{
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
namespace Hyperbar;
|
namespace Hyperbar.Widget;
|
||||||
|
|
||||||
public static class IWidgetBuilderExtensions
|
public static class IWidgetBuilderExtensions
|
||||||
{
|
{
|
||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
namespace Hyperbar;
|
namespace Hyperbar.Widget;
|
||||||
|
|
||||||
public interface IWidgetComponentViewModel : IDisposable;
|
public interface IWidgetComponentViewModel : IDisposable;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace Hyperbar;
|
namespace Hyperbar.Widget;
|
||||||
|
|
||||||
public interface IWidgetHost :
|
public interface IWidgetHost :
|
||||||
IInitializer
|
IInitializer
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Hyperbar;
|
namespace Hyperbar.Widget;
|
||||||
|
|
||||||
public interface IWidgetView;
|
public interface IWidgetView;
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Hyperbar;
|
namespace Hyperbar.Widget;
|
||||||
|
|
||||||
public interface IWidgetViewModel : IDisposable;
|
public interface IWidgetViewModel : IDisposable;
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Hyperbar;
|
namespace Hyperbar.Widget;
|
||||||
|
|
||||||
public record Started<TValue>(TValue Value) : INotification;
|
public record Started<TValue>(TValue Value) : INotification;
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Hyperbar;
|
namespace Hyperbar.Widget;
|
||||||
|
|
||||||
public record Stopped<TValue>(TValue Value) : INotification;
|
public record Stopped<TValue>(TValue Value) : INotification;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Hyperbar;
|
namespace Hyperbar.Widget;
|
||||||
|
|
||||||
public record WidgetAssembly(Assembly? Assembly = default) :
|
public record WidgetAssembly(Assembly? Assembly = default) :
|
||||||
INotification;
|
INotification;
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Hyperbar;
|
namespace Hyperbar.Widget;
|
||||||
|
|
||||||
public class WidgetAssemblyHandler(IMediator mediator,
|
public class WidgetAssemblyHandler(IMediator mediator,
|
||||||
IFactory<Type, IWidget> factory) :
|
IFactory<Type, IWidget> factory) :
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace Hyperbar;
|
namespace Hyperbar.Widget;
|
||||||
|
|
||||||
public record WidgetAvailability
|
public record WidgetAvailability
|
||||||
{
|
{
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace Hyperbar;
|
namespace Hyperbar.Widget;
|
||||||
|
|
||||||
[NotificationHandler(nameof(WidgetBarViewModel))]
|
[NotificationHandler(nameof(WidgetBarViewModel))]
|
||||||
public partial class WidgetBarViewModel(ITemplateFactory templateFactory,
|
public partial class WidgetBarViewModel(ITemplateFactory templateFactory,
|
||||||
@@ -3,7 +3,7 @@ using Microsoft.Extensions.DependencyInjection;
|
|||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Hyperbar;
|
namespace Hyperbar.Widget;
|
||||||
|
|
||||||
public class WidgetBuilder<TConfiguration>(TConfiguration configuration) :
|
public class WidgetBuilder<TConfiguration>(TConfiguration configuration) :
|
||||||
IWidgetBuilder<TConfiguration>
|
IWidgetBuilder<TConfiguration>
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
|
|
||||||
namespace Hyperbar;
|
namespace Hyperbar.Widget;
|
||||||
|
|
||||||
[NotificationHandler(nameof(Id))]
|
[NotificationHandler(nameof(Id))]
|
||||||
public partial class WidgetButtonViewModel(IServiceFactory serviceFactory,
|
public partial class WidgetButtonViewModel(IServiceFactory serviceFactory,
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
|
||||||
namespace Hyperbar;
|
namespace Hyperbar.Widget;
|
||||||
|
|
||||||
public partial class WidgetComponentViewModel :
|
public partial class WidgetComponentViewModel :
|
||||||
ObservableCollectionViewModel<IWidgetComponentViewModel>,
|
ObservableCollectionViewModel<IWidgetComponentViewModel>,
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Hyperbar;
|
namespace Hyperbar.Widget;
|
||||||
public class WidgetConfiguration
|
public class WidgetConfiguration
|
||||||
{
|
{
|
||||||
public string? Description { get; set; }
|
public string? Description { get; set; }
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
|
|
||||||
namespace Hyperbar;
|
namespace Hyperbar.Widget;
|
||||||
|
|
||||||
public record WidgetConfigurationChanged<TConfiguration> : INotification;
|
public record WidgetConfigurationChanged<TConfiguration> : INotification;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
namespace Hyperbar;
|
namespace Hyperbar.Widget;
|
||||||
|
|
||||||
public class WidgetConfigurationHandler(IValue<WidgetAvailability> widgetAvailability) :
|
public class WidgetConfigurationHandler(IValue<WidgetAvailability> widgetAvailability) :
|
||||||
INotificationHandler<ConfigurationChanged<WidgetConfiguration>>
|
INotificationHandler<ConfigurationChanged<WidgetConfiguration>>
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
namespace Hyperbar;
|
namespace Hyperbar.Widget;
|
||||||
|
|
||||||
public class WidgetContainerFactory(IServiceFactory factory) :
|
public class WidgetContainerFactory(IServiceFactory factory) :
|
||||||
IFactory<IWidgetHost, WidgetContainerViewModel?>
|
IFactory<IWidgetHost, WidgetContainerViewModel?>
|
||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
|
||||||
namespace Hyperbar;
|
namespace Hyperbar.Widget;
|
||||||
|
|
||||||
public partial class WidgetContainerViewModel(ITemplateFactory templateFactory,
|
public partial class WidgetContainerViewModel(ITemplateFactory templateFactory,
|
||||||
IServiceFactory serviceFactory,
|
IServiceFactory serviceFactory,
|
||||||
+2
-2
@@ -2,9 +2,9 @@
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.Loader;
|
using System.Runtime.Loader;
|
||||||
|
|
||||||
namespace Hyperbar;
|
namespace Hyperbar.Widget;
|
||||||
|
|
||||||
public class WidgetEnumerationHandler(IHostEnvironment hostEnvironment,
|
public class WidgetEnumeratorHandler(IHostEnvironment hostEnvironment,
|
||||||
IMediator mediator) :
|
IMediator mediator) :
|
||||||
INotificationHandler<Enumerate<IWidget>>
|
INotificationHandler<Enumerate<IWidget>>
|
||||||
{
|
{
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace Hyperbar;
|
namespace Hyperbar.Widget;
|
||||||
|
|
||||||
public class WidgetFactory :
|
public class WidgetFactory :
|
||||||
IFactory<Type, IWidget>
|
IFactory<Type, IWidget>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
namespace Hyperbar;
|
namespace Hyperbar.Widget;
|
||||||
|
|
||||||
public class WidgetHandler(IProxyServiceCollection<IWidgetBuilder> typedServices,
|
public class WidgetHandler(IProxyServiceCollection<IWidgetBuilder> typedServices,
|
||||||
IServiceProvider provider,
|
IServiceProvider provider,
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
namespace Hyperbar;
|
namespace Hyperbar.Widget;
|
||||||
|
|
||||||
public class WidgetHost :
|
public class WidgetHost :
|
||||||
INotificationHandler<Changed<WidgetAvailability>>,
|
INotificationHandler<Changed<WidgetAvailability>>,
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace Hyperbar;
|
namespace Hyperbar.Widget;
|
||||||
|
|
||||||
public class WidgetHostHandler(IMediator mediator,
|
public class WidgetHostHandler(IMediator mediator,
|
||||||
IFactory<IWidgetHost, WidgetContainerViewModel?> factory) :
|
IFactory<IWidgetHost, WidgetContainerViewModel?> factory) :
|
||||||
@@ -12,8 +12,8 @@ public class WidgetHostHandler(IMediator mediator,
|
|||||||
{
|
{
|
||||||
if (factory.Create(host) is WidgetContainerViewModel containerViewModel)
|
if (factory.Create(host) is WidgetContainerViewModel containerViewModel)
|
||||||
{
|
{
|
||||||
await mediator.PublishAsync(new Created<WidgetContainerViewModel>(containerViewModel), nameof(WidgetBarViewModel),
|
await mediator.PublishAsync(new Created<WidgetContainerViewModel>(containerViewModel),
|
||||||
cancellationToken);
|
nameof(WidgetBarViewModel), cancellationToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace Hyperbar;
|
namespace Hyperbar.Widget;
|
||||||
|
|
||||||
public class WidgetInitializer(IMediator mediator) :
|
public class WidgetInitializer(IMediator mediator) :
|
||||||
IInitializer
|
IInitializer
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
|
|
||||||
namespace Hyperbar;
|
namespace Hyperbar.Widget;
|
||||||
|
|
||||||
[NotificationHandler(nameof(Id))]
|
[NotificationHandler(nameof(Id))]
|
||||||
public partial class WidgetMenuViewModel(IServiceFactory serviceFactory,
|
public partial class WidgetMenuViewModel(IServiceFactory serviceFactory,
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace Hyperbar;
|
namespace Hyperbar.Widget;
|
||||||
|
|
||||||
public class WidgetMonitor :
|
public class WidgetMonitor :
|
||||||
IInitializer
|
IInitializer
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
||||||
namespace Hyperbar;
|
namespace Hyperbar.Widget;
|
||||||
|
|
||||||
public sealed class WidgetService(IEnumerable<IInitializer> initializers) :
|
public sealed class WidgetService(IEnumerable<IInitializer> initializers) :
|
||||||
IHostedService
|
IHostedService
|
||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
|
|
||||||
namespace Hyperbar;
|
namespace Hyperbar.Widget;
|
||||||
|
|
||||||
[NotificationHandler(nameof(Id))]
|
[NotificationHandler(nameof(Id))]
|
||||||
public partial class WidgetSplitButtonViewModel(IServiceFactory serviceFactory,
|
public partial class WidgetSplitButtonViewModel(IServiceFactory serviceFactory,
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
namespace Hyperbar.Widget;
|
||||||
|
|
||||||
|
public class WidgetViewModelEnumerator :
|
||||||
|
INotificationHandler<Enumerate<IWidgetViewModel>>
|
||||||
|
{
|
||||||
|
public Task Handle(Enumerate<IWidgetViewModel> notification,
|
||||||
|
CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Hyperbar.Widget\Hyperbar.Widget.csproj" />
|
||||||
<ProjectReference Include="..\Hyperbar\Hyperbar.csproj" />
|
<ProjectReference Include="..\Hyperbar\Hyperbar.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Hyperbar.Widget\Hyperbar.Widget.csproj" />
|
||||||
<ProjectReference Include="..\Hyperbar.Windows.Controls\Hyperbar.Windows.Controls.csproj" />
|
<ProjectReference Include="..\Hyperbar.Windows.Controls\Hyperbar.Windows.Controls.csproj" />
|
||||||
<ProjectReference Include="..\Hyperbar.Windows.UI\Hyperbar.Windows.UI.csproj" />
|
<ProjectReference Include="..\Hyperbar.Windows.UI\Hyperbar.Windows.UI.csproj" />
|
||||||
<ProjectReference Include="..\Hyperbar\Hyperbar.csproj" />
|
<ProjectReference Include="..\Hyperbar\Hyperbar.csproj" />
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using Hyperbar.Widget;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Windows.Media.Control;
|
using Windows.Media.Control;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
namespace Hyperbar.Windows.MediaController;
|
using Hyperbar.Widget;
|
||||||
|
|
||||||
|
namespace Hyperbar.Windows.MediaController;
|
||||||
|
|
||||||
public class MediaControllerWidgetConfiguration :
|
public class MediaControllerWidgetConfiguration :
|
||||||
WidgetConfiguration
|
WidgetConfiguration
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
|
using Hyperbar.Widget;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
|
||||||
namespace Hyperbar.Windows.MediaController;
|
namespace Hyperbar.Windows.MediaController;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
|
using Hyperbar.Widget;
|
||||||
|
|
||||||
namespace Hyperbar.Windows.MediaController;
|
namespace Hyperbar.Windows.MediaController;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
namespace Hyperbar.Windows.MediaController;
|
using Hyperbar.Widget;
|
||||||
|
|
||||||
|
namespace Hyperbar.Windows.MediaController;
|
||||||
|
|
||||||
public class MediaControllerWidgetViewModel(ITemplateFactory templateFactory,
|
public class MediaControllerWidgetViewModel(ITemplateFactory templateFactory,
|
||||||
IServiceFactory serviceFactory,
|
IServiceFactory serviceFactory,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
|
using Hyperbar.Widget;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
|
||||||
namespace Hyperbar.Windows.MediaController;
|
namespace Hyperbar.Windows.MediaController;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
<PackageReference Include="System.Runtime.Caching" Version="8.0.0" />
|
<PackageReference Include="System.Runtime.Caching" Version="8.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Hyperbar.Widget\Hyperbar.Widget.csproj" />
|
||||||
<ProjectReference Include="..\Hyperbar\Hyperbar.csproj" />
|
<ProjectReference Include="..\Hyperbar\Hyperbar.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using Hyperbar.Widget;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
namespace Hyperbar.Windows.Primary;
|
namespace Hyperbar.Windows.Primary;
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
namespace Hyperbar.Windows.Primary;
|
using Hyperbar.Widget;
|
||||||
|
|
||||||
public class PrimaryWidgetConfiguration : WidgetConfiguration
|
namespace Hyperbar.Windows.Primary;
|
||||||
|
|
||||||
|
public class PrimaryWidgetConfiguration :
|
||||||
|
WidgetConfiguration
|
||||||
{
|
{
|
||||||
public List<PrimaryCommandConfiguration> Commands { get; set; } = [];
|
public List<PrimaryCommandConfiguration> Commands { get; set; } = [];
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
namespace Hyperbar.Windows.Primary;
|
using Hyperbar.Widget;
|
||||||
|
|
||||||
|
namespace Hyperbar.Windows.Primary;
|
||||||
|
|
||||||
public class PrimaryWidgetConfigurationHandler(IMediator mediator,
|
public class PrimaryWidgetConfigurationHandler(IMediator mediator,
|
||||||
PrimaryWidgetConfiguration configuration,
|
PrimaryWidgetConfiguration configuration,
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
namespace Hyperbar.Windows.Primary;
|
using Hyperbar.Widget;
|
||||||
|
|
||||||
|
namespace Hyperbar.Windows.Primary;
|
||||||
|
|
||||||
[NotificationHandler(nameof(PrimaryWidgetViewModel))]
|
[NotificationHandler(nameof(PrimaryWidgetViewModel))]
|
||||||
public class PrimaryWidgetViewModel(ITemplateFactory templateFactory,
|
public class PrimaryWidgetViewModel(ITemplateFactory templateFactory,
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
namespace Hyperbar.Windows.Primary;
|
using Hyperbar.Widget;
|
||||||
|
|
||||||
|
namespace Hyperbar.Windows.Primary;
|
||||||
|
|
||||||
public class WidgetComponentEnumerationHandler(PrimaryWidgetConfiguration configuration,
|
public class WidgetComponentEnumerationHandler(PrimaryWidgetConfiguration configuration,
|
||||||
IFactory<PrimaryCommandConfiguration, IWidgetComponentViewModel?> factory,
|
IFactory<PrimaryCommandConfiguration, IWidgetComponentViewModel?> factory,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
|
using Hyperbar.Widget;
|
||||||
|
|
||||||
namespace Hyperbar.Windows.Primary;
|
namespace Hyperbar.Windows.Primary;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
namespace Hyperbar.Windows.Primary;
|
using Hyperbar.Widget;
|
||||||
|
|
||||||
|
namespace Hyperbar.Windows.Primary;
|
||||||
|
|
||||||
public class WidgetComponentProvider(ICache<Guid, IWidgetComponentViewModel> cache) :
|
public class WidgetComponentProvider(ICache<Guid, IWidgetComponentViewModel> cache) :
|
||||||
IProvider<PrimaryCommandConfiguration, IWidgetComponentViewModel?>
|
IProvider<PrimaryCommandConfiguration, IWidgetComponentViewModel?>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Hyperbar.Windows.Controls;
|
using Hyperbar.Widget;
|
||||||
|
using Hyperbar.Windows.Controls;
|
||||||
using Hyperbar.Windows.Interop;
|
using Hyperbar.Windows.Interop;
|
||||||
using Hyperbar.Windows.UI;
|
using Hyperbar.Windows.UI;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
<HasPackageAndPublishMenu>true</HasPackageAndPublishMenu>
|
<HasPackageAndPublishMenu>true</HasPackageAndPublishMenu>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Hyperbar.Widget\Hyperbar.Widget.csproj" />
|
||||||
<ProjectReference Include="..\Hyperbar.Windows.Controls\Hyperbar.Windows.Controls.csproj" />
|
<ProjectReference Include="..\Hyperbar.Windows.Controls\Hyperbar.Windows.Controls.csproj" />
|
||||||
<ProjectReference Include="..\Hyperbar.Windows.Interop\Hyperbar.Windows.Interop.csproj" />
|
<ProjectReference Include="..\Hyperbar.Windows.Interop\Hyperbar.Windows.Interop.csproj" />
|
||||||
<ProjectReference Include="..\Hyperbar.Windows.UI\Hyperbar.Windows.UI.csproj" />
|
<ProjectReference Include="..\Hyperbar.Windows.UI\Hyperbar.Windows.UI.csproj" />
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Hyperbar.Windows.Controls;
|
using Hyperbar.Widget;
|
||||||
|
using Hyperbar.Windows.Controls;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
namespace Hyperbar.Windows;
|
namespace Hyperbar.Windows;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using Hyperbar.Widget;
|
||||||
using Microsoft.UI.Xaml.Controls;
|
using Microsoft.UI.Xaml.Controls;
|
||||||
|
|
||||||
namespace Hyperbar.Windows;
|
namespace Hyperbar.Windows;
|
||||||
|
|||||||
+19
-1
@@ -17,7 +17,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hyperbar.Windows.UI", "Hype
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "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
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hyperbar.Windows.MediaController", "Hyperbar.Windows.MediaController\Hyperbar.Windows.MediaController.csproj", "{88C3EC90-C48C-47B9-89A8-740EFFFE5AAD}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hyperbar.Windows.MediaController", "Hyperbar.Windows.MediaController\Hyperbar.Windows.MediaController.csproj", "{88C3EC90-C48C-47B9-89A8-740EFFFE5AAD}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hyperbar.Widget", "Hyperbar.Widget\Hyperbar.Widget.csproj", "{D38F95E6-744B-45DB-AF67-F331FB73615A}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@@ -167,6 +169,22 @@ Global
|
|||||||
{88C3EC90-C48C-47B9-89A8-740EFFFE5AAD}.Release|x64.Build.0 = 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.ActiveCfg = Release|Any CPU
|
||||||
{88C3EC90-C48C-47B9-89A8-740EFFFE5AAD}.Release|x86.Build.0 = Release|Any CPU
|
{88C3EC90-C48C-47B9-89A8-740EFFFE5AAD}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{D38F95E6-744B-45DB-AF67-F331FB73615A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{D38F95E6-744B-45DB-AF67-F331FB73615A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{D38F95E6-744B-45DB-AF67-F331FB73615A}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
||||||
|
{D38F95E6-744B-45DB-AF67-F331FB73615A}.Debug|ARM64.Build.0 = Debug|Any CPU
|
||||||
|
{D38F95E6-744B-45DB-AF67-F331FB73615A}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{D38F95E6-744B-45DB-AF67-F331FB73615A}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{D38F95E6-744B-45DB-AF67-F331FB73615A}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{D38F95E6-744B-45DB-AF67-F331FB73615A}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{D38F95E6-744B-45DB-AF67-F331FB73615A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{D38F95E6-744B-45DB-AF67-F331FB73615A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{D38F95E6-744B-45DB-AF67-F331FB73615A}.Release|ARM64.ActiveCfg = Release|Any CPU
|
||||||
|
{D38F95E6-744B-45DB-AF67-F331FB73615A}.Release|ARM64.Build.0 = Release|Any CPU
|
||||||
|
{D38F95E6-744B-45DB-AF67-F331FB73615A}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{D38F95E6-744B-45DB-AF67-F331FB73615A}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{D38F95E6-744B-45DB-AF67-F331FB73615A}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{D38F95E6-744B-45DB-AF67-F331FB73615A}.Release|x86.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
@@ -149,18 +149,9 @@ public static class IServiceCollectionExtensions
|
|||||||
|
|
||||||
services.AddSingleton<IDisposer, Disposer>();
|
services.AddSingleton<IDisposer, Disposer>();
|
||||||
|
|
||||||
services.AddTransient<IInitializer, WidgetInitializer>();
|
|
||||||
services.AddTransient<IFactory<Type, IWidget>, WidgetFactory>();
|
|
||||||
|
|
||||||
services.AddHandler<WidgetEnumerationHandler>();
|
|
||||||
services.AddHandler<WidgetAssemblyHandler>();
|
|
||||||
services.AddHandler<WidgetHandler>();
|
|
||||||
services.AddHandler<WidgetHostHandler>();
|
|
||||||
|
|
||||||
services.AddTransient<IFactory<IWidgetHost, WidgetContainerViewModel?>, WidgetContainerFactory>();
|
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IServiceCollection AddHandler<THandler>(this IServiceCollection services,
|
public static IServiceCollection AddHandler<THandler>(this IServiceCollection services,
|
||||||
ServiceLifetime lifetime = ServiceLifetime.Transient)
|
ServiceLifetime lifetime = ServiceLifetime.Transient)
|
||||||
where THandler :
|
where THandler :
|
||||||
@@ -225,44 +216,4 @@ public static class IServiceCollectionExtensions
|
|||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IServiceCollection AddWidgetTemplate<TWidgetContent>(this IServiceCollection services)
|
|
||||||
where TWidgetContent :
|
|
||||||
IWidgetViewModel
|
|
||||||
{
|
|
||||||
Type contentType = typeof(TWidgetContent);
|
|
||||||
Type templateType = typeof(IWidgetView);
|
|
||||||
|
|
||||||
string key = contentType.Name;
|
|
||||||
|
|
||||||
services.AddTransient(typeof(IWidgetViewModel), contentType);
|
|
||||||
services.TryAddTransient(templateType, provider => provider.GetService<IWidgetView>()!);
|
|
||||||
|
|
||||||
services.AddKeyedTransient(typeof(IWidgetViewModel), key, contentType);
|
|
||||||
services.TryAddKeyedTransient(key, (provider, key) => provider.GetService<IWidgetView>()!);
|
|
||||||
|
|
||||||
services.AddTransient<IContentTemplateDescriptor>(provider => new ContentTemplateDescriptor { ContentType = contentType, TemplateType = templateType, Key = key });
|
|
||||||
|
|
||||||
return services;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IServiceCollection AddWidgetTemplate<TWidgetContent, TWidgetTemplate>(this IServiceCollection services)
|
|
||||||
where TWidgetContent :
|
|
||||||
IWidgetViewModel
|
|
||||||
{
|
|
||||||
Type contentType = typeof(TWidgetContent);
|
|
||||||
Type templateType = typeof(TWidgetTemplate);
|
|
||||||
|
|
||||||
string key = contentType.Name;
|
|
||||||
|
|
||||||
services.AddTransient(typeof(IWidgetViewModel), contentType);
|
|
||||||
services.TryAddTransient(templateType);
|
|
||||||
|
|
||||||
services.AddKeyedTransient(typeof(IWidgetViewModel), key, contentType);
|
|
||||||
services.TryAddKeyedTransient(templateType, key);
|
|
||||||
|
|
||||||
services.AddTransient<IContentTemplateDescriptor>(provider => new ContentTemplateDescriptor { ContentType = contentType, TemplateType = templateType, Key = key });
|
|
||||||
|
|
||||||
return services;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user