From 790f5901cf844e062f6028d9353d2fe6bb6efb7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=BE=E5=90=AF=E5=B7=A5=E4=BD=9C=E5=AE=A4?= Date: Sun, 28 Jun 2026 10:07:06 +0800 Subject: [PATCH] =?UTF-8?q?v1.1.2:=20=E6=96=B0=E5=A2=9E=20PatchService=20?= =?UTF-8?q?=E5=AE=89=E8=A3=85/=E5=8D=B8=E8=BD=BD=E8=A1=A5=E4=B8=81?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=20+=20=E5=93=81=E7=89=8C=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Better-EN5/Better-EN5.csproj | 5 +- Better-EN5/Program.cs | 1 - Better-EN5/Services/PatchService.cs | 202 ++++++++++++++++++++ Better-EN5/UI/BetterSeewoMainWindow.xaml | 63 +++--- Better-EN5/UI/BetterSeewoMainWindow.xaml.cs | 118 ++++++++---- Better-EN5/manifest.coin | 2 +- 使用说明.txt | 2 +- 安装插件.bat | 2 +- 8 files changed, 320 insertions(+), 75 deletions(-) create mode 100644 Better-EN5/Services/PatchService.cs diff --git a/Better-EN5/Better-EN5.csproj b/Better-EN5/Better-EN5.csproj index bd2adba..03a94a7 100644 --- a/Better-EN5/Better-EN5.csproj +++ b/Better-EN5/Better-EN5.csproj @@ -7,8 +7,9 @@ enable BetterEN5 Better-EN5 - 1.1.1 - 1.1.1 + 1.1.2 + 1.1.0.0 + 1.1.2.0 雾启工作室 雾启工作室 雾启工作室 diff --git a/Better-EN5/Program.cs b/Better-EN5/Program.cs index 1cc13f0..38f3963 100644 --- a/Better-EN5/Program.cs +++ b/Better-EN5/Program.cs @@ -35,7 +35,6 @@ namespace BetterEN5 private async void Run() { await Task.Delay(TimeSpan.FromSeconds(3)); - await TouchFixService.ApplyFixAsync(); ExportUIItems(); } diff --git a/Better-EN5/Services/PatchService.cs b/Better-EN5/Services/PatchService.cs new file mode 100644 index 0000000..e95228d --- /dev/null +++ b/Better-EN5/Services/PatchService.cs @@ -0,0 +1,202 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; + +namespace BetterEN5.Services +{ + public class PatchService + { + private readonly string _backupDir; + private readonly string _manifestPath; + + public PatchService() + { + var appData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); + _backupDir = Path.Combine(appData, "BetterEN5", "backup"); + _manifestPath = Path.Combine(_backupDir, "manifest.json"); + } + + public bool IsInstalled() + { + return File.Exists(_manifestPath); + } + + public PatchManifest GetManifest() + { + if (!IsInstalled()) return new PatchManifest(); + try + { + var json = File.ReadAllText(_manifestPath); + return System.Text.Json.JsonSerializer.Deserialize(json) ?? new PatchManifest(); + } + catch + { + return new PatchManifest(); + } + } + + public async Task InstallAsync(IProgress progress = null) + { + await Task.Run(() => + { + progress?.Report("正在备份原始文件..."); + Directory.CreateDirectory(_backupDir); + var manifest = new PatchManifest + { + InstallTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), + Version = "1.1.2" + }; + + BackupFile(manifest, + Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), + "Seewo", "EasiNote5", "Config", "IWBConfig.json")); + + BackupFile(manifest, + Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), + "Seewo", "EasiNote5", "Config", "TouchConfig.ini")); + + var appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); + var cfgFkv = Path.Combine(appData, "Seewo", "EasiNote5", "Data", "Configs.fkv"); + if (File.Exists(cfgFkv)) + BackupFile(manifest, cfgFkv); + + var mainDir = Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), + "Seewo", "EasiNote5", "EasiNote5_5.2.4.9855", "Main"); + var configsJson = Path.Combine(mainDir, "Configs", "configs.json"); + if (File.Exists(configsJson)) + BackupFile(manifest, configsJson); + + progress?.Report("正在修补注册表..."); + manifest.RegistryKeys.Add(@"HKCU\SOFTWARE\Seewo\EasiNote5\ForceIWB"); + manifest.RegistryKeys.Add(@"HKCU\SOFTWARE\Seewo\EasiNote5\SkipTouchCheck"); + manifest.RegistryKeys.Add(@"HKCU\SOFTWARE\Seewo\EasiNote5\EnableMultiTouch"); + + progress?.Report("正在应用补丁..."); + var localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); + var configDir = Path.Combine(localAppData, "Seewo", "EasiNote5", "Config"); + Directory.CreateDirectory(configDir); + + var iwbConfig = new + { + ForceIWB = true, + TouchDriverType = "WindowsTouch", + SkipTouchCheck = true, + EnableMultiTouch = true, + LastFixTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + }; + File.WriteAllText(Path.Combine(configDir, "IWBConfig.json"), + System.Text.Json.JsonSerializer.Serialize(iwbConfig, new System.Text.Json.JsonSerializerOptions { WriteIndented = true })); + + var touchCfgLines = new[] + { + "[Touch]", "Enable=1", "Driver=Auto", "ForceEnable=1", + "SuppressErrors=1", "SkipDetection=1", "FallbackToMouse=1", "", + "[Calibration]", "Enabled=0", "", + "[MultiTouch]", "MaxPoints=10", "EnableGesture=1", + }; + File.WriteAllLines(Path.Combine(configDir, "TouchConfig.ini"), touchCfgLines); + + Microsoft.Win32.Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Seewo\EasiNote5", "ForceIWB", 1, Microsoft.Win32.RegistryValueKind.DWord); + Microsoft.Win32.Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Seewo\EasiNote5", "SkipTouchCheck", 1, Microsoft.Win32.RegistryValueKind.DWord); + Microsoft.Win32.Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Seewo\EasiNote5", "EnableMultiTouch", 1, Microsoft.Win32.RegistryValueKind.DWord); + + File.WriteAllText(_manifestPath, + System.Text.Json.JsonSerializer.Serialize(manifest, new System.Text.Json.JsonSerializerOptions { WriteIndented = true })); + + progress?.Report("补丁安装完成"); + }); + } + + public async Task UninstallAsync(IProgress progress = null) + { + await Task.Run(() => + { + if (!IsInstalled()) + { + progress?.Report("未检测到补丁,无需卸载"); + return; + } + + var manifest = GetManifest(); + progress?.Report("正在还原注册表..."); + foreach (var key in manifest.RegistryKeys) + { + try + { + var parts = key.Split('\\'); + if (parts.Length >= 2) + { + var hive = parts[0]; + var subKey = string.Join("\\", parts.Skip(1)); + if (hive == "HKCU") + { + using var rk = Microsoft.Win32.Registry.CurrentUser.OpenSubKey( + Path.GetDirectoryName(subKey)!.Replace("HKEY_CURRENT_USER\\", ""), true); + rk?.DeleteValue(Path.GetFileName(subKey), false); + } + } + } + catch { } + } + + progress?.Report("正在还原备份文件..."); + foreach (var backup in manifest.Backups) + { + try + { + if (File.Exists(backup.BackupPath)) + { + File.Copy(backup.BackupPath, backup.OriginalPath, true); + File.Delete(backup.BackupPath); + } + } + catch { } + } + + try + { + if (File.Exists(_manifestPath)) + File.Delete(_manifestPath); + } + catch { } + + progress?.Report("卸载完成,建议重启希沃白板"); + }); + } + + private void BackupFile(PatchManifest manifest, string filePath) + { + if (!File.Exists(filePath)) return; + var backupPath = filePath + ".bak"; + try + { + File.Copy(filePath, backupPath, true); + manifest.Backups.Add(new PatchBackupEntry + { + OriginalPath = filePath, + BackupPath = backupPath + }); + } + catch { } + } + } + + public class PatchManifest + { + public string Version { get; set; } = ""; + public string InstallTime { get; set; } = ""; + public List Backups { get; set; } = new(); + public List RegistryKeys { get; set; } = new(); + } + + public class PatchBackupEntry + { + public string OriginalPath { get; set; } = ""; + public string BackupPath { get; set; } = ""; + } +} diff --git a/Better-EN5/UI/BetterSeewoMainWindow.xaml b/Better-EN5/UI/BetterSeewoMainWindow.xaml index f1d6576..02544ba 100644 --- a/Better-EN5/UI/BetterSeewoMainWindow.xaml +++ b/Better-EN5/UI/BetterSeewoMainWindow.xaml @@ -15,19 +15,12 @@ #D0D0E0 #707090 - - - - - - + - @@ -76,7 +69,12 @@ - + - + + + + + +