v1.1.0: 全面重构UI为Better-Seewo横版主窗口 (Fluent风格+圆角+动画), 新增非触摸大板支持与专业版激活, 更改菜单位置至ApplicationMenu/ExtendedTitleBar
This commit is contained in:
204
Better-EN5/UI/BetterEN5Module.xaml.cs
Normal file
204
Better-EN5/UI/BetterEN5Module.xaml.cs
Normal file
@@ -0,0 +1,204 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using Microsoft.Win32;
|
||||
using BetterEN5.Services;
|
||||
|
||||
namespace BetterEN5.UI
|
||||
{
|
||||
public partial class BetterEN5Module : UserControl
|
||||
{
|
||||
private readonly InkService _inkService = new();
|
||||
private readonly ConversionService _conversionService = new();
|
||||
private readonly ActivationService _activationService = new();
|
||||
|
||||
public BetterEN5Module()
|
||||
{
|
||||
InitializeComponent();
|
||||
Loaded += OnLoaded;
|
||||
}
|
||||
|
||||
private async void OnLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
await RefreshStatusAsync();
|
||||
}
|
||||
|
||||
public async Task RefreshStatusAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
var touchOk = await Task.Run(() => TouchFixService.IsTouchWorkingCorrectly());
|
||||
TouchStatus.Text = touchOk ? "✅ IWB 模式已启用" : "⚠️ 未启用 IWB 模式";
|
||||
|
||||
var activationInfo = await Task.Run(() => _activationService.GetCurrentStatus());
|
||||
ActivationStatusText.Text = activationInfo.IsProfessional
|
||||
? $"✅ 专业版已激活 | {activationInfo.LastActivationDate}"
|
||||
: "🔓 社区版 · 点击激活";
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
private async void ExportInk_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var dialog = new SaveFileDialog
|
||||
{
|
||||
Title = "导出墨迹",
|
||||
Filter = "墨迹文件|*.ink.json|JSON 文件|*.json|所有文件|*.*",
|
||||
DefaultExt = ".ink.json"
|
||||
};
|
||||
if (dialog.ShowDialog() == true)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _inkService.ExportInkAsync(dialog.FileName);
|
||||
InkStatus.Text = $"✅ 已导出: {Path.GetFileName(dialog.FileName)}";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
InkStatus.Text = $"❌ 导出失败: {ex.Message}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async void ImportInk_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var dialog = new OpenFileDialog
|
||||
{
|
||||
Title = "导入墨迹",
|
||||
Filter = "墨迹文件|*.ink.json|JSON 文件|*.json|所有文件|*.*"
|
||||
};
|
||||
if (dialog.ShowDialog() == true)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _inkService.ImportInkAsync(dialog.FileName);
|
||||
InkStatus.Text = "✅ 墨迹已导入";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
InkStatus.Text = $"❌ 导入失败: {ex.Message}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async void ConvertPptx_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var dialog = new OpenFileDialog
|
||||
{
|
||||
Title = "选择 PowerPoint 文件",
|
||||
Filter = "PowerPoint 文件|*.pptx|所有文件|*.*"
|
||||
};
|
||||
if (dialog.ShowDialog() == true)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _conversionService.ConvertPptxToEnbxAsync(dialog.FileName);
|
||||
ConversionStatus.Text = $"✅ 转换完成: {Path.GetFileName(result)}";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ConversionStatus.Text = $"❌ 转换失败: {ex.Message}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async void ConvertEnbx_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var dialog = new OpenFileDialog
|
||||
{
|
||||
Title = "选择希沃白板课件",
|
||||
Filter = "希沃课件|*.enbx|所有文件|*.*"
|
||||
};
|
||||
if (dialog.ShowDialog() == true)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _conversionService.ConvertEnbxToPptxAsync(dialog.FileName);
|
||||
ConversionStatus.Text = $"✅ 导出完成: {Path.GetFileName(result)}";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ConversionStatus.Text = $"❌ 导出失败: {ex.Message}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async void CheckTouch_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var touchOk = await Task.Run(() => TouchFixService.IsTouchWorkingCorrectly());
|
||||
TouchStatus.Text = touchOk ? "✅ 触摸状态正常" : "⚠️ 触摸可能需要修复";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TouchStatus.Text = $"❌ 检测失败: {ex.Message}";
|
||||
}
|
||||
}
|
||||
|
||||
private async void ApplyTouchFix_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
await TouchFixService.ApplyFixAsync();
|
||||
TouchStatus.Text = "✅ 触摸修复已应用,重启后生效";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
TouchStatus.Text = $"❌ 修复失败: {ex.Message}";
|
||||
}
|
||||
}
|
||||
|
||||
private async void EnableBoardSupport_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var ok = await _activationService.ApplyBoardSupportPatchAsync();
|
||||
BoardStatus.Text = ok ? "✅ 大屏模式已配置" : "❌ 配置失败";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
BoardStatus.Text = $"❌ 错误: {ex.Message}";
|
||||
}
|
||||
}
|
||||
|
||||
private async void EnableIWB_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var ok = await _activationService.EnableIWBForNonTouchAsync();
|
||||
BoardStatus.Text = ok ? "✅ IWB 模式已启用" : "❌ 启用失败";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
BoardStatus.Text = $"❌ 错误: {ex.Message}";
|
||||
}
|
||||
}
|
||||
|
||||
private async void ActivatePro_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var dialog = new ActivateDialog();
|
||||
var ownerWindow = Window.GetWindow(this);
|
||||
if (ownerWindow != null) dialog.Owner = ownerWindow;
|
||||
if (dialog.ShowDialog() == true)
|
||||
{
|
||||
var ok = await _activationService.ActivateProfessionalAsync(dialog.LicenseKey);
|
||||
ActivationStatusText.Text = ok ? "✅ 激活成功!专业版已启用" : "❌ 激活码无效";
|
||||
}
|
||||
}
|
||||
|
||||
private async void LaunchInstaller_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var ok = await _activationService.LaunchBen5InstallerAsync();
|
||||
if (!ok)
|
||||
{
|
||||
MessageBox.Show("未找到注册补丁安装程序。\n请将 BEN5_Installer.exe 放置于插件目录。",
|
||||
"提示", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user