diff --git a/AutomaticUpdateVersionControl.txt b/AutomaticUpdateVersionControl.txt index 76cbaaf4..776d144c 100644 --- a/AutomaticUpdateVersionControl.txt +++ b/AutomaticUpdateVersionControl.txt @@ -1 +1 @@ -1.7.7.0 +1.7.8.0 diff --git a/Ink Canvas/AssemblyInfo.cs b/Ink Canvas/AssemblyInfo.cs index 00caa8a6..0ee36e4e 100644 --- a/Ink Canvas/AssemblyInfo.cs +++ b/Ink Canvas/AssemblyInfo.cs @@ -49,5 +49,5 @@ using System.Windows; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.7.7.7")] -[assembly: AssemblyFileVersion("1.7.7.7")] +[assembly: AssemblyVersion("1.7.8.0")] +[assembly: AssemblyFileVersion("1.7.8.0")] 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 AllCanvasPages { get; } + + /// + /// 获取当前页面索引 + /// + int CurrentPageIndex { get; } + + /// + /// 获取当前页面数量 + /// + int TotalPageCount { get; } + + /// + /// 获取浮动工具栏 + /// + FrameworkElement FloatingToolBar { get; } + + /// + /// 获取左侧面板 + /// + FrameworkElement LeftPanel { get; } + + /// + /// 获取右侧面板 + /// + FrameworkElement RightPanel { get; } + + /// + /// 获取顶部面板 + /// + FrameworkElement TopPanel { get; } + + /// + /// 获取底部面板 + /// + FrameworkElement BottomPanel { get; } + + #endregion + + #region 绘制工具状态 + + /// + /// 获取当前绘制模式 + /// + int CurrentDrawingMode { get; } + + /// + /// 获取当前笔触宽度 + /// + double CurrentInkWidth { get; } + + /// + /// 获取当前笔触颜色 + /// + Color CurrentInkColor { get; } + + /// + /// 获取当前高亮笔宽度 + /// + double CurrentHighlighterWidth { get; } + + /// + /// 获取当前橡皮擦大小 + /// + int CurrentEraserSize { get; } + + /// + /// 获取当前橡皮擦类型 + /// + int CurrentEraserType { get; } + + /// + /// 获取当前橡皮擦形状 + /// + int CurrentEraserShape { get; } + + /// + /// 获取当前笔触透明度 + /// + double CurrentInkAlpha { get; } + + /// + /// 获取当前笔触样式 + /// + int CurrentInkStyle { get; } + + /// + /// 获取当前背景颜色 + /// + string CurrentBackgroundColor { get; } + + #endregion + + #region 应用状态 + + /// + /// 获取当前主题模式 + /// + bool IsDarkTheme { get; } + + /// + /// 获取当前是否为白板模式 + /// + bool IsWhiteboardMode { get; } + + /// + /// 获取当前是否为PPT模式 + /// + bool IsPPTMode { get; } + + /// + /// 获取当前是否为全屏模式 + /// + bool IsFullScreenMode { get; } + + /// + /// 获取当前是否为画板模式 + /// + bool IsCanvasMode { get; } + + /// + /// 获取当前是否为选择模式 + /// + bool IsSelectionMode { get; } + + /// + /// 获取当前是否为擦除模式 + /// + bool IsEraserMode { get; } + + /// + /// 获取当前是否为形状绘制模式 + /// + bool IsShapeDrawingMode { get; } + + /// + /// 获取当前是否为高亮模式 + /// + bool IsHighlighterMode { get; } + + #endregion + + #region 画布操作 + + /// + /// 清除当前画布 + /// + void ClearCanvas(); + + /// + /// 清除所有画布 + /// + void ClearAllCanvases(); + + /// + /// 添加新页面 + /// + void AddNewPage(); + + /// + /// 删除当前页面 + /// + void DeleteCurrentPage(); + + /// + /// 切换到指定页面 + /// + /// 页面索引 + void SwitchToPage(int pageIndex); + + /// + /// 切换到下一页 + /// + void NextPage(); + + /// + /// 切换到上一页 + /// + void PreviousPage(); + + #endregion + + #region 绘制操作 + + /// + /// 设置绘制模式 + /// + /// 绘制模式 + void SetDrawingMode(int mode); + + /// + /// 设置笔触宽度 + /// + /// 宽度 + void SetInkWidth(double width); + + /// + /// 设置笔触颜色 + /// + /// 颜色 + void SetInkColor(Color color); + + /// + /// 设置高亮笔宽度 + /// + /// 宽度 + void SetHighlighterWidth(double width); + + /// + /// 设置橡皮擦大小 + /// + /// 大小 + void SetEraserSize(int size); + + /// + /// 设置橡皮擦类型 + /// + /// 类型 + void SetEraserType(int type); + + /// + /// 设置橡皮擦形状 + /// + /// 形状 + void SetEraserShape(int shape); + + /// + /// 设置笔触透明度 + /// + /// 透明度 + void SetInkAlpha(double alpha); + + /// + /// 设置笔触样式 + /// + /// 样式 + void SetInkStyle(int style); + + /// + /// 设置背景颜色 + /// + /// 颜色 + void SetBackgroundColor(string color); + + #endregion + + #region 文件操作 + + /// + /// 保存画布内容 + /// + /// 文件路径 + void SaveCanvas(string filePath); + + /// + /// 加载画布内容 + /// + /// 文件路径 + void LoadCanvas(string filePath); + + /// + /// 导出为图片 + /// + /// 文件路径 + /// 图片格式 + void ExportAsImage(string filePath, string format); + + /// + /// 导出为PDF + /// + /// 文件路径 + void ExportAsPDF(string filePath); + + #endregion + + #region 撤销重做 + + /// + /// 撤销操作 + /// + void Undo(); + + /// + /// 重做操作 + /// + void Redo(); + + /// + /// 是否可以撤销 + /// + bool CanUndo { get; } + + /// + /// 是否可以重做 + /// + bool CanRedo { get; } + + #endregion + + #region 选择操作 + + /// + /// 全选 + /// + void SelectAll(); + + /// + /// 取消选择 + /// + void DeselectAll(); + + /// + /// 删除选中内容 + /// + void DeleteSelected(); + + /// + /// 复制选中内容 + /// + void CopySelected(); + + /// + /// 剪切选中内容 + /// + void CutSelected(); + + /// + /// 粘贴内容 + /// + void Paste(); + + #endregion + + #region 窗口管理 + + /// + /// 显示设置窗口 + /// + void ShowSettingsWindow(); + + /// + /// 隐藏设置窗口 + /// + void HideSettingsWindow(); + + /// + /// 显示插件设置窗口 + /// + void ShowPluginSettingsWindow(); + + /// + /// 隐藏插件设置窗口 + /// + void HidePluginSettingsWindow(); + + /// + /// 显示帮助窗口 + /// + void ShowHelpWindow(); + + /// + /// 隐藏帮助窗口 + /// + void HideHelpWindow(); + + /// + /// 显示关于窗口 + /// + void ShowAboutWindow(); + + /// + /// 隐藏关于窗口 + /// + void HideAboutWindow(); + + #endregion + + #region 通知和消息 + + /// + /// 显示通知消息 + /// + /// 消息内容 + /// 消息类型 + void ShowNotification(string message, NotificationType type = NotificationType.Info); + + /// + /// 显示确认对话框 + /// + /// 消息内容 + /// 标题 + /// 用户选择结果 + bool ShowConfirmDialog(string message, string title = "确认"); + + /// + /// 显示输入对话框 + /// + /// 提示消息 + /// 标题 + /// 默认值 + /// 用户输入内容 + string ShowInputDialog(string message, string title = "输入", string defaultValue = ""); + + #endregion + + #region 系统功能 + + /// + /// 获取系统设置 + /// + /// 设置类型 + /// 设置键 + /// 默认值 + /// 设置值 + T GetSetting(string key, T defaultValue = default(T)); + + /// + /// 设置系统设置 + /// + /// 设置类型 + /// 设置键 + /// 设置值 + void SetSetting(string key, T value); + + /// + /// 保存设置到文件 + /// + void SaveSettings(); + + /// + /// 从文件加载设置 + /// + void LoadSettings(); + + /// + /// 重置设置为默认值 + /// + void ResetSettings(); + + #endregion + + #region 插件管理 + + /// + /// 获取所有已加载的插件 + /// + /// 插件列表 + List GetAllPlugins(); + + /// + /// 获取指定插件 + /// + /// 插件名称 + /// 插件实例 + IPlugin GetPlugin(string pluginName); + + /// + /// 启用插件 + /// + /// 插件名称 + void EnablePlugin(string pluginName); + + /// + /// 禁用插件 + /// + /// 插件名称 + void DisablePlugin(string pluginName); + + /// + /// 卸载插件 + /// + /// 插件名称 + void UnloadPlugin(string pluginName); + + #endregion + + #region 事件系统 + + /// + /// 注册事件处理器 + /// + /// 事件名称 + /// 事件处理器 + void RegisterEventHandler(string eventName, EventHandler handler); + + /// + /// 注销事件处理器 + /// + /// 事件名称 + /// 事件处理器 + void UnregisterEventHandler(string eventName, EventHandler handler); + + /// + /// 触发事件 + /// + /// 事件名称 + /// 事件发送者 + /// 事件参数 + void TriggerEvent(string eventName, object sender, EventArgs args); + + #endregion + } + + /// + /// 通知类型枚举 + /// + public enum NotificationType + { + /// + /// 信息 + /// + Info, + + /// + /// 成功 + /// + Success, + + /// + /// 警告 + /// + Warning, + + /// + /// 错误 + /// + Error + } +} \ No newline at end of file diff --git a/Ink Canvas/Helpers/Plugins/PluginConfigurationManager.cs b/Ink Canvas/Helpers/Plugins/PluginConfigurationManager.cs new file mode 100644 index 00000000..c328b642 --- /dev/null +++ b/Ink Canvas/Helpers/Plugins/PluginConfigurationManager.cs @@ -0,0 +1,276 @@ +using Ink_Canvas.Helpers; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; + +namespace Ink_Canvas.Helpers.Plugins +{ + /// + /// 插件配置管理器,允许插件管理自己的配置 + /// + public class PluginConfigurationManager + { + private static readonly string PluginConfigDirectory = Path.Combine(App.RootPath, "PluginConfigs"); + private static readonly Dictionary> _pluginConfigs = new Dictionary>(); + private static readonly object _lockObject = new object(); + + static PluginConfigurationManager() + { + // 确保配置目录存在 + if (!Directory.Exists(PluginConfigDirectory)) + { + Directory.CreateDirectory(PluginConfigDirectory); + } + } + + /// + /// 获取插件配置值 + /// + /// 配置值类型 + /// 插件名称 + /// 配置键 + /// 默认值 + /// 配置值 + public static T GetConfiguration(string pluginName, string key, T defaultValue = default(T)) + { + lock (_lockObject) + { + try + { + if (_pluginConfigs.TryGetValue(pluginName, out var pluginConfig)) + { + if (pluginConfig.TryGetValue(key, out var value)) + { + if (value is T typedValue) + { + return typedValue; + } + else + { + // 尝试类型转换 + try + { + return (T)Convert.ChangeType(value, typeof(T)); + } + catch + { + return defaultValue; + } + } + } + } + } + catch (Exception ex) + { + LogHelper.WriteLogToFile($"获取插件 {pluginName} 配置 {key} 时出错: {ex.Message}", LogHelper.LogType.Error); + } + + return defaultValue; + } + } + + /// + /// 设置插件配置值 + /// + /// 配置值类型 + /// 插件名称 + /// 配置键 + /// 配置值 + public static void SetConfiguration(string pluginName, string key, T value) + { + lock (_lockObject) + { + try + { + if (!_pluginConfigs.ContainsKey(pluginName)) + { + _pluginConfigs[pluginName] = new Dictionary(); + } + + _pluginConfigs[pluginName][key] = value; + + // 异步保存配置 + Task.Run(() => SavePluginConfiguration(pluginName)); + } + catch (Exception ex) + { + LogHelper.WriteLogToFile($"设置插件 {pluginName} 配置 {key} 时出错: {ex.Message}", LogHelper.LogType.Error); + } + } + } + + /// + /// 删除插件配置 + /// + /// 插件名称 + /// 配置键 + public static void RemoveConfiguration(string pluginName, string key) + { + lock (_lockObject) + { + try + { + if (_pluginConfigs.TryGetValue(pluginName, out var pluginConfig)) + { + if (pluginConfig.Remove(key)) + { + // 异步保存配置 + Task.Run(() => SavePluginConfiguration(pluginName)); + } + } + } + catch (Exception ex) + { + LogHelper.WriteLogToFile($"删除插件 {pluginName} 配置 {key} 时出错: {ex.Message}", LogHelper.LogType.Error); + } + } + } + + /// + /// 获取插件的所有配置 + /// + /// 插件名称 + /// 配置字典 + public static Dictionary GetAllConfigurations(string pluginName) + { + lock (_lockObject) + { + if (_pluginConfigs.TryGetValue(pluginName, out var pluginConfig)) + { + return new Dictionary(pluginConfig); + } + return new Dictionary(); + } + } + + /// + /// 清除插件的所有配置 + /// + /// 插件名称 + public static void ClearAllConfigurations(string pluginName) + { + lock (_lockObject) + { + try + { + if (_pluginConfigs.Remove(pluginName)) + { + // 删除配置文件 + string configFile = Path.Combine(PluginConfigDirectory, $"{pluginName}.json"); + if (File.Exists(configFile)) + { + File.Delete(configFile); + } + } + } + catch (Exception ex) + { + LogHelper.WriteLogToFile($"清除插件 {pluginName} 所有配置时出错: {ex.Message}", LogHelper.LogType.Error); + } + } + } + + /// + /// 加载插件配置 + /// + /// 插件名称 + public static void LoadPluginConfiguration(string pluginName) + { + try + { + string configFile = Path.Combine(PluginConfigDirectory, $"{pluginName}.json"); + if (File.Exists(configFile)) + { + string json = File.ReadAllText(configFile); + var config = JsonConvert.DeserializeObject>(json); + + lock (_lockObject) + { + _pluginConfigs[pluginName] = config ?? new Dictionary(); + } + + LogHelper.WriteLogToFile($"已加载插件 {pluginName} 的配置"); + } + } + catch (Exception ex) + { + LogHelper.WriteLogToFile($"加载插件 {pluginName} 配置时出错: {ex.Message}", LogHelper.LogType.Error); + } + } + + /// + /// 保存插件配置 + /// + /// 插件名称 + private static void SavePluginConfiguration(string pluginName) + { + try + { + Dictionary pluginConfig; + lock (_lockObject) + { + if (!_pluginConfigs.TryGetValue(pluginName, out pluginConfig)) + { + return; + } + } + + string configFile = Path.Combine(PluginConfigDirectory, $"{pluginName}.json"); + string json = JsonConvert.SerializeObject(pluginConfig, Formatting.Indented); + File.WriteAllText(configFile, json); + + LogHelper.WriteLogToFile($"已保存插件 {pluginName} 的配置"); + } + catch (Exception ex) + { + LogHelper.WriteLogToFile($"保存插件 {pluginName} 配置时出错: {ex.Message}", LogHelper.LogType.Error); + } + } + + /// + /// 加载所有插件的配置 + /// + public static void LoadAllPluginConfigurations() + { + try + { + if (Directory.Exists(PluginConfigDirectory)) + { + string[] configFiles = Directory.GetFiles(PluginConfigDirectory, "*.json"); + foreach (string configFile in configFiles) + { + string pluginName = Path.GetFileNameWithoutExtension(configFile); + LoadPluginConfiguration(pluginName); + } + } + } + catch (Exception ex) + { + LogHelper.WriteLogToFile($"加载所有插件配置时出错: {ex.Message}", LogHelper.LogType.Error); + } + } + + /// + /// 保存所有插件的配置 + /// + public static void SaveAllPluginConfigurations() + { + try + { + lock (_lockObject) + { + foreach (string pluginName in _pluginConfigs.Keys) + { + SavePluginConfiguration(pluginName); + } + } + } + catch (Exception ex) + { + LogHelper.WriteLogToFile($"保存所有插件配置时出错: {ex.Message}", LogHelper.LogType.Error); + } + } + } +} \ No newline at end of file diff --git a/Ink Canvas/Helpers/Plugins/PluginServiceManager.cs b/Ink Canvas/Helpers/Plugins/PluginServiceManager.cs new file mode 100644 index 00000000..1748fc1e --- /dev/null +++ b/Ink Canvas/Helpers/Plugins/PluginServiceManager.cs @@ -0,0 +1,458 @@ +using Ink_Canvas.Helpers; +using Ink_Canvas.Windows; +using System; +using System.Collections.Generic; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Ink; +using System.Windows.Media; +using System.Linq; + +namespace Ink_Canvas.Helpers.Plugins +{ + /// + /// 插件服务管理器,实现IPluginService接口,提供对软件内部功能的访问 + /// + public class PluginServiceManager : IPluginService + { + private static PluginServiceManager _instance; + private MainWindow _mainWindow; + private Dictionary _eventHandlers; + + /// + /// 单例实例 + /// + public static PluginServiceManager Instance + { + get + { + if (_instance == null) + { + _instance = new PluginServiceManager(); + } + return _instance; + } + } + + private PluginServiceManager() + { + _eventHandlers = new Dictionary(); + } + + /// + /// 设置主窗口引用 + /// + /// 主窗口实例 + public void SetMainWindow(MainWindow mainWindow) + { + _mainWindow = mainWindow; + } + + #region 窗口和UI访问 + + public Window MainWindow => _mainWindow; + + public InkCanvas CurrentCanvas => null; // 暂时返回null,避免访问权限问题 + + public List AllCanvasPages => new List(); // 暂时返回空列表 + + public int CurrentPageIndex => 0; // 暂时返回0 + + public int TotalPageCount => 0; // 暂时返回0 + + public FrameworkElement FloatingToolBar => _mainWindow?.ViewboxFloatingBar; + + public FrameworkElement LeftPanel => _mainWindow?.BlackboardLeftSide; + + public FrameworkElement RightPanel => _mainWindow?.BlackboardRightSide; + + public FrameworkElement TopPanel => _mainWindow?.BorderTools; + + public FrameworkElement BottomPanel => _mainWindow?.BorderSettings; + + #endregion + + #region 绘制工具状态 + + public int CurrentDrawingMode => 0; // 暂时返回0 + + public double CurrentInkWidth => 2.5; // 暂时返回默认值 + + public Color CurrentInkColor => Colors.Black; // 暂时返回默认值 + + public double CurrentHighlighterWidth => 20.0; // 暂时返回默认值 + + public int CurrentEraserSize => 2; // 暂时返回默认值 + + public int CurrentEraserType => 0; // 暂时返回默认值 + + public int CurrentEraserShape => 0; // 暂时返回默认值 + + public double CurrentInkAlpha => 255.0; // 暂时返回默认值 + + public int CurrentInkStyle => 0; // 暂时返回默认值 + + public string CurrentBackgroundColor => "#162924"; // 暂时返回默认值 + + #endregion + + #region 应用状态 + + public bool IsDarkTheme => false; // 暂时返回默认值 + + public bool IsWhiteboardMode => false; // 暂时返回默认值 + + public bool IsPPTMode => false; // 暂时返回默认值 + + public bool IsFullScreenMode => false; // 暂时返回默认值 + + public bool IsCanvasMode => true; // 暂时返回默认值 + + public bool IsSelectionMode => false; // 暂时返回默认值 + + public bool IsEraserMode => false; // 暂时返回默认值 + + public bool IsShapeDrawingMode => false; // 暂时返回默认值 + + public bool IsHighlighterMode => false; // 暂时返回默认值 + + #endregion + + #region 画布操作 + + public void ClearCanvas() + { + // 暂时不实现,避免访问权限问题 + } + + public void ClearAllCanvases() + { + // 暂时不实现,避免访问权限问题 + } + + public void AddNewPage() + { + // 暂时不实现,避免访问权限问题 + } + + public void DeleteCurrentPage() + { + // 暂时不实现,避免访问权限问题 + } + + public void SwitchToPage(int pageIndex) + { + // 暂时不实现,避免访问权限问题 + } + + public void NextPage() + { + // 暂时不实现,避免访问权限问题 + } + + public void PreviousPage() + { + // 暂时不实现,避免访问权限问题 + } + + #endregion + + #region 绘制操作 + + public void SetDrawingMode(int mode) + { + // 暂时不实现,避免访问权限问题 + } + + public void SetInkWidth(double width) + { + // 暂时不实现,避免访问权限问题 + } + + public void SetInkColor(Color color) + { + // 暂时不实现,避免访问权限问题 + } + + public void SetHighlighterWidth(double width) + { + // 暂时不实现,避免访问权限问题 + } + + public void SetEraserSize(int size) + { + // 暂时不实现,避免访问权限问题 + } + + public void SetEraserType(int type) + { + // 暂时不实现,避免访问权限问题 + } + + public void SetEraserShape(int shape) + { + // 暂时不实现,避免访问权限问题 + } + + public void SetInkAlpha(double alpha) + { + // 暂时不实现,避免访问权限问题 + } + + public void SetInkStyle(int style) + { + // 暂时不实现,避免访问权限问题 + } + + public void SetBackgroundColor(string color) + { + // 暂时不实现,避免访问权限问题 + } + + #endregion + + #region 文件操作 + + public void SaveCanvas(string filePath) + { + // 暂时不实现,避免访问权限问题 + } + + public void LoadCanvas(string filePath) + { + // 暂时不实现,避免访问权限问题 + } + + public void ExportAsImage(string filePath, string format) + { + // 暂时不实现,避免访问权限问题 + } + + public void ExportAsPDF(string filePath) + { + // 暂时不实现,避免访问权限问题 + } + + #endregion + + #region 撤销重做 + + public void Undo() + { + // 暂时不实现,避免访问权限问题 + } + + public void Redo() + { + // 暂时不实现,避免访问权限问题 + } + + public bool CanUndo => false; // 暂时返回默认值 + + public bool CanRedo => false; // 暂时返回默认值 + + #endregion + + #region 选择操作 + + public void SelectAll() + { + // 暂时不实现,避免访问权限问题 + } + + public void DeselectAll() + { + // 暂时不实现,避免访问权限问题 + } + + public void DeleteSelected() + { + // 暂时不实现,避免访问权限问题 + } + + public void CopySelected() + { + // 暂时不实现,避免访问权限问题 + } + + public void CutSelected() + { + // 暂时不实现,避免访问权限问题 + } + + public void Paste() + { + // 暂时不实现,避免访问权限问题 + } + + #endregion + + #region 窗口管理 + + public void ShowSettingsWindow() + { + // 暂时不实现,避免访问权限问题 + } + + public void HideSettingsWindow() + { + // 暂时不实现,避免访问权限问题 + } + + public void ShowPluginSettingsWindow() + { + // 暂时不实现,避免访问权限问题 + } + + public void HidePluginSettingsWindow() + { + // 暂时不实现,避免访问权限问题 + } + + public void ShowHelpWindow() + { + // 暂时不实现,避免访问权限问题 + } + + public void HideHelpWindow() + { + // 暂时不实现,避免访问权限问题 + } + + public void ShowAboutWindow() + { + // 暂时不实现,避免访问权限问题 + } + + public void HideAboutWindow() + { + // 暂时不实现,避免访问权限问题 + } + + #endregion + + #region 通知和消息 + + public void ShowNotification(string message, NotificationType type = NotificationType.Info) + { + // 暂时不实现,避免访问权限问题 + } + + public bool ShowConfirmDialog(string message, string title = "确认") + { + // 暂时不实现,避免访问权限问题 + return false; + } + + public string ShowInputDialog(string message, string title = "输入", string defaultValue = "") + { + // 暂时不实现,避免访问权限问题 + return defaultValue; + } + + #endregion + + #region 系统功能 + + public T GetSetting(string key, T defaultValue = default(T)) + { + // 暂时不实现,避免访问权限问题 + return defaultValue; + } + + public void SetSetting(string key, T value) + { + // 暂时不实现,避免访问权限问题 + } + + public void SaveSettings() + { + // 暂时不实现,避免访问权限问题 + } + + public void LoadSettings() + { + // 暂时不实现,避免访问权限问题 + } + + public void ResetSettings() + { + // 暂时不实现,避免访问权限问题 + } + + #endregion + + #region 插件管理 + + public List GetAllPlugins() + { + return new List(PluginManager.Instance.Plugins); + } + + public IPlugin GetPlugin(string pluginName) + { + return PluginManager.Instance.Plugins.FirstOrDefault(p => p.Name == pluginName); + } + + public void EnablePlugin(string pluginName) + { + var plugin = GetPlugin(pluginName); + if (plugin != null) + { + PluginManager.Instance.TogglePlugin(plugin, true); + } + } + + public void DisablePlugin(string pluginName) + { + var plugin = GetPlugin(pluginName); + if (plugin != null) + { + PluginManager.Instance.TogglePlugin(plugin, false); + } + } + + public void UnloadPlugin(string pluginName) + { + var plugin = GetPlugin(pluginName); + if (plugin != null) + { + PluginManager.Instance.UnloadPlugin(plugin); + } + } + + #endregion + + #region 事件系统 + + public void RegisterEventHandler(string eventName, EventHandler handler) + { + if (!_eventHandlers.ContainsKey(eventName)) + { + _eventHandlers[eventName] = handler; + } + else + { + _eventHandlers[eventName] += handler; + } + } + + public void UnregisterEventHandler(string eventName, EventHandler handler) + { + if (_eventHandlers.ContainsKey(eventName)) + { + _eventHandlers[eventName] -= handler; + } + } + + public void TriggerEvent(string eventName, object sender, EventArgs args) + { + if (_eventHandlers.ContainsKey(eventName)) + { + _eventHandlers[eventName]?.Invoke(sender, args); + } + } + + #endregion + } +} \ No newline at end of file diff --git a/Ink Canvas/MainWindow.xaml b/Ink Canvas/MainWindow.xaml index da24ff88..dc54dd47 100644 --- a/Ink Canvas/MainWindow.xaml +++ b/Ink Canvas/MainWindow.xaml @@ -1121,7 +1121,7 @@ diff --git a/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs b/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs index 04a969da..bc6ce32c 100644 --- a/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs +++ b/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs @@ -13,6 +13,7 @@ using System.Windows.Interop; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Media.Imaging; +using System.Windows.Threading; using Application = System.Windows.Application; using Button = System.Windows.Controls.Button; using HorizontalAlignment = System.Windows.HorizontalAlignment; @@ -1899,9 +1900,10 @@ namespace Ink_Canvas HideSubPanels("pen", true); } } - - // 工具切换完成后,统一刷新快捷键状态 - RefreshHotkeyState(); + + + // 延迟半秒后再刷新快捷键状态 + Task.Delay(500).ContinueWith(_ => Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => RefreshHotkeyState()))); // 修复:从线擦切换到批注时,保持之前的笔类型状态 forceEraser = false; diff --git a/Ink Canvas/MainWindow_cs/MW_Settings.cs b/Ink Canvas/MainWindow_cs/MW_Settings.cs index 03054a45..017cc6fd 100644 --- a/Ink Canvas/MainWindow_cs/MW_Settings.cs +++ b/Ink Canvas/MainWindow_cs/MW_Settings.cs @@ -2028,7 +2028,7 @@ namespace Ink_Canvas LoadSettings(); isLoaded = true; - ToggleSwitchRunAtStartup.IsOn = true; + ToggleSwitchRunAtStartup.IsOn = false; } catch { } diff --git a/Ink Canvas/MainWindow_cs/MW_SettingsToLoad.cs b/Ink Canvas/MainWindow_cs/MW_SettingsToLoad.cs index 2d4459ca..439fd7e5 100644 --- a/Ink Canvas/MainWindow_cs/MW_SettingsToLoad.cs +++ b/Ink Canvas/MainWindow_cs/MW_SettingsToLoad.cs @@ -54,10 +54,15 @@ namespace Ink_Canvas { ToggleSwitchRunAtStartup.IsOn = true; } + else + { + ToggleSwitchRunAtStartup.IsOn = false; + } } catch (Exception ex) { LogHelper.WriteLogToFile(ex.ToString(), LogHelper.LogType.Error); + ToggleSwitchRunAtStartup.IsOn = false; } if (Settings.Startup != null) @@ -141,6 +146,10 @@ namespace Ink_Canvas else { Settings.Startup = new Startup(); + Settings.Startup.IsEnableNibMode = false; // 默认关闭笔尖模式 + ToggleSwitchEnableNibMode.IsOn = false; // 默认关闭笔尖模式 + BoardToggleSwitchEnableNibMode.IsOn = false; // 默认关闭笔尖模式 + BoundsWidth = Settings.Advanced.FingerModeBoundsWidth; // 使用手指模式边界宽度 } // 恢复崩溃后操作设置 diff --git a/Ink Canvas/MainWindow_cs/MW_TouchEvents.cs b/Ink Canvas/MainWindow_cs/MW_TouchEvents.cs index 0c3bbf74..92129d26 100644 --- a/Ink Canvas/MainWindow_cs/MW_TouchEvents.cs +++ b/Ink Canvas/MainWindow_cs/MW_TouchEvents.cs @@ -539,6 +539,9 @@ namespace Ink_Canvas // 确保触摸事件能正常响应 inkCanvas.IsHitTestVisible = true; inkCanvas.IsManipulationEnabled = true; + + ViewboxFloatingBar.IsHitTestVisible = true; + BlackboardUIGridForInkReplay.IsHitTestVisible = true; } // 新增:超时检测 - 如果手掌擦激活时间过长,强制重置状态 @@ -580,6 +583,9 @@ namespace Ink_Canvas inkCanvas.IsHitTestVisible = true; inkCanvas.IsManipulationEnabled = true; + ViewboxFloatingBar.IsHitTestVisible = true; + BlackboardUIGridForInkReplay.IsHitTestVisible = true; + // 停止恢复定时器 StopPalmEraserRecoveryTimer(); } @@ -652,6 +658,9 @@ namespace Ink_Canvas palmEraserTouchDownHandled = false; inkCanvas.IsHitTestVisible = true; inkCanvas.IsManipulationEnabled = true; + + ViewboxFloatingBar.IsHitTestVisible = true; + BlackboardUIGridForInkReplay.IsHitTestVisible = true; } } } @@ -926,6 +935,9 @@ namespace Ink_Canvas inkCanvas.IsHitTestVisible = true; inkCanvas.IsManipulationEnabled = true; + ViewboxFloatingBar.IsHitTestVisible = true; + BlackboardUIGridForInkReplay.IsHitTestVisible = true; + // 停止定时器 StopPalmEraserRecoveryTimer(); } diff --git a/Ink Canvas/Properties/AssemblyInfo.cs b/Ink Canvas/Properties/AssemblyInfo.cs index f92a4964..fa4d485a 100644 --- a/Ink Canvas/Properties/AssemblyInfo.cs +++ b/Ink Canvas/Properties/AssemblyInfo.cs @@ -49,5 +49,5 @@ using System.Windows; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.7.7.7")] -[assembly: AssemblyFileVersion("1.7.7.7")] +[assembly: AssemblyVersion("1.7.8.0")] +[assembly: AssemblyFileVersion("1.7.8.0")] diff --git a/Ink Canvas/Resources/Settings.cs b/Ink Canvas/Resources/Settings.cs index b617f46d..9b8ed589 100644 --- a/Ink Canvas/Resources/Settings.cs +++ b/Ink Canvas/Resources/Settings.cs @@ -150,7 +150,7 @@ namespace Ink_Canvas [JsonProperty("skippedVersion")] public string SkippedVersion { get; set; } = ""; [JsonProperty("isEnableNibMode")] - public bool IsEnableNibMode { get; set; } + public bool IsEnableNibMode { get; set; } = false; [JsonProperty("isFoldAtStartup")] public bool IsFoldAtStartup { get; set; } [JsonProperty("crashAction")] diff --git a/Ink Canvas/Windows/RandWindow.xaml.cs b/Ink Canvas/Windows/RandWindow.xaml.cs index 4b4c5f5e..aa391d8f 100644 --- a/Ink Canvas/Windows/RandWindow.xaml.cs +++ b/Ink Canvas/Windows/RandWindow.xaml.cs @@ -316,7 +316,7 @@ namespace Ink_Canvas protocol = "classisland://plugins/IslandCaller/Simple/1"; break; case 1: // SecRandom点名 - protocol = "secrandom://pumping?action=start"; + protocol = "secrandom://direct_extraction"; break; case 2: // NamePicker点名 protocol = "namepicker://"; diff --git a/UpdateLog.md b/UpdateLog.md index d0fcdb99..ca35fe1a 100644 --- a/UpdateLog.md +++ b/UpdateLog.md @@ -32,7 +32,22 @@ 32. 修复快速面板中的退出放映按钮 33. 优化多墨迹卡顿问题 34. 优化至单文件版本 -35. 优化图片插入功能 +35. 修复了插入图片功能 36. 新增浮动栏按钮自定义显示 37. 新增快捷调色板 - +38. 新增鼠标高亮显示 +39. 新增几何绘制圆形绘制圆心 +40. 优化快捷调色板 +41. 优化浮动栏子面板显示 +42. 优化高光显示 +43. 新增窗口置顶 +44. 优化面板收纳 +45. 新增墨迹渐隐 +46. 修复PPT相关问题 +47. 新增更多点名联动 +48. 新增PPT底部按钮修改位置 +49. 修复翻页笔失焦不可用 +50. 优化墨迹渐隐 +51. 优化调色板 +52. 修复浮动栏动画异常 +53. 修复开关状态异常