Files
Better-Seewo/Better-EN5/UI/ManagerMenuItem.cs
miao-moe 8dd1eed519 feat: Better-Seewo v2.0.0 - 希沃白板功能增强插件
- Fluent Design 风格 UI,深色/浅色主题切换
- 平滑过渡动画(页面切换、按钮交互、状态变化)
- 五大核心功能:安装管理、墨迹管理、格式转换、触摸设置、激活管理
- 基于 dotnetCampus.EasiPlugin.Sdk v2.1.1-alpha.3 插件框架
- WPF 安装向导(欢迎页 -> 安装页 -> 完成页)
2026-06-28 06:51:35 +00:00

127 lines
4.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* ManagerMenuItem.cs
* "Better-Seewo 管理" 菜单项
* 所属项目Better-Seewo
* 作者:雾启工作室
*
* 说明:
* 实现白板编辑菜单中的"Better-Seewo 管理"功能。
* 点击后启动 Better-Seewo Manager 管理器程序Manager.exe
* 管理器程序与插件位于同一目录下。
*/
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
using dotnetCampus.EasiPlugin;
namespace Better_Seewo.Better_EN5.UI
{
/// <summary>
/// 管理器启动菜单项
/// 实现 IMenuPluginItem 接口,在白板编辑菜单中显示"Better-Seewo 管理"按钮
/// 点击后启动 Better-Seewo Manager 管理器桌面应用程序
/// </summary>
public class ManagerMenuItem : IMenuPluginItem
{
/// <summary>
/// 菜单项唯一标识符
/// </summary>
public Guid Id { get; } = new Guid("C3D4E5F6-A7B8-9012-CDEF-123456789012");
/// <summary>
/// 菜单项显示标题
/// 根据当前语言环境显示"Better-Seewo 管理"或"Better-Seewo Manager"
/// </summary>
public string Title { get; }
/// <summary>
/// 菜单项排序提示值
/// 值越大越靠前999 表示在菜单中位于最前方
/// </summary>
public int SortHint { get; } = 999;
/// <summary>
/// 语言资源源,用于获取多语言文本
/// </summary>
private readonly DictionaryLanguageSource _languageSource;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="languageSource">中英文双语资源字典</param>
public ManagerMenuItem(DictionaryLanguageSource languageSource)
{
_languageSource = languageSource;
// 从语言资源中获取菜单项标题,默认中文
Title = _languageSource.GetString("Manager.Title") ?? "Better-Seewo 管理";
}
/// <summary>
/// 获取菜单项图标
/// 返回菜单项在工具栏中显示的图标资源路径
/// </summary>
/// <returns>图标资源路径字符串</returns>
public string GetMenuIcon()
{
// 返回管理器图标路径
return "pack://application:,,,/Better-EN5;component/Resources/manager_icon.png";
}
/// <summary>
/// 菜单项点击事件处理
/// 启动 Better-Seewo Manager 管理器程序
/// 管理器位于与插件相同的目录下Manager.exe
/// </summary>
public async Task OnClickAsync()
{
await Task.Run(() =>
{
try
{
// 获取当前插件所在的目录路径
string pluginDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
// 构建管理器可执行文件的完整路径
string managerPath = Path.Combine(pluginDirectory, "Manager.exe");
// 检查管理器程序是否存在
if (!File.Exists(managerPath))
{
System.Windows.MessageBox.Show(
$"未找到管理器程序:\n{managerPath}\n\n请确认 Manager.exe 已正确安装。",
"启动失败",
System.Windows.MessageBoxButton.OK,
System.Windows.MessageBoxImage.Warning);
return;
}
// 启动管理器进程
ProcessStartInfo startInfo = new ProcessStartInfo
{
FileName = managerPath,
// 使用 ShellExecute 以便系统正确处理文件关联
UseShellExecute = true,
// 工作目录设置为插件目录
WorkingDirectory = pluginDirectory,
};
Process.Start(startInfo);
}
catch (Exception ex)
{
// 捕获并提示启动过程中的异常
System.Windows.MessageBox.Show(
$"启动管理器时发生错误:\n{ex.Message}",
"启动失败",
System.Windows.MessageBoxButton.OK,
System.Windows.MessageBoxImage.Error);
}
});
}
}
}