feat: Better-Seewo v2.0.0 - 希沃白板功能增强插件
- Fluent Design 风格 UI,深色/浅色主题切换 - 平滑过渡动画(页面切换、按钮交互、状态变化) - 五大核心功能:安装管理、墨迹管理、格式转换、触摸设置、激活管理 - 基于 dotnetCampus.EasiPlugin.Sdk v2.1.1-alpha.3 插件框架 - WPF 安装向导(欢迎页 -> 安装页 -> 完成页)
This commit is contained in:
118
Better-EN5/UI/ExportInkMenuItem.cs
Normal file
118
Better-EN5/UI/ExportInkMenuItem.cs
Normal file
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
* ExportInkMenuItem.cs
|
||||
* "导出墨迹" 菜单项
|
||||
* 所属项目:Better-Seewo
|
||||
* 作者:雾启工作室
|
||||
*
|
||||
* 说明:
|
||||
* 实现白板编辑菜单中的"导出墨迹"功能。
|
||||
* 点击后将当前白板的墨迹数据导出为 .ink.json 格式的 JSON 文件。
|
||||
* 默认文件名为"课件墨迹.ink.json"。
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
using dotnetCampus.EasiPlugin;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Better_Seewo.Better_EN5.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// 导出墨迹菜单项
|
||||
/// 实现 IMenuPluginItem 接口,在白板编辑菜单中显示"导出墨迹"按钮
|
||||
/// 点击后打开文件保存对话框,将当前白板墨迹序列化为 JSON 文件
|
||||
/// </summary>
|
||||
public class ExportInkMenuItem : IMenuPluginItem
|
||||
{
|
||||
/// <summary>
|
||||
/// 菜单项唯一标识符
|
||||
/// </summary>
|
||||
public Guid Id { get; } = new Guid("A1B2C3D4-E5F6-7890-ABCD-EF1234567890");
|
||||
|
||||
/// <summary>
|
||||
/// 菜单项显示标题
|
||||
/// 根据当前语言环境显示"导出墨迹"或"Export Ink"
|
||||
/// </summary>
|
||||
public string Title { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 菜单项排序提示值
|
||||
/// 值越大越靠前,998 表示在菜单中靠前的位置
|
||||
/// </summary>
|
||||
public int SortHint { get; } = 998;
|
||||
|
||||
/// <summary>
|
||||
/// 语言资源源,用于获取多语言文本
|
||||
/// </summary>
|
||||
private readonly DictionaryLanguageSource _languageSource;
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
/// </summary>
|
||||
/// <param name="languageSource">中英文双语资源字典</param>
|
||||
public ExportInkMenuItem(DictionaryLanguageSource languageSource)
|
||||
{
|
||||
_languageSource = languageSource;
|
||||
// 从语言资源中获取菜单项标题,默认中文
|
||||
Title = _languageSource.GetString("ExportInk.Title") ?? "导出墨迹";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取菜单项图标
|
||||
/// 返回菜单项在工具栏中显示的图标资源路径
|
||||
/// </summary>
|
||||
/// <returns>图标资源路径字符串</returns>
|
||||
public string GetMenuIcon()
|
||||
{
|
||||
// 返回导出图标路径
|
||||
return "pack://application:,,,/Better-EN5;component/Resources/export_icon.png";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 菜单项点击事件处理
|
||||
/// 打开文件保存对话框,将当前白板墨迹导出为 .ink.json 文件
|
||||
/// </summary>
|
||||
public async Task OnClickAsync()
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
// 从白板获取当前墨迹数据
|
||||
var inkData = InkDataHelper.ExportInkData();
|
||||
|
||||
if (inkData == null)
|
||||
{
|
||||
MessageBox.Show("当前白板没有可导出的墨迹数据。", "提示",
|
||||
MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
return;
|
||||
}
|
||||
|
||||
// 创建文件保存对话框
|
||||
var saveFileDialog = new Microsoft.Win32.SaveFileDialog
|
||||
{
|
||||
// 默认文件名
|
||||
FileName = "课件墨迹.ink.json",
|
||||
// 文件过滤器
|
||||
Filter = "墨迹 JSON 文件 (*.ink.json)|*.ink.json|所有文件 (*.*)|*.*",
|
||||
// 默认扩展名
|
||||
DefaultExt = ".ink.json",
|
||||
// 对话框标题
|
||||
Title = "导出墨迹",
|
||||
};
|
||||
|
||||
// 显示保存对话框
|
||||
if (saveFileDialog.ShowDialog() == true)
|
||||
{
|
||||
// 使用 Newtonsoft.Json 将墨迹数据序列化为格式化的 JSON 字符串
|
||||
string json = JsonConvert.SerializeObject(inkData, Formatting.Indented);
|
||||
|
||||
// 写入文件
|
||||
File.WriteAllText(saveFileDialog.FileName, json);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
127
Better-EN5/UI/ImportInkMenuItem.cs
Normal file
127
Better-EN5/UI/ImportInkMenuItem.cs
Normal file
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* ImportInkMenuItem.cs
|
||||
* "导入墨迹" 菜单项
|
||||
* 所属项目:Better-Seewo
|
||||
* 作者:雾启工作室
|
||||
*
|
||||
* 说明:
|
||||
* 实现白板编辑菜单中的"导入墨迹"功能。
|
||||
* 点击后打开文件选择对话框,选择 .ink.json 文件导入到当前白板。
|
||||
* 默认文件名为"课件墨迹.ink.json"。
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
using dotnetCampus.EasiPlugin;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Better_Seewo.Better_EN5.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// 导入墨迹菜单项
|
||||
/// 实现 IMenuPluginItem 接口,在白板编辑菜单中显示"导入墨迹"按钮
|
||||
/// 点击后打开文件选择对话框,读取 JSON 文件并将墨迹数据应用到白板
|
||||
/// </summary>
|
||||
public class ImportInkMenuItem : IMenuPluginItem
|
||||
{
|
||||
/// <summary>
|
||||
/// 菜单项唯一标识符
|
||||
/// </summary>
|
||||
public Guid Id { get; } = new Guid("B2C3D4E5-F6A7-8901-BCDE-F12345678901");
|
||||
|
||||
/// <summary>
|
||||
/// 菜单项显示标题
|
||||
/// 根据当前语言环境显示"导入墨迹"或"Import Ink"
|
||||
/// </summary>
|
||||
public string Title { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 菜单项排序提示值
|
||||
/// 值越大越靠前,997 表示在菜单中位于"导出墨迹"之后
|
||||
/// </summary>
|
||||
public int SortHint { get; } = 997;
|
||||
|
||||
/// <summary>
|
||||
/// 语言资源源,用于获取多语言文本
|
||||
/// </summary>
|
||||
private readonly DictionaryLanguageSource _languageSource;
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
/// </summary>
|
||||
/// <param name="languageSource">中英文双语资源字典</param>
|
||||
public ImportInkMenuItem(DictionaryLanguageSource languageSource)
|
||||
{
|
||||
_languageSource = languageSource;
|
||||
// 从语言资源中获取菜单项标题,默认中文
|
||||
Title = _languageSource.GetString("ImportInk.Title") ?? "导入墨迹";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取菜单项图标
|
||||
/// 返回菜单项在工具栏中显示的图标资源路径
|
||||
/// </summary>
|
||||
/// <returns>图标资源路径字符串</returns>
|
||||
public string GetMenuIcon()
|
||||
{
|
||||
// 返回导入图标路径
|
||||
return "pack://application:,,,/Better-EN5;component/Resources/import_icon.png";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 菜单项点击事件处理
|
||||
/// 打开文件选择对话框,读取 .ink.json 文件并将墨迹数据导入到当前白板
|
||||
/// </summary>
|
||||
public async Task OnClickAsync()
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
// 创建文件选择对话框
|
||||
var openFileDialog = new Microsoft.Win32.OpenFileDialog
|
||||
{
|
||||
// 默认文件名
|
||||
FileName = "课件墨迹.ink.json",
|
||||
// 文件过滤器
|
||||
Filter = "墨迹 JSON 文件 (*.ink.json)|*.ink.json|所有文件 (*.*)|*.*",
|
||||
// 默认扩展名
|
||||
DefaultExt = ".ink.json",
|
||||
// 对话框标题
|
||||
Title = "导入墨迹",
|
||||
};
|
||||
|
||||
// 显示打开对话框
|
||||
if (openFileDialog.ShowDialog() == true)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 读取 JSON 文件内容
|
||||
string json = File.ReadAllText(openFileDialog.FileName);
|
||||
|
||||
// 使用 Newtonsoft.Json 反序列化墨迹数据
|
||||
var inkData = JsonConvert.DeserializeObject<InkStrokeCollection>(json);
|
||||
|
||||
if (inkData == null)
|
||||
{
|
||||
MessageBox.Show("无法解析所选文件的墨迹数据。", "导入失败",
|
||||
MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
// 将墨迹数据应用到白板
|
||||
InkDataHelper.ImportInkData(inkData);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// 捕获并提示导入过程中的异常
|
||||
MessageBox.Show($"导入墨迹时发生错误:\n{ex.Message}", "导入失败",
|
||||
MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
240
Better-EN5/UI/InkDataHelper.cs
Normal file
240
Better-EN5/UI/InkDataHelper.cs
Normal file
@@ -0,0 +1,240 @@
|
||||
/*
|
||||
* InkDataHelper.cs
|
||||
* 墨迹数据辅助类
|
||||
* 所属项目:Better-Seewo
|
||||
* 作者:雾启工作室
|
||||
*
|
||||
* 说明:
|
||||
* 提供墨迹数据的导出和导入功能。
|
||||
* ExportInkData:从白板获取当前墨迹数据并封装为可序列化的模型
|
||||
* ImportInkData:将墨迹数据模型应用到白板
|
||||
* InkStrokeCollection:墨迹笔画集合数据模型,用于 JSON 序列化
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using dotnetCampus.EasiPlugin;
|
||||
|
||||
namespace Better_Seewo.Better_EN5.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// 墨迹数据辅助类
|
||||
/// 提供从白板导出墨迹数据和向白板导入墨迹数据的静态方法
|
||||
/// </summary>
|
||||
public static class InkDataHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 从当前白板获取墨迹数据并导出为 InkStrokeCollection 模型
|
||||
/// 通过白板 SDK 接口读取当前页面的所有墨迹笔画信息
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// 包含所有墨迹笔画数据的 InkStrokeCollection;
|
||||
/// 如果白板没有墨迹则返回 null
|
||||
/// </returns>
|
||||
public static InkStrokeCollection ExportInkData()
|
||||
{
|
||||
// 获取白板当前页面的墨迹对象集合
|
||||
var inkObjects = EN.BoardEditMenu.GetCurrentPageInkObjects();
|
||||
|
||||
if (inkObjects == null || inkObjects.Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// 构建墨迹笔画集合
|
||||
var collection = new InkStrokeCollection
|
||||
{
|
||||
// 导出时间戳
|
||||
ExportTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
// 版本号,用于后续格式兼容
|
||||
Version = "1.0",
|
||||
};
|
||||
|
||||
// 遍历所有墨迹对象,提取笔画数据
|
||||
foreach (var inkObject in inkObjects)
|
||||
{
|
||||
var stroke = new InkStroke
|
||||
{
|
||||
// 笔画唯一标识
|
||||
Id = inkObject.Id.ToString(),
|
||||
// 笔画类型(如自由画笔、直线、圆形等)
|
||||
StrokeType = inkObject.StrokeType.ToString(),
|
||||
// 笔画颜色(ARGB 格式)
|
||||
Color = inkObject.Color.ToArgb(),
|
||||
// 笔画粗细(像素)
|
||||
Thickness = inkObject.Thickness,
|
||||
// 笔画的点集合(每个点包含 X、Y 坐标和压力值)
|
||||
Points = inkObject.GetPoints().Select(p => new InkPoint
|
||||
{
|
||||
X = p.X,
|
||||
Y = p.Y,
|
||||
// 压力值,用于支持压感笔
|
||||
Pressure = p.Pressure,
|
||||
}).ToList(),
|
||||
};
|
||||
|
||||
collection.Strokes.Add(stroke);
|
||||
}
|
||||
|
||||
return collection;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将墨迹数据导入到当前白板
|
||||
/// 读取 InkStrokeCollection 模型并通过白板 SDK 接口创建对应的墨迹笔画
|
||||
/// </summary>
|
||||
/// <param name="inkData">要导入的墨迹数据集合</param>
|
||||
public static void ImportInkData(InkStrokeCollection inkData)
|
||||
{
|
||||
if (inkData == null || inkData.Strokes == null || inkData.Strokes.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 遍历所有笔画数据,逐个创建墨迹对象并添加到白板
|
||||
foreach (var stroke in inkData.Strokes)
|
||||
{
|
||||
// 解析颜色值
|
||||
var color = System.Drawing.Color.FromArgb(stroke.Color);
|
||||
|
||||
// 将 InkPoint 列表转换为白板 SDK 所需的点集合
|
||||
var points = stroke.Points.Select(p => new InkPointData
|
||||
{
|
||||
X = p.X,
|
||||
Y = p.Y,
|
||||
Pressure = p.Pressure,
|
||||
}).ToArray();
|
||||
|
||||
// 创建墨迹对象并添加到当前白板页面
|
||||
var inkObject = EN.BoardEditMenu.CreateInkObject(
|
||||
strokeType: ParseStrokeType(stroke.StrokeType),
|
||||
color: color,
|
||||
thickness: stroke.Thickness,
|
||||
points: points
|
||||
);
|
||||
|
||||
// 将墨迹对象添加到白板
|
||||
EN.BoardEditMenu.AddInkObjectToCurrentPage(inkObject);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 解析笔画类型字符串为枚举值
|
||||
/// </summary>
|
||||
/// <param name="strokeTypeStr">笔画类型字符串</param>
|
||||
/// <returns>对应的笔画类型枚举</returns>
|
||||
private static StrokeType ParseStrokeType(string strokeTypeStr)
|
||||
{
|
||||
// 尝试解析字符串为枚举值,解析失败则使用默认的自由画笔类型
|
||||
if (Enum.TryParse<StrokeType>(strokeTypeStr, out var result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
return StrokeType.FreeDraw;
|
||||
}
|
||||
}
|
||||
|
||||
#region 墨迹数据模型
|
||||
|
||||
/// <summary>
|
||||
/// 墨迹笔画集合数据模型
|
||||
/// 包含一组墨迹笔画的完整信息,用于 JSON 序列化和反序列化
|
||||
/// </summary>
|
||||
public class InkStrokeCollection
|
||||
{
|
||||
/// <summary>
|
||||
/// 导出版本号
|
||||
/// 用于后续格式升级时的兼容性判断
|
||||
/// </summary>
|
||||
[JsonProperty("version")]
|
||||
public string Version { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 导出时间戳
|
||||
/// 记录墨迹导出的具体时间
|
||||
/// </summary>
|
||||
[JsonProperty("exportTime")]
|
||||
public string ExportTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 笔画集合
|
||||
/// 包含当前白板页面上的所有墨迹笔画数据
|
||||
/// </summary>
|
||||
[JsonProperty("strokes")]
|
||||
public List<InkStroke> Strokes { get; set; } = new List<InkStroke>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 单条墨迹笔画数据模型
|
||||
/// 描述一笔连续的墨迹,包含颜色、粗细、点集合等属性
|
||||
/// </summary>
|
||||
public class InkStroke
|
||||
{
|
||||
/// <summary>
|
||||
/// 笔画唯一标识
|
||||
/// 原始白板中该笔画的 ID,导入时可用于匹配和覆盖
|
||||
/// </summary>
|
||||
[JsonProperty("id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 笔画类型
|
||||
/// 如 FreeDraw(自由画笔)、Line(直线)、Ellipse(椭圆)等
|
||||
/// </summary>
|
||||
[JsonProperty("strokeType")]
|
||||
public string StrokeType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 笔画颜色
|
||||
/// 使用 ARGB 整数值表示(与 System.Drawing.Color.FromArgb 兼容)
|
||||
/// </summary>
|
||||
[JsonProperty("color")]
|
||||
public int Color { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 笔画粗细
|
||||
/// 单位为像素,表示笔画的线条宽度
|
||||
/// </summary>
|
||||
[JsonProperty("thickness")]
|
||||
public double Thickness { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 笔画点集合
|
||||
/// 一组有序的坐标点,构成笔画的路径
|
||||
/// </summary>
|
||||
[JsonProperty("points")]
|
||||
public List<InkPoint> Points { get; set; } = new List<InkPoint>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 墨迹点数据模型
|
||||
/// 表示墨迹路径上的一个采样点,包含坐标和压力值
|
||||
/// </summary>
|
||||
public class InkPoint
|
||||
{
|
||||
/// <summary>
|
||||
/// X 轴坐标
|
||||
/// </summary>
|
||||
[JsonProperty("x")]
|
||||
public double X { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Y 轴坐标
|
||||
/// </summary>
|
||||
[JsonProperty("y")]
|
||||
public double Y { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 压力值
|
||||
/// 用于支持压感笔设备,值范围为 0.0 ~ 1.0
|
||||
/// </summary>
|
||||
[JsonProperty("pressure")]
|
||||
public double Pressure { get; set; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
126
Better-EN5/UI/ManagerMenuItem.cs
Normal file
126
Better-EN5/UI/ManagerMenuItem.cs
Normal file
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user