From 454078ec82abd63f180d0f239265477fe2dd41c7 Mon Sep 17 00:00:00 2001
From: CJKmkp <2564608840@qq.com>
Date: Sun, 24 Aug 2025 12:02:29 +0800
Subject: [PATCH 1/7] =?UTF-8?q?add:=E6=9B=B4=E5=A4=9A=E6=8F=92=E4=BB=B6?=
=?UTF-8?q?=E6=94=AF=E6=8C=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Helpers/Plugins/EnhancedPluginBase.cs | 93 +++
Ink Canvas/Helpers/Plugins/IEnhancedPlugin.cs | 49 ++
Ink Canvas/Helpers/Plugins/IPluginService.cs | 558 ++++++++++++++++++
.../Plugins/PluginConfigurationManager.cs | 276 +++++++++
.../Helpers/Plugins/PluginServiceManager.cs | 458 ++++++++++++++
5 files changed, 1434 insertions(+)
create mode 100644 Ink Canvas/Helpers/Plugins/EnhancedPluginBase.cs
create mode 100644 Ink Canvas/Helpers/Plugins/IEnhancedPlugin.cs
create mode 100644 Ink Canvas/Helpers/Plugins/IPluginService.cs
create mode 100644 Ink Canvas/Helpers/Plugins/PluginConfigurationManager.cs
create mode 100644 Ink Canvas/Helpers/Plugins/PluginServiceManager.cs
diff --git a/Ink Canvas/Helpers/Plugins/EnhancedPluginBase.cs b/Ink Canvas/Helpers/Plugins/EnhancedPluginBase.cs
new file mode 100644
index 00000000..cf3c0b47
--- /dev/null
+++ b/Ink Canvas/Helpers/Plugins/EnhancedPluginBase.cs
@@ -0,0 +1,93 @@
+using System;
+using System.Windows.Controls;
+
+namespace Ink_Canvas.Helpers.Plugins
+{
+ ///
+ /// 增强的插件基类,提供对插件服务的访问和基本实现
+ ///
+ public abstract class EnhancedPluginBase : PluginBase, IEnhancedPlugin
+ {
+ ///
+ /// 插件服务实例
+ ///
+ public IPluginService PluginService { get; private set; }
+
+ ///
+ /// 构造函数
+ ///
+ protected EnhancedPluginBase()
+ {
+ PluginService = PluginServiceManager.Instance;
+ }
+
+ ///
+ /// 插件启动时调用,在Initialize之后
+ ///
+ public virtual void OnStartup()
+ {
+ LogHelper.WriteLogToFile($"插件 {Name} 已启动");
+ }
+
+ ///
+ /// 插件关闭时调用,在Cleanup之前
+ ///
+ public virtual void OnShutdown()
+ {
+ LogHelper.WriteLogToFile($"插件 {Name} 正在关闭");
+ }
+
+ ///
+ /// 获取插件的菜单项
+ ///
+ /// 菜单项集合
+ public virtual MenuItem[] GetMenuItems()
+ {
+ return new MenuItem[0];
+ }
+
+ ///
+ /// 获取插件的工具栏按钮
+ ///
+ /// 工具栏按钮集合
+ public virtual Button[] GetToolbarButtons()
+ {
+ return new Button[0];
+ }
+
+ ///
+ /// 获取插件的状态栏信息
+ ///
+ /// 状态栏信息
+ public virtual string GetStatusBarInfo()
+ {
+ return $"{Name} v{Version} - {(IsEnabled ? "已启用" : "已禁用")}";
+ }
+
+ ///
+ /// 插件配置变更时调用
+ ///
+ public virtual void OnConfigurationChanged()
+ {
+ LogHelper.WriteLogToFile($"插件 {Name} 配置已变更");
+ }
+
+ ///
+ /// 重写初始化方法,调用OnStartup
+ ///
+ public override void Initialize()
+ {
+ base.Initialize();
+ OnStartup();
+ }
+
+ ///
+ /// 重写清理方法,调用OnShutdown
+ ///
+ public override void Cleanup()
+ {
+ OnShutdown();
+ base.Cleanup();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Ink Canvas/Helpers/Plugins/IEnhancedPlugin.cs b/Ink Canvas/Helpers/Plugins/IEnhancedPlugin.cs
new file mode 100644
index 00000000..270064db
--- /dev/null
+++ b/Ink Canvas/Helpers/Plugins/IEnhancedPlugin.cs
@@ -0,0 +1,49 @@
+using System;
+using System.Windows.Controls;
+
+namespace Ink_Canvas.Helpers.Plugins
+{
+ ///
+ /// 增强的插件接口,提供对插件服务的访问
+ ///
+ public interface IEnhancedPlugin : IPlugin
+ {
+ ///
+ /// 获取插件服务实例
+ ///
+ IPluginService PluginService { get; }
+
+ ///
+ /// 插件启动时调用,在Initialize之后
+ ///
+ void OnStartup();
+
+ ///
+ /// 插件关闭时调用,在Cleanup之前
+ ///
+ void OnShutdown();
+
+ ///
+ /// 获取插件的菜单项
+ ///
+ /// 菜单项集合
+ MenuItem[] GetMenuItems();
+
+ ///
+ /// 获取插件的工具栏按钮
+ ///
+ /// 工具栏按钮集合
+ Button[] GetToolbarButtons();
+
+ ///
+ /// 获取插件的状态栏信息
+ ///
+ /// 状态栏信息
+ string GetStatusBarInfo();
+
+ ///
+ /// 插件配置变更时调用
+ ///
+ void OnConfigurationChanged();
+ }
+}
\ No newline at end of file
diff --git a/Ink Canvas/Helpers/Plugins/IPluginService.cs b/Ink Canvas/Helpers/Plugins/IPluginService.cs
new file mode 100644
index 00000000..3063f85f
--- /dev/null
+++ b/Ink Canvas/Helpers/Plugins/IPluginService.cs
@@ -0,0 +1,558 @@
+using System;
+using System.Collections.Generic;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Ink;
+using System.Windows.Media;
+
+namespace Ink_Canvas.Helpers.Plugins
+{
+ ///
+ /// 插件服务接口,提供对软件内部功能的访问
+ ///
+ public interface IPluginService
+ {
+ #region 窗口和UI访问
+
+ ///
+ /// 获取主窗口引用
+ ///
+ Window MainWindow { get; }
+
+ ///
+ /// 获取当前画布
+ ///
+ InkCanvas CurrentCanvas { get; }
+
+ ///
+ /// 获取所有画布页面
+ ///
+ List