This commit is contained in:
Dan Clark
2024-11-16 13:52:42 +00:00
6 changed files with 79 additions and 17 deletions
+21
View File
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0-windows10.0.19041.0</TargetFramework>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<RootNamespace>Toolkit.UI.WinUI</RootNamespace>
<RuntimeIdentifiers Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) &gt;= 8">
win-x86;win-x64;win-arm64
</RuntimeIdentifiers>
<RuntimeIdentifiers Condition="$([MSBuild]::GetTargetFrameworkVersion('$(TargetFramework)')) &lt; 8">
win10-x86;win10-x64;win10-arm64
</RuntimeIdentifiers>
<UseWinUI>true</UseWinUI>
<WindowsSdkPackageVersion>10.0.19041.41</WindowsSdkPackageVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1742" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240923002" />
<PackageReference Include="WinUIEx" Version="2.4.2" />
</ItemGroup>
</Project>
+25
View File
@@ -0,0 +1,25 @@
using Microsoft.UI.Xaml;
using WinUIEx;
namespace Toolkit.UI.WinUI;
public static partial class WindowExtensions
{
public static void SetWindowStyle(this Window window,
WindowStyle style)
{
WinUIEx.WindowStyle windowStyle = window.GetWindowStyle();
switch (style)
{
case WindowStyle.None:
windowStyle &= ~(WinUIEx.WindowStyle.Caption |
WinUIEx.WindowStyle.ThickFrame |
WinUIEx.WindowStyle.Border |
WinUIEx.WindowStyle.SysMenu);
break;
}
window.SetWindowStyle(windowStyle);
}
}
+9
View File
@@ -0,0 +1,9 @@
namespace Toolkit.UI.WinUI;
public enum WindowStyle
{
None,
SingleBorderWindow,
ThreeDBorderWindow,
ToolWindow
}
@@ -1,9 +1,4 @@
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Toolkit.Foundation;
namespace Toolkit.WinUI;
@@ -12,7 +7,15 @@ public static class IServiceCollectionExtensions
{
public static IServiceCollection AddWinUI(this IServiceCollection services)
{
services.AddTransient<IDispatcher, WinUIDispatcher>();
services.AddTransient<IDispatcherTimerFactory, DispatcherTimerFactory>();
services.AddTransient((Func<IServiceProvider, IProxyServiceCollection<IComponentBuilder>>)(provider =>
new ProxyServiceCollection<IComponentBuilder>(services =>
{
})));
return services;
}
}
+14
View File
@@ -0,0 +1,14 @@
using Microsoft.UI.Dispatching;
using Toolkit.Foundation;
namespace Toolkit.WinUI;
public class WinUIDispatcher :
IDispatcher
{
public Task Invoke(Action action)
{
DispatcherQueue.GetForCurrentThread().TryEnqueue(action.Invoke);
return Task.CompletedTask;
}
}
+2 -12
View File
@@ -17,6 +17,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Toolkit.WinUI", "Toolkit.Wi
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Toolkit.Test", "Toolkit.Test\Toolkit.Test.csproj", "{E125F8EF-6B66-400F-9CDE-BC3DB1463F4E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Toolkit.UI.WinUI", "Toolkit.UI.WinUI\Toolkit.UI.WinUI.csproj", "{13C89DC0-5B75-4368-930D-D156B06E3F6A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -99,18 +101,6 @@ Global
{D90BFF29-B38C-432E-849A-28C5A88A6DDD}.Release|x64.Build.0 = Release|Any CPU
{D90BFF29-B38C-432E-849A-28C5A88A6DDD}.Release|x86.ActiveCfg = Release|Any CPU
{D90BFF29-B38C-432E-849A-28C5A88A6DDD}.Release|x86.Build.0 = Release|Any CPU
{E125F8EF-6B66-400F-9CDE-BC3DB1463F4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E125F8EF-6B66-400F-9CDE-BC3DB1463F4E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E125F8EF-6B66-400F-9CDE-BC3DB1463F4E}.Debug|x64.ActiveCfg = Debug|Any CPU
{E125F8EF-6B66-400F-9CDE-BC3DB1463F4E}.Debug|x64.Build.0 = Debug|Any CPU
{E125F8EF-6B66-400F-9CDE-BC3DB1463F4E}.Debug|x86.ActiveCfg = Debug|Any CPU
{E125F8EF-6B66-400F-9CDE-BC3DB1463F4E}.Debug|x86.Build.0 = Debug|Any CPU
{E125F8EF-6B66-400F-9CDE-BC3DB1463F4E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E125F8EF-6B66-400F-9CDE-BC3DB1463F4E}.Release|Any CPU.Build.0 = Release|Any CPU
{E125F8EF-6B66-400F-9CDE-BC3DB1463F4E}.Release|x64.ActiveCfg = Release|Any CPU
{E125F8EF-6B66-400F-9CDE-BC3DB1463F4E}.Release|x64.Build.0 = Release|Any CPU
{E125F8EF-6B66-400F-9CDE-BC3DB1463F4E}.Release|x86.ActiveCfg = Release|Any CPU
{E125F8EF-6B66-400F-9CDE-BC3DB1463F4E}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE