Rename projects to better structure it. The aim is to try and keep it not dependant on the type of UI framework it uses thus allowing us to switch to another UI framework if we need later...
@@ -1,13 +0,0 @@
|
||||
using Hyperbar.Lifecycles;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Hyperbar.Desktop.Contextual;
|
||||
|
||||
public class ContextualCommandBuilder :
|
||||
ICommandBuilder
|
||||
{
|
||||
public void Create(IServiceCollection services)
|
||||
{
|
||||
services.AddCommandTemplate<ContextualCommandViewModel, ContextualCommandView>();
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
|
||||
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
|
||||
<RootNamespace>Hyperbar.Desktop.Controls</RootNamespace>
|
||||
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
|
||||
<UseWinUI>true</UseWinUI>
|
||||
<UseRidGraph>true</UseRidGraph>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.231202003-experimental1" />
|
||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.25936-preview" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Hyperbar.Desktop.Win32\Hyperbar.Desktop.Win32.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Update="CommandFlyout\CommandFlyoutPresenter.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</None>
|
||||
<None Update="Themes\Generic.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="CommandFlyout\CommandFlyoutPresenter.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="Themes\Generic.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,14 +0,0 @@
|
||||
using Hyperbar.Lifecycles;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Hyperbar.Desktop.Primary;
|
||||
|
||||
public class PrimaryCommandBuilder :
|
||||
ICommandBuilder
|
||||
{
|
||||
public void Create(IServiceCollection services)
|
||||
{
|
||||
services.AddCommandTemplate<PrimaryCommandViewModel, PrimaryCommandView>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
namespace Hyperbar.Desktop.Primary;
|
||||
|
||||
public sealed partial class PrimaryCommandView : Page
|
||||
{
|
||||
public PrimaryCommandView() => InitializeComponent();
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
using Hyperbar.Lifecycles;
|
||||
using Hyperbar.Templates;
|
||||
|
||||
namespace Hyperbar.Desktop.Primary;
|
||||
|
||||
public class PrimaryCommandConfiguration
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class PrimaryCommandViewModel(ITemplateFactory templateFactory) :
|
||||
ICommandViewModel,
|
||||
ITemplatedViewModel
|
||||
{
|
||||
public ITemplateFactory TemplateFactory { get; } = templateFactory;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
using Hyperbar.Lifecycles;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Hyperbar.Windows.Contextual;
|
||||
|
||||
public class ContextualCommandWidgetBuilder :
|
||||
ICommandWidgetBuilder
|
||||
{
|
||||
public void Create(IServiceCollection services)
|
||||
{
|
||||
services
|
||||
.AddWritableConfiguration<ContextualCommandWidgetConfiguration>()
|
||||
.AddCommandTemplate<ContextualCommandWidgetViewModel, ContextualCommandWidgetView>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
namespace Hyperbar.Windows.Contextual;
|
||||
|
||||
public class ContextualCommandWidgetConfiguration
|
||||
{
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Page
|
||||
x:Class="Hyperbar.Desktop.Contextual.ContextualCommandView"
|
||||
x:Class="Hyperbar.Windows.Contextual.ContextualCommandWidgetView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Grid>
|
||||
<Button Content="This is a test" Click="Button_Click"/>
|
||||
<Button Click="Button_Click" Content="This is a test" />
|
||||
</Grid>
|
||||
</Page>
|
||||
@@ -1,12 +1,12 @@
|
||||
using Hyperbar.Desktop.Win32;
|
||||
using Hyperbar.Windows.Win32;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Windows.System;
|
||||
|
||||
namespace Hyperbar.Desktop.Contextual;
|
||||
namespace Hyperbar.Windows.Contextual;
|
||||
|
||||
public sealed partial class ContextualCommandView : Page
|
||||
public sealed partial class ContextualCommandWidgetView : Page
|
||||
{
|
||||
public ContextualCommandView() => InitializeComponent();
|
||||
public ContextualCommandWidgetView() => InitializeComponent();
|
||||
|
||||
private void Button_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
|
||||
{
|
||||
@@ -1,10 +1,10 @@
|
||||
using Hyperbar.Lifecycles;
|
||||
using Hyperbar.Templates;
|
||||
|
||||
namespace Hyperbar.Desktop.Contextual;
|
||||
namespace Hyperbar.Windows.Contextual;
|
||||
|
||||
public class ContextualCommandViewModel(ITemplateFactory templateFactory) :
|
||||
ICommandViewModel,
|
||||
public class ContextualCommandWidgetViewModel(ITemplateFactory templateFactory) :
|
||||
ICommandWidgetViewModel,
|
||||
ITemplatedViewModel
|
||||
{
|
||||
public ITemplateFactory TemplateFactory { get; } = templateFactory;
|
||||
@@ -2,10 +2,12 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
|
||||
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
|
||||
<RootNamespace>Hyperbar.Desktop.Contextual</RootNamespace>
|
||||
<RootNamespace>Hyperbar.Windows.Contextual</RootNamespace>
|
||||
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
|
||||
<UseWinUI>true</UseWinUI>
|
||||
<UseRidGraph>true</UseRidGraph>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
||||
@@ -13,7 +15,7 @@
|
||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.25936-preview" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Hyperbar.Desktop.Win32\Hyperbar.Desktop.Win32.csproj" />
|
||||
<ProjectReference Include="..\Hyperbar.Windows.Win32\Hyperbar.Windows.Win32.csproj" />
|
||||
<ProjectReference Include="..\Hyperbar\Hyperbar.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,6 +1,6 @@
|
||||
using Microsoft.UI.Xaml;
|
||||
|
||||
namespace Hyperbar.Desktop.Controls;
|
||||
namespace Hyperbar.Windows.Controls;
|
||||
|
||||
public class DesktopFlyout :
|
||||
DependencyObject
|
||||
@@ -1,17 +1,15 @@
|
||||
using Microsoft.UI.Xaml;
|
||||
using Hyperbar.Desktop.Win32;
|
||||
using Hyperbar.Windows.Win32;
|
||||
using Microsoft.UI.Xaml.Controls.Primitives;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Windows.Foundation;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
|
||||
namespace Hyperbar.Desktop.Controls;
|
||||
namespace Hyperbar.Windows.Controls;
|
||||
|
||||
internal class DesktopFlyoutHost : Window
|
||||
{
|
||||
private readonly DesktopFlyoutPresenter presenter;
|
||||
private DesktopFlyoutPlacement placement;
|
||||
private Popup popup;
|
||||
private Popup? popup;
|
||||
|
||||
public DesktopFlyoutHost(DesktopFlyoutPresenter presenter)
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Hyperbar.Desktop.Controls;
|
||||
namespace Hyperbar.Windows.Controls;
|
||||
|
||||
public enum DesktopFlyoutPlacement
|
||||
{
|
||||
@@ -2,7 +2,7 @@
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
|
||||
namespace Hyperbar.Desktop.Controls;
|
||||
namespace Hyperbar.Windows.Controls;
|
||||
|
||||
public class DesktopFlyoutPresenter :
|
||||
ContentControl
|
||||
@@ -2,7 +2,7 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="using:Hyperbar.Desktop.Controls">
|
||||
xmlns:controls="using:Hyperbar.Windows.Controls">
|
||||
<ResourceDictionary.ThemeDictionaries>
|
||||
<ResourceDictionary x:Key="Default">
|
||||
<StaticResource x:Key="CommandBarFlyoutBackground" ResourceKey="AcrylicInAppFillColorDefaultBrush" />
|
||||
@@ -1,6 +1,6 @@
|
||||
using Microsoft.UI.Xaml;
|
||||
|
||||
namespace Hyperbar.Desktop.Controls;
|
||||
namespace Hyperbar.Windows.Controls;
|
||||
|
||||
public class DesktopFlyoutPresenterTemplateSettings : DependencyObject
|
||||
{
|
||||
@@ -0,0 +1,19 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
|
||||
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
|
||||
<RootNamespace>Hyperbar.Windows.Controls</RootNamespace>
|
||||
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
|
||||
<UseWinUI>true</UseWinUI>
|
||||
<UseRidGraph>true</UseRidGraph>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.231202003-experimental1" />
|
||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.25936-preview" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Hyperbar.Windows.Win32\Hyperbar.Windows.Win32.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="ms-appx:///Hyperbar.Desktop.Controls/DesktopFlyout/DesktopFlyoutPresenter.xaml" />
|
||||
<ResourceDictionary Source="ms-appx:///Hyperbar.Windows.Controls/DesktopFlyout/DesktopFlyoutPresenter.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
@@ -2,10 +2,12 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
|
||||
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
|
||||
<RootNamespace>Hyperbar.Desktop.Primary</RootNamespace>
|
||||
<RootNamespace>Hyperbar.Windows.Primary</RootNamespace>
|
||||
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
|
||||
<UseWinUI>true</UseWinUI>
|
||||
<UseRidGraph>true</UseRidGraph>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<IsAotCompatible>True</IsAotCompatible>
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
|
||||
public interface IPrimaryCommand
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
|
||||
public class KeyAcceleratorCommand :
|
||||
IPrimaryCommand
|
||||
{
|
||||
public string? Icon { get; set; }
|
||||
|
||||
public string? Key { get; set; }
|
||||
|
||||
public string[]? Modifiers { get; set; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
|
||||
public class PrimaryCommandConfiguration : List<IPrimaryCommand>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
using Hyperbar.Lifecycles;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
|
||||
public class PrimaryCommandWidgetBuilder :
|
||||
ICommandWidgetBuilder
|
||||
{
|
||||
public void Create(IServiceCollection services)
|
||||
{
|
||||
services.AddWritableConfiguration<PrimaryCommandConfiguration>()
|
||||
.AddCommandTemplate<PrimaryCommandWidgetViewModel, PrimaryCommandWidgetView>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Page
|
||||
x:Class="Hyperbar.Desktop.Primary.PrimaryCommandView"
|
||||
x:Class="Hyperbar.Windows.Primary.PrimaryCommandWidgetView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Grid>
|
||||
@@ -0,0 +1,8 @@
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
|
||||
public sealed partial class PrimaryCommandWidgetView : Page
|
||||
{
|
||||
public PrimaryCommandWidgetView() => InitializeComponent();
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using Hyperbar.Lifecycles;
|
||||
using Hyperbar.Templates;
|
||||
using Windows.System;
|
||||
|
||||
namespace Hyperbar.Windows.Primary;
|
||||
|
||||
public class PrimaryCommandWidgetViewModel :
|
||||
ICommandWidgetViewModel,
|
||||
ITemplatedViewModel
|
||||
{
|
||||
public PrimaryCommandWidgetViewModel(ITemplateFactory templateFactory,
|
||||
IWritableConfiguration<PrimaryCommandConfiguration> configuration)
|
||||
{
|
||||
TemplateFactory = templateFactory;
|
||||
|
||||
configuration.Write(args => { args.Add(new KeyAcceleratorCommand { Key = $"138" , Modifiers = [$"{VirtualKey.LeftWindows}"] }); });
|
||||
configuration.Write(args => { args.Add(new KeyAcceleratorCommand { Key = $"{VirtualKey.Tab}", Modifiers = [$"{VirtualKey.LeftWindows}"] }); });
|
||||
configuration.Write(args => { args.Add(new KeyAcceleratorCommand { Key = $"{VirtualKey.L}", Modifiers = [$"{VirtualKey.LeftWindows}", $"{VirtualKey.Control}"] }); });
|
||||
}
|
||||
|
||||
public ITemplateFactory TemplateFactory { get; }
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ using Windows.Win32.Graphics.Gdi;
|
||||
using System.Runtime.InteropServices;
|
||||
using Windows.Win32.UI.WindowsAndMessaging;
|
||||
|
||||
namespace Hyperbar.Desktop.Win32;
|
||||
namespace Hyperbar.Windows.Win32;
|
||||
|
||||
public static class HwndExtensions
|
||||
{
|
||||
@@ -4,7 +4,7 @@ using System;
|
||||
using Windows.UI.Popups;
|
||||
using WinRT.Interop;
|
||||
|
||||
namespace Hyperbar.Desktop.Win32;
|
||||
namespace Hyperbar.Windows.Win32;
|
||||
|
||||
public static class WindowExtensions
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Hyperbar.Desktop.Win32;
|
||||
namespace Hyperbar.Windows.Win32;
|
||||
|
||||
public enum WindowPlacement
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace Hyperbar.Desktop.Win32;
|
||||
namespace Hyperbar.Windows.Win32;
|
||||
|
||||
[Flags]
|
||||
public enum WindowStyle
|
||||
@@ -5,7 +5,7 @@ using Windows.System;
|
||||
using Windows.Win32;
|
||||
using Windows.Win32.UI.KeyboardAndMouseInput;
|
||||
|
||||
namespace Hyperbar.Desktop.Win32;
|
||||
namespace Hyperbar.Windows.Win32;
|
||||
|
||||
public class KeyInterop
|
||||
{
|
||||
@@ -1,9 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Application
|
||||
x:Class="Hyperbar.Desktop.App"
|
||||
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.Desktop">
|
||||
xmlns:desktop="using:Hyperbar.Windows">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
@@ -1,21 +1,15 @@
|
||||
using Hyperbar.Desktop.Contextual;
|
||||
using Hyperbar.Desktop.Controls;
|
||||
using Hyperbar.Desktop.Primary;
|
||||
using Hyperbar.Windows.Contextual;
|
||||
using Hyperbar.Windows.Controls;
|
||||
using Hyperbar.Windows.Primary;
|
||||
using Hyperbar.Lifecycles;
|
||||
using Hyperbar.Templates;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.UI.Xaml;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hyperbar.Desktop;
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
public class AppConfiguration
|
||||
{
|
||||
|
||||
}
|
||||
public partial class App :
|
||||
Application
|
||||
{
|
||||
@@ -46,17 +40,17 @@ public partial class App :
|
||||
|
||||
services.AddDataTemplate<CommandViewModel, CommandView>();
|
||||
|
||||
services.AddCommand<ContextualCommandBuilder>("");
|
||||
services.AddCommand<PrimaryCommandBuilder>("");
|
||||
services.AddCommand<ContextualCommandWidgetBuilder>("");
|
||||
services.AddCommand<PrimaryCommandWidgetBuilder>("");
|
||||
|
||||
services.AddTransient(provider =>
|
||||
{
|
||||
static IEnumerable<ICommandViewModel> Resolve(IServiceProvider services)
|
||||
static IEnumerable<ICommandWidgetViewModel> Resolve(IServiceProvider services)
|
||||
{
|
||||
foreach (ICommandContext commandContext in services.GetServices<ICommandContext>())
|
||||
foreach (ICommandWidgetContext commandContext in services.GetServices<ICommandWidgetContext>())
|
||||
{
|
||||
if (commandContext.ServiceProvider.GetService<ICommandViewModel>() is
|
||||
ICommandViewModel commandViewModel)
|
||||
if (commandContext.ServiceProvider.GetService<ICommandWidgetViewModel>() is
|
||||
ICommandWidgetViewModel commandViewModel)
|
||||
{
|
||||
yield return commandViewModel;
|
||||
}
|
||||
@@ -65,11 +59,9 @@ public partial class App :
|
||||
|
||||
return Resolve(provider);
|
||||
});
|
||||
|
||||
services.ConfigureWritableOptions<AppConfiguration>();
|
||||
|
||||
})
|
||||
.Build();
|
||||
|
||||
await host.RunAsync();
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 432 B After Width: | Height: | Size: 432 B |
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 637 B After Width: | Height: | Size: 637 B |
|
Before Width: | Height: | Size: 283 B After Width: | Height: | Size: 283 B |
|
Before Width: | Height: | Size: 456 B After Width: | Height: | Size: 456 B |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
@@ -3,7 +3,7 @@
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
|
||||
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
|
||||
<RootNamespace>Hyperbar.Desktop</RootNamespace>
|
||||
<RootNamespace>Hyperbar.Windows</RootNamespace>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<Platforms>x86;x64;ARM64</Platforms>
|
||||
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
|
||||
@@ -11,6 +11,7 @@
|
||||
<UseRidGraph>true</UseRidGraph>
|
||||
<UseWinUI>true</UseWinUI>
|
||||
<EnableMsixTooling>true</EnableMsixTooling>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
@@ -36,9 +37,9 @@
|
||||
<ProjectCapability Include="Msix" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Hyperbar.Desktop.Contextual\Hyperbar.Desktop.Contextual.csproj" />
|
||||
<ProjectReference Include="..\Hyperbar.Desktop.Controls\Hyperbar.Desktop.Controls.csproj" />
|
||||
<ProjectReference Include="..\Hyperbar.Desktop.Primary\Hyperbar.Desktop.Primary.csproj" />
|
||||
<ProjectReference Include="..\Hyperbar.Windows.Contextual\Hyperbar.Windows.Contextual.csproj" />
|
||||
<ProjectReference Include="..\Hyperbar.Windows.Controls\Hyperbar.Windows.Controls.csproj" />
|
||||
<ProjectReference Include="..\Hyperbar.Windows.Primary\Hyperbar.Windows.Primary.csproj" />
|
||||
<ProjectReference Include="..\Hyperbar\Hyperbar.csproj" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Condition="'$(DisableHasPackageAndPublishMenuAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
|
||||
@@ -1,9 +1,9 @@
|
||||
using Hyperbar.Desktop.Controls;
|
||||
using Hyperbar.Windows.Controls;
|
||||
using Hyperbar.Lifecycles;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hyperbar.Desktop;
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
public class AppInitializer([FromKeyedServices(nameof(CommandViewModel))] CommandView view,
|
||||
[FromKeyedServices(nameof(CommandViewModel))] CommandViewModel viewModel,
|
||||
@@ -3,14 +3,14 @@ using Hyperbar.Templates;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace Hyperbar.Desktop
|
||||
namespace Hyperbar.Windows
|
||||
{
|
||||
public static class IServiceCollectionExtensions
|
||||
{
|
||||
public static IServiceCollection AddCommand<TCommandBuilder>(this IServiceCollection services,
|
||||
string key)
|
||||
where TCommandBuilder :
|
||||
ICommandBuilder, new()
|
||||
ICommandWidgetBuilder, new()
|
||||
{
|
||||
TCommandBuilder builder = new();
|
||||
IHost? host = new HostBuilder()
|
||||
@@ -22,7 +22,7 @@ namespace Hyperbar.Desktop
|
||||
builder.Create(isolatedServices);
|
||||
}).Build();
|
||||
|
||||
services.AddTransient<ICommandContext>(provider => new CommandContext(host.Services));
|
||||
services.AddTransient<ICommandWidgetContext>(provider => new CommandWidgetContext(host.Services));
|
||||
return services;
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@
|
||||
<mp:PhoneIdentity PhoneProductId="24ccddba-447f-4d37-891d-523e8d820f45" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
|
||||
|
||||
<Properties>
|
||||
<DisplayName>Hyperbar.Desktop</DisplayName>
|
||||
<DisplayName>Hyperbar.Windows</DisplayName>
|
||||
<PublisherDisplayName>dan_c</PublisherDisplayName>
|
||||
<Logo>Assets\StoreLogo.png</Logo>
|
||||
</Properties>
|
||||
@@ -34,8 +34,8 @@
|
||||
Executable="$targetnametoken$.exe"
|
||||
EntryPoint="$targetentrypoint$">
|
||||
<uap:VisualElements
|
||||
DisplayName="Hyperbar.Desktop"
|
||||
Description="Hyperbar.Desktop"
|
||||
DisplayName="Hyperbar.Windows"
|
||||
Description="Hyperbar.Windows"
|
||||
BackgroundColor="transparent"
|
||||
Square150x150Logo="Assets\Square150x150Logo.png"
|
||||
Square44x44Logo="Assets\Square44x44Logo.png">
|
||||
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"profiles": {
|
||||
"Hyperbar.Desktop (Package)": {
|
||||
"Hyperbar.Windows (Package)": {
|
||||
"commandName": "MsixPackage"
|
||||
},
|
||||
"Hyperbar.Desktop (Unpackaged)": {
|
||||
"Hyperbar.Windows (Unpackaged)": {
|
||||
"commandName": "Project"
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
using Microsoft.UI.Xaml;
|
||||
|
||||
namespace Hyperbar.Desktop
|
||||
namespace Hyperbar.Windows
|
||||
{
|
||||
|
||||
public interface ITemplateGeneratorFactory
|
||||
@@ -6,7 +6,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Hyperbar.Desktop;
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
public class TemplateFactory(ITemplateGeneratorFactory factory,
|
||||
IEnumerable<IDataTemplateDescriptor> descriptors,
|
||||
@@ -2,7 +2,7 @@
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
namespace Hyperbar.Desktop;
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
public class TemplateGeneratorControl :
|
||||
ContentControl
|
||||
@@ -1,7 +1,7 @@
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Markup;
|
||||
|
||||
namespace Hyperbar.Desktop;
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
public class TemplateGeneratorFactory :
|
||||
ITemplateGeneratorFactory
|
||||
@@ -10,7 +10,7 @@ public class TemplateGeneratorFactory :
|
||||
{
|
||||
string xamlString = @"
|
||||
<DataTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
|
||||
xmlns:desktop='using:Hyperbar.Desktop'>
|
||||
xmlns:desktop='using:Hyperbar.Windows'>
|
||||
<desktop:TemplateGeneratorControl />
|
||||
</DataTemplate>";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Page
|
||||
x:Class="Hyperbar.Desktop.CommandView"
|
||||
x:Class="Hyperbar.Windows.CommandView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<ItemsControl ItemTemplateSelector="{Binding TemplateFactory}" ItemsSource="{Binding}">
|
||||
@@ -1,7 +1,7 @@
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Input;
|
||||
|
||||
namespace Hyperbar.Desktop;
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
public sealed partial class CommandView : Page
|
||||
{
|
||||
@@ -2,20 +2,17 @@
|
||||
using Hyperbar.Templates;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hyperbar.Desktop;
|
||||
namespace Hyperbar.Windows;
|
||||
|
||||
public partial class CommandViewModel :
|
||||
ObservableCollectionViewModel,
|
||||
ITemplatedViewModel
|
||||
{
|
||||
public CommandViewModel(ITemplateFactory templateFactory,
|
||||
IEnumerable<ICommandViewModel> commands,
|
||||
IWritableConfiguration<AppConfiguration> options)
|
||||
IEnumerable<ICommandWidgetViewModel> commands)
|
||||
{
|
||||
TemplateFactory = templateFactory;
|
||||
AddRange(commands);
|
||||
|
||||
options.Update(args => { });
|
||||
}
|
||||
|
||||
public ITemplateFactory TemplateFactory { get; }
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<assemblyIdentity version="1.0.0.0" name="Hyperbar.Desktop.app"/>
|
||||
<assemblyIdentity version="1.0.0.0" name="Hyperbar.Windows.app"/>
|
||||
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
@@ -3,17 +3,17 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.8.34330.188
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hyperbar.Desktop", "Hyperbar.Desktop\Hyperbar.Desktop.csproj", "{5C4824EE-23AB-495C-B55A-1F7C2A489698}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hyperbar.Windows", "Hyperbar.Windows\Hyperbar.Windows.csproj", "{5C4824EE-23AB-495C-B55A-1F7C2A489698}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hyperbar.Desktop.Controls", "Hyperbar.Desktop.Controls\Hyperbar.Desktop.Controls.csproj", "{48ECC6A3-94FF-405D-9DB5-46A725C1B117}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hyperbar.Windows.Controls", "Hyperbar.Windows.Controls\Hyperbar.Windows.Controls.csproj", "{48ECC6A3-94FF-405D-9DB5-46A725C1B117}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hyperbar.Desktop.Win32", "Hyperbar.Desktop.Win32\Hyperbar.Desktop.Win32.csproj", "{8A4BBC50-970C-4FA8-9F21-0FA63269222F}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hyperbar.Windows.Win32", "Hyperbar.Windows.Win32\Hyperbar.Windows.Win32.csproj", "{8A4BBC50-970C-4FA8-9F21-0FA63269222F}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hyperbar", "Hyperbar\Hyperbar.csproj", "{E5795878-C7E3-4386-86FA-33681BCF8D5B}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hyperbar.Desktop.Contextual", "Hyperbar.Desktop.Contextual\Hyperbar.Desktop.Contextual.csproj", "{C32D4073-2A9B-4257-8895-09951FAD8E7A}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hyperbar.Windows.Contextual", "Hyperbar.Windows.Contextual\Hyperbar.Windows.Contextual.csproj", "{C32D4073-2A9B-4257-8895-09951FAD8E7A}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hyperbar.Desktop.Primary", "Hyperbar.Desktop.Primary\Hyperbar.Desktop.Primary.csproj", "{AFB8A3EB-8831-4041-AE05-3E0EF672887C}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hyperbar.Windows.Primary", "Hyperbar.Windows.Primary\Hyperbar.Windows.Primary.csproj", "{AFB8A3EB-8831-4041-AE05-3E0EF672887C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
||||
@@ -23,15 +23,16 @@ public class ConfigurationWriter<TConfiguration>(string path,
|
||||
|
||||
private readonly JsonSerializerOptions? serializerOptions = serializerOptions ??= DefaultSerializerOptions();
|
||||
|
||||
public void Write(Action<TConfiguration?>? updateDelegate = null)
|
||||
public void Write(Action<TConfiguration> updateDelegate)
|
||||
{
|
||||
TConfiguration? updatedValue = TryGet(out TConfiguration? value) ? value : new TConfiguration();
|
||||
|
||||
updateDelegate?.Invoke(updatedValue);
|
||||
Write(updatedValue);
|
||||
if ((TryGet(out TConfiguration? value) ? value : new TConfiguration()) is TConfiguration updatedValue)
|
||||
{
|
||||
updateDelegate?.Invoke(updatedValue);
|
||||
Write(updatedValue);
|
||||
}
|
||||
}
|
||||
|
||||
public void Write(TConfiguration? value)
|
||||
public void Write(TConfiguration value)
|
||||
{
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
@@ -81,7 +82,7 @@ public class ConfigurationWriter<TConfiguration>(string path,
|
||||
stream.SetLength(stream.Position);
|
||||
}
|
||||
|
||||
private bool TryGet<T>(out T? value)
|
||||
private bool TryGet(out TConfiguration? value)
|
||||
{
|
||||
if (File.Exists(path))
|
||||
{
|
||||
@@ -90,7 +91,7 @@ public class ConfigurationWriter<TConfiguration>(string path,
|
||||
using JsonDocument jsonDocument = JsonDocument.Parse(jsonContent);
|
||||
if (jsonDocument.RootElement.TryGetProperty(section, out JsonElement sectionValue))
|
||||
{
|
||||
value = JsonSerializer.Deserialize<T>(sectionValue.ToString(), serializerOptions);
|
||||
value = JsonSerializer.Deserialize<TConfiguration>(sectionValue.ToString(), serializerOptions);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ namespace Hyperbar.Options
|
||||
where TConfiguration :
|
||||
class, new()
|
||||
{
|
||||
void Write(Action<TConfiguration?>? updateDelegate = null);
|
||||
void Write(Action<TConfiguration> updateDelegate);
|
||||
|
||||
void Write(TConfiguration? value);
|
||||
void Write(TConfiguration value);
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,6 @@ public interface IWritableConfiguration<out TConfiguration> :
|
||||
where TConfiguration :
|
||||
class, new()
|
||||
{
|
||||
void Update(Action<TConfiguration?> updateAction,
|
||||
void Write(Action<TConfiguration> updateAction,
|
||||
bool reload = true);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ public class WritableConfiguration<TConfiguration>(IConfigurationWriter<TConfigu
|
||||
|
||||
public TConfiguration Get(string? name) => options.Get(name);
|
||||
|
||||
public void Update(Action<TConfiguration?> updateDelegate,
|
||||
public void Write(Action<TConfiguration> updateDelegate,
|
||||
bool reload = true)
|
||||
{
|
||||
writer.Write(updateDelegate);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using Hyperbar.Lifecycles;
|
||||
using Hyperbar.Options;
|
||||
using Hyperbar.Templates;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.FileProviders;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
@@ -11,16 +10,15 @@ using System.Text.Json;
|
||||
namespace Hyperbar;
|
||||
public static class IServiceCollectionExtensions
|
||||
{
|
||||
public static IServiceCollection ConfigureWritableOptions<TConfiguration>(this IServiceCollection services,
|
||||
string path = "Settings.json",
|
||||
Func<JsonSerializerOptions>? defaultSerializerOptions = null)
|
||||
public static IServiceCollection AddWritableConfiguration<TConfiguration>(this IServiceCollection services,
|
||||
string path = "Settings.json")
|
||||
where TConfiguration :
|
||||
class, new()
|
||||
{
|
||||
return services.ConfigureWritableOptions<TConfiguration>(typeof(TConfiguration).Name, path);
|
||||
return services.AddWritableConfiguration<TConfiguration>(typeof(TConfiguration).Name, path);
|
||||
}
|
||||
|
||||
public static IServiceCollection ConfigureWritableOptions<TConfiguration>(this IServiceCollection services,
|
||||
public static IServiceCollection AddWritableConfiguration<TConfiguration>(this IServiceCollection services,
|
||||
string section,
|
||||
string path = "Settings.json",
|
||||
Action<JsonSerializerOptions>? serializerDelegate = null)
|
||||
@@ -59,16 +57,16 @@ public static class IServiceCollectionExtensions
|
||||
|
||||
public static IServiceCollection AddCommandTemplate<TCommand, TCommandTemplate>(this IServiceCollection services)
|
||||
where TCommand :
|
||||
ICommandViewModel
|
||||
ICommandWidgetViewModel
|
||||
{
|
||||
Type dataType = typeof(TCommand);
|
||||
Type templateType = typeof(TCommandTemplate);
|
||||
|
||||
string key = dataType.Name;
|
||||
|
||||
services.AddTransient(typeof(ICommandViewModel), dataType);
|
||||
services.AddTransient(typeof(ICommandWidgetViewModel), dataType);
|
||||
services.AddTransient(templateType);
|
||||
services.AddKeyedTransient(typeof(ICommandViewModel), key, dataType);
|
||||
services.AddKeyedTransient(typeof(ICommandWidgetViewModel), key, dataType);
|
||||
services.AddKeyedTransient(templateType, key);
|
||||
|
||||
services.AddTransient<IDataTemplateDescriptor>(provider => new DataTemplateDescriptor
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace Hyperbar.Lifecycles;
|
||||
|
||||
public class CommandContext(IServiceProvider serviceProvider) :
|
||||
ICommandContext
|
||||
public class CommandWidgetContext(IServiceProvider serviceProvider) :
|
||||
ICommandWidgetContext
|
||||
{
|
||||
public IServiceProvider ServiceProvider => serviceProvider;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Hyperbar.Lifecycles;
|
||||
|
||||
public interface ICommandBuilder
|
||||
public interface ICommandWidgetBuilder
|
||||
{
|
||||
void Create(IServiceCollection services);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Hyperbar.Lifecycles;
|
||||
|
||||
public interface ICommandContext
|
||||
public interface ICommandWidgetContext
|
||||
{
|
||||
IServiceProvider ServiceProvider { get; }
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Hyperbar.Lifecycles;
|
||||
|
||||
public interface ICommandViewModel
|
||||
public interface ICommandWidgetViewModel
|
||||
{
|
||||
|
||||
}
|
||||