v1.1.0: 修复入口使用BoardEditMenu/HeadToolBar, 16:9横版UI重做, 进度条在操作时显示, 雾启工作室
This commit is contained in:
@@ -1,12 +1,21 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media.Animation;
|
||||
using Microsoft.Win32;
|
||||
using BetterEN5.Services;
|
||||
|
||||
namespace BetterEN5.UI
|
||||
{
|
||||
public partial class BetterSeewoMainWindow : Window
|
||||
{
|
||||
private readonly InkService _inkService = new();
|
||||
private readonly ConversionService _conversionService = new();
|
||||
private readonly ActivationService _activationService = new();
|
||||
|
||||
public BetterSeewoMainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -15,47 +24,185 @@ namespace BetterEN5.UI
|
||||
|
||||
private void OnLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var storyboard = (Storyboard)Resources["ScaleInStoryboard"];
|
||||
BeginStoryboard(storyboard);
|
||||
var sb = (Storyboard)TryFindResource("ScaleInStoryboard");
|
||||
if (sb != null) BeginStoryboard(sb);
|
||||
_ = RefreshStatusAsync();
|
||||
}
|
||||
|
||||
private void Minimize_Click(object sender, RoutedEventArgs e)
|
||||
private void NavChanged(object sender, RoutedEventArgs e)
|
||||
{
|
||||
WindowState = WindowState.Minimized;
|
||||
if (sender == NavInk) ShowPanel(PanelInk);
|
||||
else if (sender == NavConvert) ShowPanel(PanelConvert);
|
||||
else if (sender == NavTouch) ShowPanel(PanelTouch);
|
||||
else if (sender == NavBoard) ShowPanel(PanelBoard);
|
||||
else if (sender == NavActivate) ShowPanel(PanelActivate);
|
||||
}
|
||||
|
||||
private void Maximize_Click(object sender, RoutedEventArgs e)
|
||||
private void ShowPanel(StackPanel panel)
|
||||
{
|
||||
WindowState = WindowState == WindowState.Maximized
|
||||
? WindowState.Normal
|
||||
: WindowState.Maximized;
|
||||
foreach (var p in new[] { PanelInk, PanelConvert, PanelTouch, PanelBoard, PanelActivate })
|
||||
p.Visibility = p == panel ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
private void Close_Click(object sender, RoutedEventArgs e)
|
||||
private async Task RefreshStatusAsync()
|
||||
{
|
||||
Close();
|
||||
var touchOk = await Task.Run(() => TouchFixService.IsTouchWorkingCorrectly());
|
||||
TouchStatus.Text = touchOk ? "✅ IWB 模式已启用" : "⚠️ 未启用 IWB 模式";
|
||||
var info = await Task.Run(() => _activationService.GetCurrentStatus());
|
||||
ActivationStatusText.Text = info.IsProfessional
|
||||
? $"✅ 专业版 · {info.LastActivationDate}"
|
||||
: "🔓 社区版";
|
||||
}
|
||||
|
||||
public void RefreshModule()
|
||||
private void Minimize_Click(object s, RoutedEventArgs e) => WindowState = WindowState.Minimized;
|
||||
private void Maximize_Click(object s, RoutedEventArgs e) => WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;
|
||||
private void Close_Click(object s, RoutedEventArgs e) => Close();
|
||||
|
||||
private async void ExportInk_Click(object s, RoutedEventArgs e)
|
||||
{
|
||||
En5Module?.RefreshStatusAsync();
|
||||
var dialog = new SaveFileDialog { Title = "导出墨迹", Filter = "墨迹文件|*.ink.json|JSON|*.json", DefaultExt = ".ink.json" };
|
||||
if (dialog.ShowDialog() == true)
|
||||
{
|
||||
await ProgressDialog.Show(this, "导出墨迹", async p =>
|
||||
{
|
||||
p.UpdateStatus("正在导出墨迹...", "读取课件笔迹数据");
|
||||
await _inkService.ExportInkAsync(dialog.FileName);
|
||||
p.UpdateStatus("导出完成", $"已保存至 {Path.GetFileName(dialog.FileName)}");
|
||||
});
|
||||
InkStatus.Text = $"已导出: {Path.GetFileName(dialog.FileName)}";
|
||||
}
|
||||
}
|
||||
|
||||
private async void ImportInk_Click(object s, RoutedEventArgs e)
|
||||
{
|
||||
var dialog = new OpenFileDialog { Title = "导入墨迹", Filter = "墨迹文件|*.ink.json|JSON|*.json" };
|
||||
if (dialog.ShowDialog() == true)
|
||||
{
|
||||
await ProgressDialog.Show(this, "导入墨迹", async p =>
|
||||
{
|
||||
p.UpdateStatus("正在导入墨迹...", "写入课件笔迹");
|
||||
await _inkService.ImportInkAsync(dialog.FileName);
|
||||
});
|
||||
InkStatus.Text = "墨迹已导入";
|
||||
}
|
||||
}
|
||||
|
||||
private async void ConvertPptx_Click(object s, RoutedEventArgs e)
|
||||
{
|
||||
var dialog = new OpenFileDialog { Title = "选择 PPT", Filter = "PowerPoint|*.pptx" };
|
||||
if (dialog.ShowDialog() == true)
|
||||
{
|
||||
await ProgressDialog.Show(this, "转换文件", async p =>
|
||||
{
|
||||
p.UpdateStatus("正在转换 PPT → ENBX...", "调用转换器");
|
||||
var result = await _conversionService.ConvertPptxToEnbxAsync(dialog.FileName);
|
||||
p.UpdateStatus("转换完成", Path.GetFileName(result));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private async void ConvertEnbx_Click(object s, RoutedEventArgs e)
|
||||
{
|
||||
var dialog = new OpenFileDialog { Title = "选择 ENBX", Filter = "希沃课件|*.enbx" };
|
||||
if (dialog.ShowDialog() == true)
|
||||
{
|
||||
await ProgressDialog.Show(this, "转换文件", async p =>
|
||||
{
|
||||
p.UpdateStatus("正在转换 ENBX → PPT...", "调用转换器");
|
||||
var result = await _conversionService.ConvertEnbxToPptxAsync(dialog.FileName);
|
||||
p.UpdateStatus("导出完成", Path.GetFileName(result));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private async void CheckTouch_Click(object s, RoutedEventArgs e)
|
||||
{
|
||||
var ok = await Task.Run(() => TouchFixService.IsTouchWorkingCorrectly());
|
||||
TouchStatus.Text = ok ? "✅ IWB 模式已启用" : "⚠️ 未启用 IWB 模式";
|
||||
}
|
||||
|
||||
private async void ApplyTouchFix_Click(object s, RoutedEventArgs e)
|
||||
{
|
||||
await ProgressDialog.Show(this, "触摸修复", async p =>
|
||||
{
|
||||
p.UpdateStatus("正在写入注册表配置...", "ForceIWB");
|
||||
await Task.Run(() => TouchFixService.ApplyFixAsync());
|
||||
p.UpdateStatus("正在配置 IWB 模式...", "IWBConfig.json");
|
||||
await Task.Delay(300);
|
||||
p.UpdateStatus("完成", "请重启希沃白板生效");
|
||||
});
|
||||
TouchStatus.Text = "修复已应用,请重启";
|
||||
}
|
||||
|
||||
private async void EnableBoardSupport_Click(object s, RoutedEventArgs e)
|
||||
{
|
||||
await ProgressDialog.Show(this, "大屏支持", async p =>
|
||||
{
|
||||
p.UpdateStatus("正在配置大屏模式...", "修补 Configs.fkv");
|
||||
await _activationService.ApplyBoardSupportPatchAsync();
|
||||
p.UpdateStatus("正在写入注册表...", "大屏相关键值");
|
||||
await Task.Delay(200);
|
||||
p.UpdateStatus("完成", "大屏模式已配置");
|
||||
});
|
||||
BoardStatus.Text = "大屏模式已配置";
|
||||
}
|
||||
|
||||
private async void EnableIWB_Click(object s, RoutedEventArgs e)
|
||||
{
|
||||
await ProgressDialog.Show(this, "IWB 模式", async p =>
|
||||
{
|
||||
p.UpdateStatus("正在启用 IWB 模式...", "注册表 + 配置文件");
|
||||
await _activationService.EnableIWBForNonTouchAsync();
|
||||
p.UpdateStatus("完成", "IWB 模式已启用,重启生效");
|
||||
});
|
||||
BoardStatus.Text = "IWB 已启用";
|
||||
}
|
||||
|
||||
private async void ActivatePro_Click(object s, RoutedEventArgs e)
|
||||
{
|
||||
var dlg = new ActivateDialog();
|
||||
dlg.Owner = this;
|
||||
if (dlg.ShowDialog() == true)
|
||||
{
|
||||
await ProgressDialog.Show(this, "激活", async p =>
|
||||
{
|
||||
p.UpdateStatus("正在验证激活码...", "");
|
||||
var ok = await _activationService.ActivateProfessionalAsync(dlg.LicenseKey);
|
||||
if (ok)
|
||||
{
|
||||
p.UpdateStatus("激活成功", "专业版已启用");
|
||||
ActivationStatusText.Text = "✅ 专业版已激活";
|
||||
}
|
||||
else
|
||||
{
|
||||
p.UpdateStatus("激活失败", "激活码无效");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private async void LaunchInstaller_Click(object s, RoutedEventArgs e)
|
||||
{
|
||||
var ok = await _activationService.LaunchBen5InstallerAsync();
|
||||
if (!ok)
|
||||
MessageBox.Show(this, "未找到注册补丁安装程序", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
|
||||
private async void CheckActivation_Click(object s, RoutedEventArgs e)
|
||||
{
|
||||
var info = await Task.Run(() => _activationService.GetCurrentStatus());
|
||||
ActivationStatusText.Text = info.IsProfessional
|
||||
? $"✅ 专业版 · {info.LastActivationDate}"
|
||||
: "🔓 社区版";
|
||||
}
|
||||
|
||||
public static void ShowWindow()
|
||||
{
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
var existing = Application.Current.Windows.OfType<BetterSeewoMainWindow>().FirstOrDefault();
|
||||
if (existing != null)
|
||||
{
|
||||
if (existing.WindowState == WindowState.Minimized)
|
||||
existing.WindowState = WindowState.Normal;
|
||||
existing.Activate();
|
||||
return;
|
||||
}
|
||||
|
||||
var window = new BetterSeewoMainWindow();
|
||||
window.Show();
|
||||
var w = Application.Current.Windows.OfType<BetterSeewoMainWindow>().FirstOrDefault();
|
||||
if (w != null) { w.Activate(); return; }
|
||||
new BetterSeewoMainWindow().Show();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user