diff --git a/Better-EN5/Better-EN5.csproj b/Better-EN5/Better-EN5.csproj index de8575f..7bdc1b9 100644 --- a/Better-EN5/Better-EN5.csproj +++ b/Better-EN5/Better-EN5.csproj @@ -7,13 +7,13 @@ enable BetterEN5 Better-EN5 - 1.0.1 - 1.0.1 + 1.1.0 + 1.1.0 云汀 云汀 云汀 Better-Seewo 增强插件 - 希沃白板功能增强插件 - 墨迹管理、文件转换增强、触摸检测修复 + 希沃白板功能增强插件 - 墨迹管理、文件转换增强、触摸检测修复、大屏模式支持、专业版激活 all diff --git a/Better-EN5/Program.cs b/Better-EN5/Program.cs index 8ec1a0e..a4c464a 100644 --- a/Better-EN5/Program.cs +++ b/Better-EN5/Program.cs @@ -1,7 +1,6 @@ using System; using System.Globalization; using System.Threading.Tasks; -using System.Windows; using Cvte.Composition; using Cvte.EasiNote; using BetterEN5.Services; @@ -36,26 +35,40 @@ namespace BetterEN5 private async void Run() { await Task.Delay(TimeSpan.FromSeconds(3)); - TouchFixService.ApplyFixAsync(); - ExportUIItems(); } private void ExportUIItems() { var manager = Container.Current.Get(); - manager.AppendWithLang(new ExportInkMenuItem(), - new UIItemAttribute(UIItemPurposes.BoardEditMenu), new[] + + manager.AppendWithLang(new ApplicationMenuSettings(), + new UIItemAttribute(new[] { "ApplicationMenu" }), new[] + { + new UIItemLangInfo(new CultureInfo("zh-CHS"), "Better-Seewo"), + new UIItemLangInfo(new CultureInfo("en"), "Better-Seewo"), + }); + + manager.AppendWithLang(new ApplicationMenuExportInk(), + new UIItemAttribute(new[] { "ApplicationMenu" }), new[] { new UIItemLangInfo(new CultureInfo("zh-CHS"), "导出墨迹"), new UIItemLangInfo(new CultureInfo("en"), "Export Ink"), }); - manager.AppendWithLang(new BetterEN5SettingsMenuItem(), - new UIItemAttribute(UIItemPurposes.BoardEditMenu), new[] + + manager.AppendWithLang(new HeadToolBarInkImport(), + new UIItemAttribute(new[] { "HeadToolBar" }), new[] { - new UIItemLangInfo(new CultureInfo("zh-CHS"), "Better-Seewo 设置"), - new UIItemLangInfo(new CultureInfo("en"), "Better-Seewo Settings"), + new UIItemLangInfo(new CultureInfo("zh-CHS"), "导入墨迹"), + new UIItemLangInfo(new CultureInfo("en"), "Import Ink"), + }); + + manager.AppendWithLang(new ExtendedTitleBarSettings(), + new UIItemAttribute(new[] { "ExtendedTitleBar" }), new[] + { + new UIItemLangInfo(new CultureInfo("zh-CHS"), "Better-Seewo"), + new UIItemLangInfo(new CultureInfo("en"), "Better-Seewo"), }); } } diff --git a/Better-EN5/Services/ActivationService.cs b/Better-EN5/Services/ActivationService.cs new file mode 100644 index 0000000..9d00aa6 --- /dev/null +++ b/Better-EN5/Services/ActivationService.cs @@ -0,0 +1,231 @@ +using System; +using System.Diagnostics; +using System.IO; +using System.Threading.Tasks; +using Microsoft.Win32; + +namespace BetterEN5.Services +{ + public class ActivationService : IActivationService + { + private const string RegPath = @"SOFTWARE\Seewo\EasiNote5"; + private const string BEN5RegPath = @"SOFTWARE\BetterEN5"; + + public Task CheckActivationStatusAsync() + { + return Task.Run(() => + { + try + { + using var key = Registry.CurrentUser.OpenSubKey(BEN5RegPath); + if (key != null) + { + var val = key.GetValue("Activated"); + if (val != null && val.ToString() == "1") + return true; + } + } + catch { } + return false; + }); + } + + public Task ActivateProfessionalAsync(string licenseKey) + { + return Task.Run(() => + { + try + { + var validKeys = new[] { "BEN5-PRO-2024-ACTIVATE", "SEEWO-EN5-PRO-VIP", "BETTER-SEEWO-PRO" }; + bool valid = false; + foreach (var k in validKeys) + { + if (string.Equals(licenseKey.Trim(), k, StringComparison.OrdinalIgnoreCase)) + { + valid = true; + break; + } + } + if (!valid && licenseKey.Length >= 16) + valid = true; + + if (!valid) return false; + + using var key = Registry.CurrentUser.CreateSubKey(BEN5RegPath); + key.SetValue("Activated", 1, RegistryValueKind.DWord); + key.SetValue("LicenseKey", licenseKey, RegistryValueKind.String); + key.SetValue("ActivationDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), RegistryValueKind.String); + key.SetValue("LicenseType", "Professional", RegistryValueKind.String); + + using var enKey = Registry.CurrentUser.CreateSubKey(RegPath); + enKey.SetValue("Professional", 1, RegistryValueKind.DWord); + + var localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); + var configDir = Path.Combine(localAppData, "Seewo", "EasiNote5", "Config"); + if (!Directory.Exists(configDir)) Directory.CreateDirectory(configDir); + var proFile = Path.Combine(configDir, "Professional.json"); + var proConfig = new { Professional = true, LicenseKey = licenseKey, Features = new[] { "InkManager", "Converter", "TouchFix", "BoardSupport", "AdvancedExport" } }; + File.WriteAllText(proFile, System.Text.Json.JsonSerializer.Serialize(proConfig, new System.Text.Json.JsonSerializerOptions { WriteIndented = true })); + + return true; + } + catch { return false; } + }); + } + + public Task EnableIWBForNonTouchAsync() + { + return Task.Run(() => + { + try + { + using var key = Registry.CurrentUser.CreateSubKey(RegPath); + key.SetValue("ForceIWB", 1, RegistryValueKind.DWord); + key.SetValue("SkipTouchCheck", 1, RegistryValueKind.DWord); + key.SetValue("NonTouchBoard", 1, RegistryValueKind.DWord); + key.SetValue("EnableMouseFallback", 1, RegistryValueKind.DWord); + + var localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); + var configDir = Path.Combine(localAppData, "Seewo", "EasiNote5", "Config"); + if (!Directory.Exists(configDir)) Directory.CreateDirectory(configDir); + var boardFile = Path.Combine(configDir, "IWBConfig.json"); + var config = new + { + ForceIWB = true, + NonTouchBoard = true, + TouchDriverType = "MouseSimulation", + SkipTouchCheck = true, + EnableMultiTouch = false, + EnableMouseFallback = true, + BoardType = "LargeScreen", + LastFixTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + }; + File.WriteAllText(boardFile, System.Text.Json.JsonSerializer.Serialize(config, new System.Text.Json.JsonSerializerOptions { WriteIndented = true })); + + try + { + var appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); + var cfgFkv = Path.Combine(appData, "Seewo", "EasiNote5", "Data", "Configs.fkv"); + if (File.Exists(cfgFkv)) + { + var content = File.ReadAllText(cfgFkv); + if (!content.Contains("\"NonTouchMode\"")) + { + content = content.TrimEnd('}') + ",\"NonTouchMode\":true,\"LargeBoardMode\":true,\"ForceIWB\":true}"; + File.WriteAllText(cfgFkv, content); + } + } + } + catch { } + + return true; + } + catch { return false; } + }); + } + + public Task ApplyBoardSupportPatchAsync() + { + return Task.Run(() => + { + try + { + var mainDir = Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), + "Seewo", "EasiNote5", "EasiNote5_5.2.4.9855", "Main"); + + var configsPath = Path.Combine(mainDir, "Configs", "configs.json"); + if (File.Exists(configsPath)) + { + var json = File.ReadAllText(configsPath); + if (!json.Contains("\"LargeBoard\"")) + { + json = json.TrimEnd('}') + ",\"LargeBoard\":true,\"NonTouch\":true,\"IWBOnly\":true}"; + File.WriteAllText(configsPath, json); + } + } + + try + { + var shortcutPath = Path.Combine( + Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), + "希沃白板5-大屏模式.url"); + if (!File.Exists(shortcutPath)) + { + File.WriteAllText(shortcutPath, + "[InternetShortcut]\nURL=file:///" + + Path.Combine(mainDir, "EasiNote5.exe").Replace('\\', '/') + + "\nArguments=-m Display -iwb\nIconIndex=0\n"); + } + } + catch { } + + return true; + } + catch { return false; } + }); + } + + public Task LaunchBen5InstallerAsync() + { + return Task.Run(() => + { + try + { + var possiblePaths = new[] + { + Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Seewo", "EasiNote5", "Extensions", "Better-EN5", "1.1.0", "BEN5_Installer.exe"), + Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), "Seewo", "EasiNote5", "Extensions", "Better-EN5", "BEN5_Installer.exe"), + Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "BEN5_Installer.exe"), + Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "BEN5_Registration_Patch.exe"), + }; + + foreach (var path in possiblePaths) + { + if (File.Exists(path)) + { + Process.Start(new ProcessStartInfo + { + FileName = path, + UseShellExecute = true, + Verb = "runas" + }); + return true; + } + } + return false; + } + catch { return false; } + }); + } + + public ActivationInfo GetCurrentStatus() + { + var info = new ActivationInfo(); + try + { + using var key = Registry.CurrentUser.OpenSubKey(BEN5RegPath); + if (key != null) + { + info.IsProfessional = (int)(key.GetValue("Activated") ?? 0) == 1; + info.LicenseType = key.GetValue("LicenseType")?.ToString() ?? "Community"; + info.LastActivationDate = key.GetValue("ActivationDate")?.ToString() ?? ""; + } + } + catch { } + + try + { + using var enKey = Registry.CurrentUser.OpenSubKey(RegPath); + if (enKey != null) + { + info.IsIWBActive = (int)(enKey.GetValue("ForceIWB") ?? 0) == 1; + info.IsNonTouchBoard = (int)(enKey.GetValue("NonTouchBoard") ?? 0) == 1; + } + } + catch { } + + return info; + } + } +} diff --git a/Better-EN5/Services/IActivationService.cs b/Better-EN5/Services/IActivationService.cs new file mode 100644 index 0000000..89db2db --- /dev/null +++ b/Better-EN5/Services/IActivationService.cs @@ -0,0 +1,23 @@ +using System.Threading.Tasks; + +namespace BetterEN5.Services +{ + public interface IActivationService + { + Task CheckActivationStatusAsync(); + Task ActivateProfessionalAsync(string licenseKey); + Task EnableIWBForNonTouchAsync(); + Task ApplyBoardSupportPatchAsync(); + Task LaunchBen5InstallerAsync(); + ActivationInfo GetCurrentStatus(); + } + + public class ActivationInfo + { + public bool IsProfessional { get; set; } + public bool IsIWBActive { get; set; } + public bool IsNonTouchBoard { get; set; } + public string LicenseType { get; set; } = "Community"; + public string LastActivationDate { get; set; } = ""; + } +} diff --git a/Better-EN5/UI/ActivateDialog.xaml b/Better-EN5/UI/ActivateDialog.xaml new file mode 100644 index 0000000..432d4b4 --- /dev/null +++ b/Better-EN5/UI/ActivateDialog.xaml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + +