80 lines
2.3 KiB
C#
80 lines
2.3 KiB
C#
|
|
using System;
|
||
|
|
using System.IO;
|
||
|
|
using System.Threading.Tasks;
|
||
|
|
using System.Windows;
|
||
|
|
using System.Windows.Controls;
|
||
|
|
|
||
|
|
namespace BetterSeewoInstaller.Pages;
|
||
|
|
|
||
|
|
public partial class InstallPage : Page
|
||
|
|
{
|
||
|
|
public InstallPage()
|
||
|
|
{
|
||
|
|
InitializeComponent();
|
||
|
|
Loaded += OnLoaded;
|
||
|
|
}
|
||
|
|
|
||
|
|
private async void OnLoaded(object sender, RoutedEventArgs e)
|
||
|
|
{
|
||
|
|
await RunInstall();
|
||
|
|
}
|
||
|
|
|
||
|
|
private async Task RunInstall()
|
||
|
|
{
|
||
|
|
try
|
||
|
|
{
|
||
|
|
StatusText.Text = "正在检查环境...";
|
||
|
|
DetailText.Text = "查找 EN5 安装路径";
|
||
|
|
ProgressBar.Value = 10;
|
||
|
|
|
||
|
|
var en5Path = @"C:\Program Files (x86)\Seewo\EasiNote5\EasiNote5_5.2.4.9855\Main";
|
||
|
|
if (!Directory.Exists(en5Path))
|
||
|
|
{
|
||
|
|
StatusText.Text = "错误:未找到 EN5";
|
||
|
|
DetailText.Text = "请先安装希沃白板 EN5";
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
await Task.Delay(500);
|
||
|
|
|
||
|
|
StatusText.Text = "正在安装插件...";
|
||
|
|
DetailText.Text = "复制插件文件到 EN5 Plugins 目录";
|
||
|
|
ProgressBar.Value = 40;
|
||
|
|
|
||
|
|
var pluginDir = Path.Combine(en5Path, "Plugins", "Better-EN5");
|
||
|
|
Directory.CreateDirectory(pluginDir);
|
||
|
|
|
||
|
|
// 复制插件 DLL
|
||
|
|
var sourceDir = AppDomain.CurrentDomain.BaseDirectory;
|
||
|
|
var pluginFiles = new[] { "Better-EN5.dll" };
|
||
|
|
foreach (var file in pluginFiles)
|
||
|
|
{
|
||
|
|
var src = Path.Combine(sourceDir, file);
|
||
|
|
var dst = Path.Combine(pluginDir, file);
|
||
|
|
if (File.Exists(src))
|
||
|
|
File.Copy(src, dst, true);
|
||
|
|
}
|
||
|
|
|
||
|
|
await Task.Delay(500);
|
||
|
|
|
||
|
|
StatusText.Text = "正在安装管理器...";
|
||
|
|
DetailText.Text = "复制管理器文件";
|
||
|
|
ProgressBar.Value = 70;
|
||
|
|
|
||
|
|
var mgrDir = Path.Combine(en5Path, "Plugins", "Better-Seewo-Manager");
|
||
|
|
Directory.CreateDirectory(mgrDir);
|
||
|
|
|
||
|
|
await Task.Delay(500);
|
||
|
|
|
||
|
|
StatusText.Text = "安装完成";
|
||
|
|
DetailText.Text = "Better-Seewo 已成功安装";
|
||
|
|
ProgressBar.Value = 100;
|
||
|
|
}
|
||
|
|
catch (Exception ex)
|
||
|
|
{
|
||
|
|
StatusText.Text = "安装失败";
|
||
|
|
DetailText.Text = ex.Message;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|