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

HaloPixelToolBox

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

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

XFEstudio/HaloPixelToolBox

add-minimize

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

代码差异

5 个文件 +58 -20
Modified HaloPixelToolBox/HaloPixelToolBox.Core/Utilities/CloudLyricsReader.cs +24 -18
@@ -11,6 +11,12 @@ public class CloudMusicLyricsReader
11 11 public FileVersionInfo? VersionInfo { get; set; }
12 12 public Version Version { get; set; } = new();
13 13 public MemoryEditor Editor { get; set; } = new();
14 public static Dictionary<string, Func<MemoryEditor, nint>> VersionResolverDictionary { get; } = new()
15 {
16 { "3.1.27", editor => editor.ResolvePointerAddress("cloudmusic.dll", 0x01DDE290, 0xE0, 0x8, 0xE8, 0x38, 0x118, 0x8, 0x0) },
17 { "3.1.26", editor => editor.ResolvePointerAddress("cloudmusic.dll", 0x01DD5130, 0xE8, 0x38, 0x120, 0x18, 0x0) },
18 { "3.1.25", editor => editor.ResolvePointerAddress("cloudmusic.dll", 0x01DAFF60, 0xE0, 0x8, 0x128, 0x18, 0x0) },
19 };
14 20
15 21 public bool Initialize()
16 22 {
@@ -41,33 +47,33 @@ public class CloudMusicLyricsReader
41 47 public bool TryReadLyrics(out string lyrics)
42 48 {
43 49 lyrics = "无法读取歌词";
44 if (Editor.ReadMemory(Address, 200, out var buffer))
50 try
45 51 {
46 lyrics = Encoding.Unicode.GetString(buffer, 0, GetValidLength(buffer));
47 return true;
52 if (Editor.ReadMemory(Address, 200, out var buffer))
53 {
54 lyrics = Encoding.Unicode.GetString(buffer, 0, GetValidLength(buffer));
55 return true;
56 }
48 57 }
49 else return false;
58 catch (Exception ex)
59 {
60 Console.WriteLine($"[ERROR]读取歌词异常:{ex.Message}");
61 Console.WriteLine($"[TRACE]{ex.StackTrace}");
62 }
63 return false;
50 64 }
51 65
52 66 public bool ReresolveAddress()
53 67 {
54 68 try
55 69 {
70 if (Version.MajorRevision == 0)
71 return false;
56 72 nint address = 0;
57 switch (Version.ToString(3))
58 {
59 case "3.1.27":
60 address = Editor.ResolvePointerAddress("cloudmusic.dll", 0x01DDE290, 0xE0, 0x8, 0xE8, 0x38, 0x118, 0x8, 0x0);
61 break;
62 case "3.1.26":
63 address = Editor.ResolvePointerAddress("cloudmusic.dll", 0x01DD5130, 0xE8, 0x38, 0x120, 0x18, 0x0);
64 break;
65 case "3.1.25":
66 address = Editor.ResolvePointerAddress("cloudmusic.dll", 0x01DAFF60, 0xE0, 0x8, 0x128, 0x18, 0x0);
67 break;
68 default:
69 break;
70 }
73 if (VersionResolverDictionary.TryGetValue(Version.ToString(3), out var resolver))
74 address = resolver(Editor);
75 else
76 Console.WriteLine($"[WARN]未找到匹配的版本解析器,当前版本:{Version}");
71 77 if (address != Address)
72 78 Console.WriteLine($"[DEBUG]读取到新的地址:{address}({address:X})");
73 79 if (address != 0)
Modified HaloPixelToolBox/HaloPixelToolBox/ViewModels/CloudMusicLyricsToolPageViewModel.cs +2 -0
@@ -23,6 +23,8 @@ public partial class CloudMusicLyricsToolPageViewModel : ServiceBaseViewModelBas
23 23 private int switchBackTimeout = CloudMusicLyricsProfile.SwitchBackTimeout;
24 24 [ObservableProperty]
25 25 private string cloudMusicVersion = string.Empty;
26 [ObservableProperty]
27 private string supportedVersion = CloudMusicLyricsReader.VersionResolverDictionary.Keys.FirstOrDefault() ?? string.Empty;
26 28 public HaloPixelDevice Device { get; set; } = new();
27 29 public CloudMusicLyricsReader Reader { get; set; } = new();
28 30
Modified HaloPixelToolBox/HaloPixelToolBox/ViewModels/SettingPageViewModel.cs +11 -0
@@ -6,6 +6,7 @@ using HaloPixelToolBox.Profiles.CrossVersionProfiles;
6 6 using HaloPixelToolBox.Utilities;
7 7 using Microsoft.Win32;
8 8 using System.Reflection;
9 using Windows.System;
9 10 using XFEExtension.NetCore.FileExtension;
10 11 using XFEExtension.NetCore.WinUIHelper.Interface.Services;
11 12 using XFEExtension.NetCore.WinUIHelper.Utilities;
@@ -15,6 +16,8 @@ namespace HaloPixelToolBox.ViewModels;
15 16
16 17 public partial class SettingPageViewModel : ViewModelBase
17 18 {
19 [ObservableProperty]
20 private int closeButtonActionIndex = SystemProfile.MinimizeWhenClose ? 0 : 1;
18 21 [ObservableProperty]
19 22 bool isAutoStartEnable = SystemProfile.AutoStart;
20 23 [ObservableProperty]
@@ -38,6 +41,8 @@ public partial class SettingPageViewModel : ViewModelBase
38 41 public ISettingService SettingService { get; set; } = ServiceManager.GetService<ISettingService>();
39 42 public IDialogService DialogService { get; set; } = ServiceManager.GetService<IDialogService>();
40 43
44 partial void OnCloseButtonActionIndexChanged(int value) => SystemProfile.MinimizeWhenClose = value == 0;
45
41 46 partial void OnIsAutoStartEnableChanged(bool value)
42 47 {
43 48 SystemProfile.AutoStart = value;
@@ -83,6 +88,12 @@ public partial class SettingPageViewModel : ViewModelBase
83 88 }
84 89 }
85 90
91 [RelayCommand]
92 static async Task LinkToGithubRepo() => await Launcher.LaunchUriAsync(new Uri("https://github.com/XFEstudio/HaloPixelToolBox"));
93
94 [RelayCommand]
95 static async Task LinkToGithubIssue() => await Launcher.LaunchUriAsync(new Uri("https://github.com/XFEstudio/HaloPixelToolBox/issues/new/choose"));
96
86 97 [RelayCommand]
87 98 void ClearIgnoreVersion() => IgnoreVersion = string.Empty;
88 99
Modified HaloPixelToolBox/HaloPixelToolBox/Views/CloudMusicLyricsToolPage.xaml +1 -1
@@ -42,7 +42,7 @@
42 42 <Border CornerRadius="90" Height="25" Width="25" Visibility="{x:Bind ViewModel.CloudMusicReady, Mode=OneWay}" Background="{ThemeResource SystemFillColorSuccessBrush}"/>
43 43 </Grid>
44 44 </Grid>
45 <TextBlock Text="网易云版本 (当前支持版本3.1.26)" Style="{StaticResource SettingsSectionHeaderTextBlockStyle}"/>
45 <TextBlock Text="{x:Bind ViewModel.SupportedVersion, Mode=OneWay, Converter={StaticResource StringFormatConverter}, ConverterParameter='网易云版本 (当前支持版本 (0) )'}" Style="{StaticResource SettingsSectionHeaderTextBlockStyle}"/>
46 46 <TextBlock Text="{x:Bind ViewModel.CloudMusicVersion, Mode=OneWay}" Style="{StaticResource BodyTextBlockStyle}"/>
47 47 <TextBlock Text="启用状态" Style="{StaticResource SettingsSectionHeaderTextBlockStyle}"/>
48 48 <controls:SettingsCard Header="启用歌词同步" Description="启用后,网易云的歌词会实时显示在花再 Halo Pixel 音响上">
Modified HaloPixelToolBox/HaloPixelToolBox/Views/SettingPage.xaml +20 -1
@@ -44,10 +44,19 @@
44 44 </controls:SettingsCard>
45 45 <controls:SettingsCard Header="自动托盘到右下角" Description="启动软件后自动托盘到右下角">
46 46 <controls:SettingsCard.HeaderIcon>
47 <FontIcon Glyph="&#xE7E8;"/>
47 <FontIcon Glyph="&#xE944;"/>
48 48 </controls:SettingsCard.HeaderIcon>
49 49 <ToggleSwitch x:Name="minimizeWhenOpenToggleSwitch" IsOn="{x:Bind ViewModel.MinimizeWhenOpen, Mode=TwoWay}"/>
50 50 </controls:SettingsCard>
51 <controls:SettingsCard Header="软件退出" Description="点击退出软件时的操作">
52 <controls:SettingsCard.HeaderIcon>
53 <FontIcon Glyph="&#xE89F;"/>
54 </controls:SettingsCard.HeaderIcon>
55 <ComboBox SelectedIndex="{x:Bind ViewModel.CloseButtonActionIndex, Mode=TwoWay}">
56 <ComboBoxItem Content="最小化到右下角托盘区"/>
57 <ComboBoxItem Content="直接退出程序"/>
58 </ComboBox>
59 </controls:SettingsCard>
51 60 <TextBlock Text="下载 &amp; 更新" Style="{StaticResource SettingsSectionHeaderTextBlockStyle}"/>
52 61 <controls:SettingsCard Header="检查新的更新" Description="检查是否有新的更新">
53 62 <Button Content="检查更新" Command="{x:Bind ViewModel.CheckUpgradeCommand}"/>
@@ -92,6 +101,16 @@
92 101 <controls:SettingsCard Header="作者">
93 102 <TextBlock Text="XFEstudio" Foreground="{ThemeResource TextFillColorSecondary}"/>
94 103 </controls:SettingsCard>
104 <controls:SettingsCard Header="问题反馈 &amp; 建议" IsClickEnabled="True" Command="{x:Bind ViewModel.LinkToGithubIssueCommand}">
105 <controls:SettingsCard.ActionIcon>
106 <FontIcon Glyph="&#xE8A7;"/>
107 </controls:SettingsCard.ActionIcon>
108 </controls:SettingsCard>
109 <controls:SettingsCard Header="Github仓库" IsClickEnabled="True" Command="{x:Bind ViewModel.LinkToGithubRepoCommand}">
110 <controls:SettingsCard.ActionIcon>
111 <FontIcon Glyph="&#xE8A7;"/>
112 </controls:SettingsCard.ActionIcon>
113 </controls:SettingsCard>
95 114 <controls:SettingsCard Header="联系我们" HorizontalContentAlignment="Left" ContentAlignment="Vertical">
96 115 <StackPanel Margin="-12,0,0,0" Orientation="Vertical">
97 116 <HyperlinkButton Content="加入QQ群" NavigateUri="https://qm.qq.com/q/VLpyYjWOWe"/>