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

HaloPixelToolBox

【WinUI3】基于USB HID通讯的花再音响工具箱

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

XFEstudio/HaloPixelToolBox

完善程序

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

代码差异

23 个文件 +393 -47
Modified .gitignore +3 -1
@@ -360,4 +360,6 @@ MigrationBackup/
360 360 .ionide/
361 361
362 362 # Fody - auto-generated XML schema
363 FodyWeavers.xsd
363 FodyWeavers.xsd
364 /HaloPixelToolBox.Installer.Package/Source.zip
365 /HaloPixelToolBox.Installer/Resources/Resource/Source.zip
Added HaloPixelToolBox.Installer.Package/HaloPixelToolBox.Installer.Package.csproj +20 -0
@@ -0,0 +1,20 @@
1 <Project Sdk="Microsoft.NET.Sdk">
2
3 <PropertyGroup>
4 <OutputType>Exe</OutputType>
5 <TargetFramework>net8.0</TargetFramework>
6 <ImplicitUsings>enable</ImplicitUsings>
7 <Nullable>enable</Nullable>
8 <InvariantGlobalization>true</InvariantGlobalization>
9 <ApplicationManifest>app.manifest</ApplicationManifest>
10 </PropertyGroup>
11
12 <ItemGroup>
13 <None Remove="Source.zip" />
14 </ItemGroup>
15
16 <ItemGroup>
17 <EmbeddedResource Include="Source.zip" />
18 </ItemGroup>
19
20 </Project>
Added HaloPixelToolBox.Installer.Package/Program.cs +42 -0
@@ -0,0 +1,42 @@
1 using System.Diagnostics;
2 using System.IO.Compression;
3 using System.Reflection;
4 using System.Text;
5
6 if (Assembly.GetExecutingAssembly().GetManifestResourceStream("HaloPixelToolBox.Installer.Package.Source.zip") is Stream innerStream)
7 {
8 try
9 {
10 Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
11 using var zipArchive = new ZipArchive(innerStream, ZipArchiveMode.Read, false, Encoding.GetEncoding("GB2312"));
12 foreach (var entry in zipArchive.Entries)
13 {
14 try
15 {
16 if (string.IsNullOrEmpty(entry.Name))
17 Directory.CreateDirectory(entry.FullName);
18 else
19 entry.ExtractToFile(entry.FullName, true);
20 }
21 catch (Exception ex)
22 {
23 Console.WriteLine(ex.Message);
24 }
25 }
26 }
27 catch (Exception ex)
28 {
29 Console.WriteLine($"安装时发生错误:{ex.Message}");
30 }
31 }
32 else
33 {
34 Console.WriteLine("未找到嵌入的资源文件:InstallerPackage.Source.zip");
35 }
36
37 Process.Start(new ProcessStartInfo
38 {
39 FileName = "Installer.exe",
40 Verb = "runas",
41 UseShellExecute = true
42 })?.Dispose();
Added HaloPixelToolBox.Installer.Package/app.manifest +79 -0
@@ -0,0 +1,79 @@
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="MyApplication.app"/>
4 <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
5 <security>
6 <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
7 <!-- UAC 清单选项
8 如果想要更改 Windows 用户帐户控制级别,请使用
9 以下节点之一替换 requestedExecutionLevel 节点。
10
11 <requestedExecutionLevel level="asInvoker" uiAccess="false" />
12 <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
13 <requestedExecutionLevel level="highestAvailable" uiAccess="false" />
14
15 指定 requestedExecutionLevel 元素将禁用文件和注册表虚拟化。
16 如果你的应用程序需要此虚拟化来实现向后兼容性,则移除此
17 元素。
18 -->
19 <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
20 </requestedPrivileges>
21 </security>
22 </trustInfo>
23
24 <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
25 <application>
26 <!-- 设计此应用程序与其一起工作且已针对此应用程序进行测试的
27 Windows 版本的列表。取消评论适当的元素,
28 Windows 将自动选择最兼容的环境。 -->
29
30 <!-- Windows Vista -->
31 <!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
32
33 <!-- Windows 7 -->
34 <!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
35
36 <!-- Windows 8 -->
37 <!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
38
39 <!-- Windows 8.1 -->
40 <!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
41
42 <!-- Windows 10 -->
43 <!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
44
45 </application>
46 </compatibility>
47
48 <!-- 指示该应用程序可感知 DPI 且 Windows 在 DPI 较高时将不会对其进行
49 自动缩放。Windows Presentation Foundation (WPF)应用程序自动感知 DPI,无需
50 选择加入。选择加入此设置的 Windows 窗体应用程序(面向 .NET Framework 4.6)还应
51 在其 app.config 中将 "EnableWindowsFormsHighDpiAutoResizing" 设置设置为 "true"。
52
53 将应用程序设为感知长路径。请参阅 https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation -->
54 <!--
55 <application xmlns="urn:schemas-microsoft-com:asm.v3">
56 <windowsSettings>
57 <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
58 <longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
59 </windowsSettings>
60 </application>
61 -->
62
63 <!-- 启用 Windows 公共控件和对话框的主题(Windows XP 和更高版本) -->
64 <!--
65 <dependency>
66 <dependentAssembly>
67 <assemblyIdentity
68 type="win32"
69 name="Microsoft.Windows.Common-Controls"
70 version="6.0.0.0"
71 processorArchitecture="*"
72 publicKeyToken="6595b64144ccf1df"
73 language="*"
74 />
75 </dependentAssembly>
76 </dependency>
77 -->
78
79 </assembly>
Modified HaloPixelToolBox.Installer/ViewModel/Pages/InstallPageViewModel.cs +2 -2
@@ -16,7 +16,7 @@ namespace HaloPixelToolBox.Installer.ViewModel.Pages
16 16 [ObservableProperty]
17 17 bool agreementChecked = false;
18 18 [ObservableProperty]
19 string installPath = @$"{Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86)}\HaloPixelToolBox.Installer";
19 string installPath = @$"{Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86)}\HaloPixelToolBox";
20 20 public InstallPage ViewPage { get; set; } = viewPage;
21 21
22 22 [RelayCommand]
@@ -37,7 +37,7 @@ namespace HaloPixelToolBox.Installer.ViewModel.Pages
37 37 if (openFolderDialog.ShowDialog() == true)
38 38 {
39 39 if (FileHelper.IsRootPath(openFolderDialog.FolderName))
40 InstallPath = $@"{openFolderDialog.FolderName}HaloPixelToolBox.Installer";
40 InstallPath = $@"{openFolderDialog.FolderName}HaloPixelToolBox";
41 41 else
42 42 InstallPath = openFolderDialog.FolderName;
43 43 SystemProfile.InstallPath = InstallPath;
Modified HaloPixelToolBox.Installer/ViewModel/Pages/InstallProgressPageViewModel.cs +1 -1
@@ -14,7 +14,7 @@ namespace HaloPixelToolBox.Installer.ViewModel.Pages
14 14 [RelayCommand]
15 15 void ConfirmSuccess()
16 16 {
17 var startInfo = new ProcessStartInfo(Path.Combine(SystemProfile.InstallPath, "花再工具箱.exe"))
17 var startInfo = new ProcessStartInfo(Path.Combine(SystemProfile.InstallPath, "HaloPixelToolBox.exe"))
18 18 {
19 19 UseShellExecute = true,
20 20 WorkingDirectory = SystemProfile.InstallPath
Modified HaloPixelToolBox.slnx +1 -0
@@ -4,6 +4,7 @@
4 4 <Platform Name="x64" />
5 5 <Platform Name="x86" />
6 6 </Configurations>
7 <Project Path="HaloPixelToolBox.Installer.Package/HaloPixelToolBox.Installer.Package.csproj" Id="d37a90a9-f8fa-4f45-80bb-e34dadffb7f9" />
7 8 <Project Path="HaloPixelToolBox.Installer/HaloPixelToolBox.Installer.csproj" Id="2ff32c8b-4030-4872-af93-8176e0a1edec" />
8 9 <Project Path="HaloPixelToolBox/HaloPixelToolBox.Core/HaloPixelToolBox.Core.csproj" />
9 10 <Project Path="HaloPixelToolBox/HaloPixelToolBox.Test/HaloPixelToolBox.Test.csproj" />
Modified HaloPixelToolBox/HaloPixelToolBox.Core/Utilities/CloudLyricsReader.cs +3 -1
@@ -6,6 +6,7 @@ namespace HaloPixelToolBox.Core.Utilities;
6 6
7 7 public class CloudMusicLyricsReader
8 8 {
9 public nint Address { get; set; }
9 10 public MemoryEditor Editor { get; set; } = new();
10 11
11 12 public bool Initialize()
@@ -13,6 +14,7 @@ public class CloudMusicLyricsReader
13 14 if (GetCloudMusicLyricsProcess() is Process process)
14 15 {
15 16 Editor.CurrentProcess = process;
17 Address = Editor.ResolvePointerAddress("cloudmusic.dll", 0x01CE4A50, 0xE0, 0x8, 0x120, 0x8, 0x0);
16 18 return true;
17 19 }
18 20 else
@@ -24,7 +26,7 @@ public class CloudMusicLyricsReader
24 26 public bool TryReadLyrics(out string lyrics)
25 27 {
26 28 lyrics = "无法读取歌词";
27 if (Editor.ReadMemory(Editor.ResolvePointerAddress("cloudmusic.dll", 0x01CE4A50, 0xE0, 0x8, 0x120, 0x8, 0x0), 200, out var buffer))
29 if (Editor.ReadMemory(Address, 200, out var buffer))
28 30 {
29 31 lyrics = Encoding.Unicode.GetString(buffer, 0, GetValidLength(buffer));
30 32 return true;
Modified HaloPixelToolBox/HaloPixelToolBox.Core/Utilities/HaloPixelDevice.cs +0 -5
@@ -35,11 +35,6 @@ public class HaloPixelDevice
35 35 using var stream = CurrentDevice?.Open();
36 36 byte[] package = new byte[64];
37 37 var data = HidPacketBuilder.Build(text);
38 foreach (var per in data)
39 {
40 Console.Write($"{per:x}");
41 }
42 Console.WriteLine();
43 38 Array.Copy(data, package, data.Length);
44 39 stream?.Write(package);
45 40 stream?.Close();
Modified HaloPixelToolBox/HaloPixelToolBox/App.xaml.cs +1 -0
@@ -2,6 +2,7 @@
2 2 using XFEExtension.NetCore.WinUIHelper.Interface.Services;
3 3 using XFEExtension.NetCore.WinUIHelper.Utilities;
4 4 using XFEExtension.NetCore.WinUIHelper.Utilities.Helper;
5 using XFEExtension.NetCore.XFEConsole;
5 6
6 7 namespace HaloPixelToolBox
7 8 {
Modified HaloPixelToolBox/HaloPixelToolBox/HaloPixelToolBox.csproj +5 -5
@@ -16,11 +16,9 @@
16 16 <Nullable>enable</Nullable>
17 17 </PropertyGroup>
18 18 <ItemGroup>
19 <None Remove="Styles\ConverterResources.xaml" />
19 20 <None Remove="Views\MainPage.xaml" />
20 21 </ItemGroup>
21 <ItemGroup>
22 <Page Remove="Styles\ConverterResources.xaml" />
23 </ItemGroup>
24 22
25 23 <ItemGroup>
26 24 <Content Include="Assets\SplashScreen.scale-200.png" />
@@ -60,7 +58,9 @@
60 58 <PackageReference Include="CommunityToolkit.WinUI.Controls.SettingsControls" Version="8.2.250402" />
61 59 <PackageReference Include="XFEExtension.NetCore" Version="3.3.*" />
62 60 <PackageReference Include="XFEExtension.NetCore.AutoConfig" Version="2.0.*" />
61 <PackageReference Include="XFEExtension.NetCore.UpgradeHelper" Version="1.0.1" />
63 62 <PackageReference Include="XFEExtension.NetCore.WinUIHelper" Version="1.2.*" />
63 <PackageReference Include="XFEExtension.NetCore.XFEConsole" Version="1.1.2" />
64 64 </ItemGroup>
65 65 <ItemGroup>
66 66 <ProjectReference Include="..\HaloPixelToolBox.Core\HaloPixelToolBox.Core.csproj" />
@@ -71,9 +71,9 @@
71 71 <Folder Include="Utilities\Selector\" />
72 72 </ItemGroup>
73 73 <ItemGroup>
74 <None Update="Styles\ConverterResources.xaml">
74 <Page Update="Styles\ConverterResources.xaml">
75 75 <Generator>MSBuild:Compile</Generator>
76 </None>
76 </Page>
77 77 <Page Update="Views\CloudMusicLyricsToolPage.xaml">
78 78 <Generator>MSBuild:Compile</Generator>
79 79 </Page>
Added HaloPixelToolBox/HaloPixelToolBox/Implements/Services/PageService.cs +17 -0
@@ -0,0 +1,17 @@
1 using HaloPixelToolBox.Interface.Services;
2
3 namespace HaloPixelToolBox.Implements.Services;
4
5 public class PageService : IPageService
6 {
7 Page? _page;
8 public Page CurrentPage => _page ?? throw new InvalidOperationException("PageService has not been initialized. Please call Initialize() with a valid Page instance.");
9
10 public event RoutedEventHandler? CurrentPageLoaded;
11
12 public void Initialize(Page page)
13 {
14 _page = page;
15 _page.Loaded += (s, e) => CurrentPageLoaded?.Invoke(s, e);
16 }
17 }
Added HaloPixelToolBox/HaloPixelToolBox/Interface/Services/IPageService.cs +9 -0
Modified HaloPixelToolBox/HaloPixelToolBox/Profiles/CrossVersionProfiles/SystemProfile.cs +5 -0
Modified HaloPixelToolBox/HaloPixelToolBox/Utilities/Converter/BooleanInverseConverter.cs +1 -3
Added HaloPixelToolBox/HaloPixelToolBox/Utilities/Helpers/UpgradeHelper.cs +43 -0
Modified HaloPixelToolBox/HaloPixelToolBox/ViewModels/AppShellPageViewModel.cs +51 -0
Modified HaloPixelToolBox/HaloPixelToolBox/ViewModels/CloudMusicLyricsToolPageViewModel.cs +59 -16
Modified HaloPixelToolBox/HaloPixelToolBox/ViewModels/SettingPageViewModel.cs +2 -0
Modified HaloPixelToolBox/HaloPixelToolBox/Views/AppShellPage.xaml +1 -0
Modified HaloPixelToolBox/HaloPixelToolBox/Views/AppShellPage.xaml.cs +2 -1
Modified HaloPixelToolBox/HaloPixelToolBox/Views/CloudMusicLyricsToolPage.xaml +27 -12
Modified HaloPixelToolBox/HaloPixelToolBox/Views/SettingPage.xaml +19 -0