Added primaey commands extenion/plugin
This commit is contained in:
@@ -2,7 +2,8 @@ using Microsoft.Extensions.DependencyInjection;
|
|||||||
|
|
||||||
namespace Hyperbar.Desktop.Contextual;
|
namespace Hyperbar.Desktop.Contextual;
|
||||||
|
|
||||||
public class ContextualCommandBuilder : ICommandBuilder
|
public class ContextualCommandBuilder :
|
||||||
|
ICommandBuilder
|
||||||
{
|
{
|
||||||
public void Create(IServiceCollection services)
|
public void Create(IServiceCollection services)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,13 +2,7 @@
|
|||||||
<Page
|
<Page
|
||||||
x:Class="Hyperbar.Desktop.Contextual.ContextualCommandView"
|
x:Class="Hyperbar.Desktop.Contextual.ContextualCommandView"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
||||||
xmlns:local="using:Hyperbar.Desktop.Contextual"
|
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
||||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
|
|
||||||
mc:Ignorable="d">
|
|
||||||
|
|
||||||
<Grid>
|
<Grid>
|
||||||
<Button Content="This is a test" Click="Button_Click"/>
|
<Button Content="This is a test" Click="Button_Click"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -10,6 +10,6 @@ public sealed partial class ContextualCommandView : Page
|
|||||||
|
|
||||||
private void Button_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
|
private void Button_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
KeyInterop.Type((VirtualKey)186, VirtualKey.LeftWindows);
|
KeyInterop.Type(VirtualKey.L, VirtualKey.LeftWindows, VirtualKey.Control);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,8 @@
|
|||||||
namespace Hyperbar.Desktop.Contextual;
|
namespace Hyperbar.Desktop.Contextual;
|
||||||
|
|
||||||
public class ContextualCommandViewModel :
|
public class ContextualCommandViewModel(ITemplateFactory templateFactory) :
|
||||||
ICommandViewModel,
|
ICommandViewModel,
|
||||||
ITemplatedViewModel
|
ITemplatedViewModel
|
||||||
{
|
{
|
||||||
public ContextualCommandViewModel(ITemplateFactory templateFactory)
|
public ITemplateFactory TemplateFactory { get; } = templateFactory;
|
||||||
{
|
|
||||||
TemplateFactory = templateFactory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ITemplateFactory TemplateFactory { get; }
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,27 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
|
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
|
||||||
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
|
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
|
||||||
<RootNamespace>Hyperbar.Desktop.Contextual</RootNamespace>
|
<RootNamespace>Hyperbar.Desktop.Contextual</RootNamespace>
|
||||||
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
|
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
|
||||||
<UseWinUI>true</UseWinUI>
|
<UseWinUI>true</UseWinUI>
|
||||||
<UseRidGraph>true</UseRidGraph>
|
<UseRidGraph>true</UseRidGraph>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Remove="ContextualCommandView.xaml" />
|
<None Remove="ContextualCommandView.xaml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
<ItemGroup>
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.231202003-experimental1" />
|
||||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.231202003-experimental1" />
|
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.25936-preview" />
|
||||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.25936-preview" />
|
</ItemGroup>
|
||||||
</ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Hyperbar.Desktop.Win32\Hyperbar.Desktop.Win32.csproj" />
|
||||||
<ItemGroup>
|
<ProjectReference Include="..\Hyperbar\Hyperbar.csproj" />
|
||||||
<ProjectReference Include="..\Hyperbar.Desktop.Win32\Hyperbar.Desktop.Win32.csproj" />
|
</ItemGroup>
|
||||||
<ProjectReference Include="..\Hyperbar\Hyperbar.csproj" />
|
<ItemGroup>
|
||||||
</ItemGroup>
|
<Page Update="ContextualCommandView.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<ItemGroup>
|
</Page>
|
||||||
<Page Update="ContextualCommandView.xaml">
|
</ItemGroup>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
|
||||||
</Page>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
|
||||||
|
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
|
||||||
|
<RootNamespace>Hyperbar.Desktop.Primary</RootNamespace>
|
||||||
|
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
|
||||||
|
<UseWinUI>true</UseWinUI>
|
||||||
|
<UseRidGraph>true</UseRidGraph>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Remove="PrimaryCommandView.xaml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
||||||
|
<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\Hyperbar.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Page Update="PrimaryCommandView.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
namespace Hyperbar.Desktop.Primary;
|
||||||
|
|
||||||
|
public class PrimaryCommandBuilder :
|
||||||
|
ICommandBuilder
|
||||||
|
{
|
||||||
|
public void Create(IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddCommandTemplate<PrimaryCommandViewModel, PrimaryCommandView>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<Page
|
||||||
|
x:Class="Hyperbar.Desktop.Primary.PrimaryCommandView"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
<Grid>
|
||||||
|
<Button Content="Primary commands" />
|
||||||
|
</Grid>
|
||||||
|
</Page>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
using Microsoft.UI.Xaml.Controls;
|
||||||
|
|
||||||
|
namespace Hyperbar.Desktop.Primary;
|
||||||
|
|
||||||
|
public sealed partial class PrimaryCommandView : Page
|
||||||
|
{
|
||||||
|
public PrimaryCommandView() => InitializeComponent();
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
namespace Hyperbar.Desktop.Primary;
|
||||||
|
|
||||||
|
public class PrimaryCommandViewModel(ITemplateFactory templateFactory) :
|
||||||
|
ICommandViewModel,
|
||||||
|
ITemplatedViewModel
|
||||||
|
{
|
||||||
|
public ITemplateFactory TemplateFactory { get; } = templateFactory;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ public class KeyInterop
|
|||||||
{
|
{
|
||||||
private static readonly VirtualKey[] extendedKeys = [
|
private static readonly VirtualKey[] extendedKeys = [
|
||||||
VirtualKey.Menu,
|
VirtualKey.Menu,
|
||||||
VirtualKey.Menu,
|
VirtualKey.LeftMenu,
|
||||||
VirtualKey.NumberKeyLock,
|
VirtualKey.NumberKeyLock,
|
||||||
VirtualKey.Insert,
|
VirtualKey.Insert,
|
||||||
VirtualKey.Delete,
|
VirtualKey.Delete,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Hyperbar.Desktop.Contextual;
|
using Hyperbar.Desktop.Contextual;
|
||||||
using Hyperbar.Desktop.Controls;
|
using Hyperbar.Desktop.Controls;
|
||||||
|
using Hyperbar.Desktop.Primary;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.UI.Xaml;
|
using Microsoft.UI.Xaml;
|
||||||
@@ -33,10 +34,11 @@ public partial class App :
|
|||||||
|
|
||||||
// Commands
|
// Commands
|
||||||
services.AddSomething<ContextualCommandBuilder>();
|
services.AddSomething<ContextualCommandBuilder>();
|
||||||
|
services.AddSomething<PrimaryCommandBuilder>();
|
||||||
|
|
||||||
services.AddTransient(provider =>
|
services.AddTransient(provider =>
|
||||||
{
|
{
|
||||||
IEnumerable<ICommandViewModel> Resolve(IServiceProvider services)
|
static IEnumerable<ICommandViewModel> Resolve(IServiceProvider services)
|
||||||
{
|
{
|
||||||
foreach (ICommandContext commandContext in services.GetServices<ICommandContext>())
|
foreach (ICommandContext commandContext in services.GetServices<ICommandContext>())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -43,6 +43,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Hyperbar.Desktop.Contextual\Hyperbar.Desktop.Contextual.csproj" />
|
<ProjectReference Include="..\Hyperbar.Desktop.Contextual\Hyperbar.Desktop.Contextual.csproj" />
|
||||||
<ProjectReference Include="..\Hyperbar.Desktop.Controls\Hyperbar.Desktop.Controls.csproj" />
|
<ProjectReference Include="..\Hyperbar.Desktop.Controls\Hyperbar.Desktop.Controls.csproj" />
|
||||||
|
<ProjectReference Include="..\Hyperbar.Desktop.Primary\Hyperbar.Desktop.Primary.csproj" />
|
||||||
<ProjectReference Include="..\Hyperbar\Hyperbar.csproj" />
|
<ProjectReference Include="..\Hyperbar\Hyperbar.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hyperbar", "Hyperbar\Hyperb
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hyperbar.Desktop.Contextual", "Hyperbar.Desktop.Contextual\Hyperbar.Desktop.Contextual.csproj", "{C32D4073-2A9B-4257-8895-09951FAD8E7A}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hyperbar.Desktop.Contextual", "Hyperbar.Desktop.Contextual\Hyperbar.Desktop.Contextual.csproj", "{C32D4073-2A9B-4257-8895-09951FAD8E7A}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hyperbar.Desktop.Primary", "Hyperbar.Desktop.Primary\Hyperbar.Desktop.Primary.csproj", "{AFB8A3EB-8831-4041-AE05-3E0EF672887C}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -113,6 +115,22 @@ Global
|
|||||||
{C32D4073-2A9B-4257-8895-09951FAD8E7A}.Release|x64.Build.0 = Release|Any CPU
|
{C32D4073-2A9B-4257-8895-09951FAD8E7A}.Release|x64.Build.0 = Release|Any CPU
|
||||||
{C32D4073-2A9B-4257-8895-09951FAD8E7A}.Release|x86.ActiveCfg = Release|Any CPU
|
{C32D4073-2A9B-4257-8895-09951FAD8E7A}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{C32D4073-2A9B-4257-8895-09951FAD8E7A}.Release|x86.Build.0 = Release|Any CPU
|
{C32D4073-2A9B-4257-8895-09951FAD8E7A}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{AFB8A3EB-8831-4041-AE05-3E0EF672887C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{AFB8A3EB-8831-4041-AE05-3E0EF672887C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{AFB8A3EB-8831-4041-AE05-3E0EF672887C}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
||||||
|
{AFB8A3EB-8831-4041-AE05-3E0EF672887C}.Debug|ARM64.Build.0 = Debug|Any CPU
|
||||||
|
{AFB8A3EB-8831-4041-AE05-3E0EF672887C}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{AFB8A3EB-8831-4041-AE05-3E0EF672887C}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{AFB8A3EB-8831-4041-AE05-3E0EF672887C}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{AFB8A3EB-8831-4041-AE05-3E0EF672887C}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{AFB8A3EB-8831-4041-AE05-3E0EF672887C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{AFB8A3EB-8831-4041-AE05-3E0EF672887C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{AFB8A3EB-8831-4041-AE05-3E0EF672887C}.Release|ARM64.ActiveCfg = Release|Any CPU
|
||||||
|
{AFB8A3EB-8831-4041-AE05-3E0EF672887C}.Release|ARM64.Build.0 = Release|Any CPU
|
||||||
|
{AFB8A3EB-8831-4041-AE05-3E0EF672887C}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{AFB8A3EB-8831-4041-AE05-3E0EF672887C}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{AFB8A3EB-8831-4041-AE05-3E0EF672887C}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{AFB8A3EB-8831-4041-AE05-3E0EF672887C}.Release|x86.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
Reference in New Issue
Block a user