XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEExtension.NetCore.WinUIHelper

【DLL】WinUI的各种工具类,帮助开发者快速构建一个模块化的WinUI项目

公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/XFEExtension.NetCore.WinUIHelper

修复服务无法获取的bug

4d2219a
XFE工作室室长 <mail@xfegzs.com>
提交于

代码差异

19 个文件 +261 -8
Added XFEExtension.NetCore.WinUIHelper.TestApp/App.xaml +16 -0
@@ -0,0 +1,16 @@
1 <?xml version="1.0" encoding="utf-8"?>
2 <Application
3 x:Class="XFEExtension.NetCore.WinUIHelper.TestApp.App"
4 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
5 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
6 xmlns:local="using:XFEExtension.NetCore.WinUIHelper.TestApp">
7 <Application.Resources>
8 <ResourceDictionary>
9 <ResourceDictionary.MergedDictionaries>
10 <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
11 <!-- Other merged dictionaries here -->
12 </ResourceDictionary.MergedDictionaries>
13 <!-- Other app resources here -->
14 </ResourceDictionary>
15 </Application.Resources>
16 </Application>
Added XFEExtension.NetCore.WinUIHelper.TestApp/App.xaml.cs +38 -0
@@ -0,0 +1,38 @@
1 using Microsoft.UI.Xaml;
2 using System.Threading;
3 using System.Threading.Tasks;
4 using XFEExtension.NetCore.WinUIHelper.Interface.Services;
5 using XFEExtension.NetCore.WinUIHelper.Utilities;
6
7 namespace XFEExtension.NetCore.WinUIHelper.TestApp
8 {
9 /// <summary>
10 /// Provides application-specific behavior to supplement the default Application class.
11 /// </summary>
12 public partial class App : Application
13 {
14 /// <summary>
15 /// Initializes the singleton application object. This is the first line of authored code
16 /// executed, and as such is the logical equivalent of main() or WinMain().
17 /// </summary>
18 public App()
19 {
20 this.InitializeComponent();
21 var service1 = ServiceManager.GetService<INavigationParameterService<string?>>();
22 var service2 = ServiceManager.GetService<IDialogService>();
23 var service3 = ServiceManager.GetService<INavigationViewService>();
24 }
25
26 /// <summary>
27 /// Invoked when the application is launched.
28 /// </summary>
29 /// <param name="args">Details about the launch request and process.</param>
30 protected override void OnLaunched(LaunchActivatedEventArgs args)
31 {
32 m_window = new MainWindow();
33 m_window.Activate();
34 }
35
36 private Window? m_window;
37 }
38 }
Added XFEExtension.NetCore.WinUIHelper.TestApp/Assets/LockScreenLogo.scale-200.png +0 -0
二进制文件已变更,无法进行逐行预览。
Added XFEExtension.NetCore.WinUIHelper.TestApp/Assets/SplashScreen.scale-200.png +0 -0
二进制文件已变更,无法进行逐行预览。
Added XFEExtension.NetCore.WinUIHelper.TestApp/Assets/Square150x150Logo.scale-200.png +0 -0
二进制文件已变更,无法进行逐行预览。
Added XFEExtension.NetCore.WinUIHelper.TestApp/Assets/Square44x44Logo.scale-200.png +0 -0
二进制文件已变更,无法进行逐行预览。
Added XFEExtension.NetCore.WinUIHelper.TestApp/Assets/Square44x44Logo.targetsize-24_altform-unplated.png +0 -0
二进制文件已变更,无法进行逐行预览。
Added XFEExtension.NetCore.WinUIHelper.TestApp/Assets/StoreLogo.png +0 -0
二进制文件已变更,无法进行逐行预览。
Added XFEExtension.NetCore.WinUIHelper.TestApp/Assets/Wide310x150Logo.scale-200.png +0 -0
二进制文件已变更,无法进行逐行预览。
Added XFEExtension.NetCore.WinUIHelper.TestApp/MainWindow.xaml +15 -0
@@ -0,0 +1,15 @@
1 <?xml version="1.0" encoding="utf-8"?>
2 <Window
3 x:Class="XFEExtension.NetCore.WinUIHelper.TestApp.MainWindow"
4 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
5 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
6 xmlns:local="using:XFEExtension.NetCore.WinUIHelper.TestApp"
7 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
8 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9 mc:Ignorable="d"
10 Title="XFEExtension.NetCore.WinUIHelper.TestApp">
11
12 <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
13 <Button x:Name="myButton" Click="myButton_Click">Click Me</Button>
14 </StackPanel>
15 </Window>
Added XFEExtension.NetCore.WinUIHelper.TestApp/MainWindow.xaml.cs +36 -0
@@ -0,0 +1,36 @@
1 using Microsoft.UI.Xaml;
2 using Microsoft.UI.Xaml.Controls;
3 using Microsoft.UI.Xaml.Controls.Primitives;
4 using Microsoft.UI.Xaml.Data;
5 using Microsoft.UI.Xaml.Input;
6 using Microsoft.UI.Xaml.Media;
7 using Microsoft.UI.Xaml.Navigation;
8 using System;
9 using System.Collections.Generic;
10 using System.IO;
11 using System.Linq;
12 using System.Runtime.InteropServices.WindowsRuntime;
13 using Windows.Foundation;
14 using Windows.Foundation.Collections;
15
16 // To learn more about WinUI, the WinUI project structure,
17 // and more about our project templates, see: http://aka.ms/winui-project-info.
18
19 namespace XFEExtension.NetCore.WinUIHelper.TestApp
20 {
21 /// <summary>
22 /// An empty window that can be used on its own or navigated to within a Frame.
23 /// </summary>
24 public sealed partial class MainWindow : Window
25 {
26 public MainWindow()
27 {
28 this.InitializeComponent();
29 }
30
31 private void myButton_Click(object sender, RoutedEventArgs e)
32 {
33 myButton.Content = "Clicked";
34 }
35 }
36 }
Added XFEExtension.NetCore.WinUIHelper.TestApp/Package.appxmanifest +51 -0
@@ -0,0 +1,51 @@
1 <?xml version="1.0" encoding="utf-8"?>
2
3 <Package
4 xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
5 xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
6 xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
7 xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
8 IgnorableNamespaces="uap rescap">
9
10 <Identity
11 Name="872dce68-9369-4578-9c79-1629d4fe0f8b"
12 Publisher="CN=XFEstudio"
13 Version="1.0.0.0" />
14
15 <mp:PhoneIdentity PhoneProductId="872dce68-9369-4578-9c79-1629d4fe0f8b" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
16
17 <Properties>
18 <DisplayName>XFEExtension.NetCore.WinUIHelper.TestApp</DisplayName>
19 <PublisherDisplayName>XFEstudio</PublisherDisplayName>
20 <Logo>Assets\StoreLogo.png</Logo>
21 </Properties>
22
23 <Dependencies>
24 <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
25 <TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
26 </Dependencies>
27
28 <Resources>
29 <Resource Language="x-generate"/>
30 </Resources>
31
32 <Applications>
33 <Application Id="App"
34 Executable="$targetnametoken$.exe"
35 EntryPoint="$targetentrypoint$">
36 <uap:VisualElements
37 DisplayName="XFEExtension.NetCore.WinUIHelper.TestApp"
38 Description="XFEExtension.NetCore.WinUIHelper.TestApp"
39 BackgroundColor="transparent"
40 Square150x150Logo="Assets\Square150x150Logo.png"
41 Square44x44Logo="Assets\Square44x44Logo.png">
42 <uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" />
43 <uap:SplashScreen Image="Assets\SplashScreen.png" />
44 </uap:VisualElements>
45 </Application>
46 </Applications>
47
48 <Capabilities>
49 <rescap:Capability Name="runFullTrust" />
50 </Capabilities>
51 </Package>
Added XFEExtension.NetCore.WinUIHelper.TestApp/Properties/launchSettings.json +10 -0
@@ -0,0 +1,10 @@
1 {
2 "profiles": {
3 "XFEExtension.NetCore.WinUIHelper.TestApp (Package)": {
4 "commandName": "MsixPackage"
5 },
6 "XFEExtension.NetCore.WinUIHelper.TestApp (Unpackaged)": {
7 "commandName": "Project"
8 }
9 }
10 }
Added XFEExtension.NetCore.WinUIHelper.TestApp/XFEExtension.NetCore.WinUIHelper.TestApp.csproj +62 -0
@@ -0,0 +1,62 @@
1 <Project Sdk="Microsoft.NET.Sdk">
2 <PropertyGroup>
3 <OutputType>WinExe</OutputType>
4 <TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
5 <TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
6 <RootNamespace>XFEExtension.NetCore.WinUIHelper.TestApp</RootNamespace>
7 <ApplicationManifest>app.manifest</ApplicationManifest>
8 <Platforms>x86;x64;ARM64</Platforms>
9 <RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
10 <PublishProfile>win-$(Platform).pubxml</PublishProfile>
11 <UseWinUI>true</UseWinUI>
12 <EnableMsixTooling>true</EnableMsixTooling>
13 <Nullable>enable</Nullable>
14 </PropertyGroup>
15
16 <ItemGroup>
17 <Content Include="Assets\SplashScreen.scale-200.png" />
18 <Content Include="Assets\LockScreenLogo.scale-200.png" />
19 <Content Include="Assets\Square150x150Logo.scale-200.png" />
20 <Content Include="Assets\Square44x44Logo.scale-200.png" />
21 <Content Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" />
22 <Content Include="Assets\StoreLogo.png" />
23 <Content Include="Assets\Wide310x150Logo.scale-200.png" />
24 </ItemGroup>
25
26 <ItemGroup>
27 <Manifest Include="$(ApplicationManifest)" />
28 </ItemGroup>
29
30 <!--
31 Defining the "Msix" ProjectCapability here allows the Single-project MSIX Packaging
32 Tools extension to be activated for this project even if the Windows App SDK Nuget
33 package has not yet been restored.
34 -->
35 <ItemGroup Condition="'$(DisableMsixProjectCapabilityAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
36 <ProjectCapability Include="Msix" />
37 </ItemGroup>
38 <ItemGroup>
39 <PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1742" />
40 <PackageReference Include="Microsoft.WindowsAppSDK" Version="1.7.250310001" />
41 </ItemGroup>
42 <ItemGroup>
43 <ProjectReference Include="..\XFEExtension.NetCore.WinUIHelper\XFEExtension.NetCore.WinUIHelper.csproj" />
44 </ItemGroup>
45
46 <!--
47 Defining the "HasPackageAndPublishMenuAddedByProject" property here allows the Solution
48 Explorer "Package and Publish" context menu entry to be enabled for this project even if
49 the Windows App SDK Nuget package has not yet been restored.
50 -->
51 <PropertyGroup Condition="'$(DisableHasPackageAndPublishMenuAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
52 <HasPackageAndPublishMenu>true</HasPackageAndPublishMenu>
53 </PropertyGroup>
54
55 <!-- Publish Properties -->
56 <PropertyGroup>
57 <PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun>
58 <PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">True</PublishReadyToRun>
59 <PublishTrimmed Condition="'$(Configuration)' == 'Debug'">False</PublishTrimmed>
60 <PublishTrimmed Condition="'$(Configuration)' != 'Debug'">True</PublishTrimmed>
61 </PropertyGroup>
62 </Project>
Added XFEExtension.NetCore.WinUIHelper.TestApp/app.manifest +19 -0
@@ -0,0 +1,19 @@
1 <?xml version="1.0" encoding="utf-8"?>
2 <assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
3 <assemblyIdentity version="1.0.0.0" name="XFEExtension.NetCore.WinUIHelper.TestApp.app"/>
4
5 <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
6 <application>
7 <!-- The ID below informs the system that this application is compatible with OS features first introduced in Windows 10.
8 It is necessary to support features in unpackaged applications, for example the custom titlebar implementation.
9 For more info see https://docs.microsoft.com/windows/apps/windows-app-sdk/use-windows-app-sdk-run-time#declare-os-compatibility-in-your-application-manifest -->
10 <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
11 </application>
12 </compatibility>
13
14 <application xmlns="urn:schemas-microsoft-com:asm.v3">
15 <windowsSettings>
16 <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
17 </windowsSettings>
18 </application>
19 </assembly>
Modified XFEExtension.NetCore.WinUIHelper.sln +8 -0
@@ -4,6 +4,8 @@ VisualStudioVersion = 17.14.35821.62
4 4 MinimumVisualStudioVersion = 10.0.40219.1
5 5 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XFEExtension.NetCore.WinUIHelper", "XFEExtension.NetCore.WinUIHelper\XFEExtension.NetCore.WinUIHelper.csproj", "{AB7464D4-D50E-4206-A54A-52D1984DBD75}"
6 6 EndProject
7 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XFEExtension.NetCore.WinUIHelper.TestApp", "XFEExtension.NetCore.WinUIHelper.TestApp\XFEExtension.NetCore.WinUIHelper.TestApp.csproj", "{C1FDD8F5-FFFE-4993-972A-2E89ED8BC0CB}"
8 EndProject
7 9 Global
8 10 GlobalSection(SolutionConfigurationPlatforms) = preSolution
9 11 Debug|Any CPU = Debug|Any CPU
@@ -14,6 +16,12 @@ Global
14 16 {AB7464D4-D50E-4206-A54A-52D1984DBD75}.Debug|Any CPU.Build.0 = Debug|Any CPU
15 17 {AB7464D4-D50E-4206-A54A-52D1984DBD75}.Release|Any CPU.ActiveCfg = Release|Any CPU
16 18 {AB7464D4-D50E-4206-A54A-52D1984DBD75}.Release|Any CPU.Build.0 = Release|Any CPU
19 {C1FDD8F5-FFFE-4993-972A-2E89ED8BC0CB}.Debug|Any CPU.ActiveCfg = Debug|x64
20 {C1FDD8F5-FFFE-4993-972A-2E89ED8BC0CB}.Debug|Any CPU.Build.0 = Debug|x64
21 {C1FDD8F5-FFFE-4993-972A-2E89ED8BC0CB}.Debug|Any CPU.Deploy.0 = Debug|x64
22 {C1FDD8F5-FFFE-4993-972A-2E89ED8BC0CB}.Release|Any CPU.ActiveCfg = Release|x64
23 {C1FDD8F5-FFFE-4993-972A-2E89ED8BC0CB}.Release|Any CPU.Build.0 = Release|x64
24 {C1FDD8F5-FFFE-4993-972A-2E89ED8BC0CB}.Release|Any CPU.Deploy.0 = Release|x64
17 25 EndGlobalSection
18 26 GlobalSection(SolutionProperties) = preSolution
19 27 HideSolutionNode = FALSE
Modified XFEExtension.NetCore.WinUIHelper/Interface/Services/INavigationParameterService.cs +0 -2
@@ -26,6 +26,4 @@ public interface INavigationParameterService<T> : IPageService
26 26 /// </summary>
27 27 /// <param name="parameter">新的参数</param>
28 28 void OnParameterChange(object? parameter);
29
30 static INavigationParameterService() => ServiceManager.RegisterService<T>(() => new NavigationParameterService<T>());
31 29 }
Modified XFEExtension.NetCore.WinUIHelper/Utilities/GlobalServiceManager.cs +3 -2
@@ -50,11 +50,12 @@ public static class ServiceManager
50 50 /// <returns></returns>
51 51 public static T? GetService<T>()
52 52 {
53 var type = typeof(T);
54 if (type.IsGenericType)
55 return (T?)Activator.CreateInstance(type.Assembly.GetType($"XFEExtension.NetCore.WinUIHelper.Implements.Services.{type.Name![1..]}")!.MakeGenericType(type.GenericTypeArguments));
53 56 var typeName = typeof(T).Name;
54 57 if (services.TryGetValue(typeName, out var ctr))
55 {
56 58 return (T?)ctr();
57 }
58 59 return default;
59 60 }
60 61 }
Modified XFEExtension.NetCore.WinUIHelper/XFEExtension.NetCore.WinUIHelper.csproj +3 -4
@@ -9,16 +9,14 @@
9 9 <Nullable>enable</Nullable>
10 10 <GenerateDocumentationFile>True</GenerateDocumentationFile>
11 11 <Title>XFEExtension.NetCore.WinUIHelper</Title>
12 <Version>1.0.1</Version>
12 <Version>1.0.2</Version>
13 13 <Authors>XFEstudio</Authors>
14 14 <PackageIcon>logoIcon.png</PackageIcon>
15 15 <Description>WinUI的各种工具类,帮助开发者快速构建一个模块化的WinUI项目</Description>
16 16 <Copyright>寰宇朽力网络科技有限公司版权所有</Copyright>
17 17 <NeutralLanguage>zh-CN</NeutralLanguage>
18 18 <PackageReadmeFile>README.md</PackageReadmeFile>
19 <PackageReleaseNotes>简化服务类实现,更新项目版本
20
21 在多个服务类中移除了对 `IWinUIService` 接口的实现,直接实现各自的服务接口。添加了 `INavigationParameterService` 的静态构造函数以注册服务。移除了 `IWinUIService` 接口及 `StandardApp`、`StandardMainWindow` 的相关实现,简化了代码结构。更新了 `GlobalServiceManager` 中的服务注册字典,确保服务正确实例化。`AppThemeHelper` 类中添加了对主窗口的引用,简化主题更改实现。项目文件版本号从 `1.0.0` 更新至 `1.0.1`,并调整了描述信息。</PackageReleaseNotes>
19 <PackageReleaseNotes>修复服务无法获取的bug</PackageReleaseNotes>
22 20 <PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
23 21 <PackageProjectUrl>https://github.com/XFEstudio/XFEExtension.NetCore.WinUIHelper</PackageProjectUrl>
24 22 <RepositoryUrl>https://github.com/XFEstudio/XFEExtension.NetCore.WinUIHelper.git</RepositoryUrl>
@@ -45,6 +43,7 @@
45 43 <PackageReference Include="Microsoft.WindowsAppSDK" Version="1.7.250310001" />
46 44 <PackageReference Include="XFEExtension.NetCore" Version="3.3.1" />
47 45 <PackageReference Include="XFEExtension.NetCore.AutoPath" Version="1.0.1" />
46 <PackageReference Include="XFEExtension.NetCore.XFEConsole" Version="1.1.2" />
48 47 </ItemGroup>
49 48 <ItemGroup>
50 49 <Using Include="Microsoft.UI.Xaml" />