using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Windows; using System.Windows.Controls; using System.Windows.Media; using System.Windows.Ink; using Ink_Canvas.Windows; using InkCanvasForClass.PluginSdk; using LegacyNotificationType = Ink_Canvas.Helpers.Plugins.NotificationType; namespace Ink_Canvas.Helpers.Plugins { /// /// 统一宿主上下文:同时实现 SDK 的 与旧版 。 /// public class PluginSdkHostContext : IPluginContext, IPluginService { private MainWindow _mainWindow; private Dictionary _eventHandlers = new Dictionary(); /// /// 设置主窗口引用 /// /// 主窗口实例 public void SetMainWindow(MainWindow mainWindow) { _mainWindow = mainWindow; } #region 窗口和UI访问 public Window MainWindow => _mainWindow; public System.Windows.Controls.InkCanvas CurrentCanvas => _mainWindow?.inkCanvas; public IList AllCanvasPages => _mainWindow?.WhiteboardPages ?? new List(); public int CurrentPageIndex => _mainWindow?.CurrentPageIndex ?? 0; public int TotalPageCount => _mainWindow?.WhiteboardPages?.Count ?? 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 => GetCurrentDrawingMode(); public double CurrentInkWidth => GetCurrentInkWidth(); public Color CurrentInkColor => GetCurrentInkColor(); public double CurrentHighlighterWidth => GetCurrentHighlighterWidth(); public int CurrentEraserSize => GetCurrentEraserSize(); public int CurrentEraserType => GetCurrentEraserType(); public int CurrentEraserShape => GetCurrentEraserShape(); public double CurrentInkAlpha => GetCurrentInkAlpha(); public int CurrentInkStyle => GetCurrentInkStyle(); public string CurrentBackgroundColor => GetCurrentBackgroundColor(); #endregion #region 应用状态 public bool IsDarkTheme => GetIsDarkTheme(); public bool IsWhiteboardMode => GetIsWhiteboardMode(); public bool IsPPTMode => GetIsPPTMode(); public bool IsFullScreenMode => GetIsFullScreenMode(); public bool IsCanvasMode => GetIsCanvasMode(); public bool IsSelectionMode => GetIsSelectionMode(); public bool IsEraserMode => GetIsEraserMode(); public bool IsShapeDrawingMode => GetIsShapeDrawingMode(); public bool IsHighlighterMode => GetIsHighlighterMode(); #endregion #region 操作状态 public bool CanUndo => GetCanUndo(); public bool CanRedo => GetCanRedo(); #endregion #region 设置管理 public T GetSetting(string key, T defaultValue = default(T)) { try { // 这里需要根据实际的设置系统来实现 // 暂时返回默认值 return defaultValue; } catch { return defaultValue; } } public void SetSetting(string key, T value) { try { // 这里需要根据实际的设置系统来实现 LogHelper.WriteLogToFile($"设置 {key} = {value}"); } catch (Exception ex) { LogHelper.WriteLogToFile($"设置 {key} 时出错: {ex.Message}", LogHelper.LogType.Error); } } public void SaveSettings() { try { // 这里需要根据实际的设置系统来实现 LogHelper.WriteLogToFile("设置已保存"); } catch (Exception ex) { LogHelper.WriteLogToFile($"保存设置时出错: {ex.Message}", LogHelper.LogType.Error); } } public void LoadSettings() { try { // 这里需要根据实际的设置系统来实现 LogHelper.WriteLogToFile("设置已加载"); } catch (Exception ex) { LogHelper.WriteLogToFile($"加载设置时出错: {ex.Message}", LogHelper.LogType.Error); } } public void ResetSettings() { try { // 这里需要根据实际的设置系统来实现 LogHelper.WriteLogToFile("设置已重置"); } catch (Exception ex) { LogHelper.WriteLogToFile($"重置设置时出错: {ex.Message}", LogHelper.LogType.Error); } } #endregion #region 插件管理 public IList GetAllPlugins() { return PluginManager.Instance.GetAllSdkPluginInstances().ToList(); } public IInkCanvasPlugin GetPlugin(string pluginName) { return PluginManager.Instance.GetSdkPluginByName(pluginName); } public void EnablePlugin(string pluginName) { if (PluginManager.Instance.GetSdkPluginByName(pluginName) != null) { PluginManager.Instance.SetSdkPluginEnabledByName(pluginName, true); return; } var plugin = PluginManager.Instance.Plugins.FirstOrDefault(p => p.Name == pluginName); if (plugin != null) { PluginManager.Instance.TogglePlugin(plugin, true); } } public void DisablePlugin(string pluginName) { if (PluginManager.Instance.GetSdkPluginByName(pluginName) != null) { PluginManager.Instance.SetSdkPluginEnabledByName(pluginName, false); return; } var plugin = PluginManager.Instance.Plugins.FirstOrDefault(p => p.Name == pluginName); if (plugin != null) { PluginManager.Instance.TogglePlugin(plugin, false); } } public void UnloadPlugin(string pluginName) { if (PluginManager.Instance.GetSdkPluginByName(pluginName) != null) { PluginManager.Instance.UnloadSdkPluginByName(pluginName); return; } var plugin = PluginManager.Instance.Plugins.FirstOrDefault(p => p.Name == pluginName); if (plugin != null) { PluginManager.Instance.UnloadPlugin(plugin, true); } } #endregion #region 窗口操作 public void ShowSettingsWindow() { try { if (_mainWindow == null) { return; } _mainWindow.Dispatcher.BeginInvoke(new Action(() => _mainWindow.BtnSettings_Click(null, null))); } catch (Exception ex) { LogHelper.WriteLogToFile($"显示设置窗口时出错: {ex.Message}", LogHelper.LogType.Error); } } public void HideSettingsWindow() { try { if (_mainWindow == null) { return; } _mainWindow.Dispatcher.BeginInvoke(new Action(() => _mainWindow.HideSubPanels())); } catch (Exception ex) { LogHelper.WriteLogToFile($"隐藏设置窗口时出错: {ex.Message}", LogHelper.LogType.Error); } } public void ShowPluginSettingsWindow() { try { if (_mainWindow == null) { return; } _mainWindow.Dispatcher.BeginInvoke(new Action(() => { var w = new PluginSettingsWindow { Owner = _mainWindow }; w.Show(); })); } catch (Exception ex) { LogHelper.WriteLogToFile($"显示插件设置窗口时出错: {ex.Message}", LogHelper.LogType.Error); } } public void HidePluginSettingsWindow() { try { var app = Application.Current; if (app?.Dispatcher == null) { return; } app.Dispatcher.BeginInvoke(new Action(() => { foreach (Window w in app.Windows) { if (w is PluginSettingsWindow psw) { psw.Close(); } } })); } catch (Exception ex) { LogHelper.WriteLogToFile($"隐藏插件设置窗口时出错: {ex.Message}", LogHelper.LogType.Error); } } public void ShowHelpWindow() { try { // 这里需要调用帮助窗口显示方法 LogHelper.WriteLogToFile("显示帮助窗口"); } catch (Exception ex) { LogHelper.WriteLogToFile($"显示帮助窗口时出错: {ex.Message}", LogHelper.LogType.Error); } } public void HideHelpWindow() { try { // 这里需要调用帮助窗口隐藏方法 LogHelper.WriteLogToFile("隐藏帮助窗口"); } catch (Exception ex) { LogHelper.WriteLogToFile($"隐藏帮助窗口时出错: {ex.Message}", LogHelper.LogType.Error); } } public void ShowAboutWindow() { try { // 这里需要调用关于窗口显示方法 LogHelper.WriteLogToFile("显示关于窗口"); } catch (Exception ex) { LogHelper.WriteLogToFile($"显示关于窗口时出错: {ex.Message}", LogHelper.LogType.Error); } } public void HideAboutWindow() { try { // 这里需要调用关于窗口隐藏方法 LogHelper.WriteLogToFile("隐藏关于窗口"); } catch (Exception ex) { LogHelper.WriteLogToFile($"隐藏关于窗口时出错: {ex.Message}", LogHelper.LogType.Error); } } public void ShowNotification(string message, InkCanvasForClass.PluginSdk.NotificationType type = InkCanvasForClass.PluginSdk.NotificationType.Info) { try { LogHelper.WriteLogToFile($"通知: {message} ({type})"); var title = type.ToString(); _mainWindow?.PluginHost_ShowInfo(title, message); } catch (Exception ex) { LogHelper.WriteLogToFile($"显示通知时出错: {ex.Message}", LogHelper.LogType.Error); } } public bool ShowConfirmDialog(string message, string title = "确认") { try { return _mainWindow != null && _mainWindow.PluginHost_ShowConfirm(title, message); } catch (Exception ex) { LogHelper.WriteLogToFile($"显示确认对话框时出错: {ex.Message}", LogHelper.LogType.Error); return false; } } public string ShowInputDialog(string message, string title = "输入", string defaultValue = "") { try { return _mainWindow != null ? _mainWindow.PluginHost_ShowInput(title, message, defaultValue) : defaultValue; } catch (Exception ex) { LogHelper.WriteLogToFile($"显示输入对话框时出错: {ex.Message}", LogHelper.LogType.Error); return defaultValue; } } public void SetFullScreen(bool isFullScreen) { try { if (_mainWindow == null) { return; } _mainWindow.Dispatcher.Invoke(() => { _mainWindow.WindowState = isFullScreen ? WindowState.Maximized : WindowState.Normal; }); } catch (Exception ex) { LogHelper.WriteLogToFile($"设置全屏时出错: {ex.Message}", LogHelper.LogType.Error); } } public void SetTopMost(bool isTopMost) { try { if (_mainWindow == null) { return; } _mainWindow.Dispatcher.Invoke(() => _mainWindow.Topmost = isTopMost); } catch (Exception ex) { LogHelper.WriteLogToFile($"设置置顶时出错: {ex.Message}", LogHelper.LogType.Error); } } public void SetWindowVisibility(bool isVisible) { try { if (_mainWindow == null) { return; } _mainWindow.Dispatcher.Invoke(() => _mainWindow.Visibility = isVisible ? Visibility.Visible : Visibility.Hidden); } catch (Exception ex) { LogHelper.WriteLogToFile($"设置窗口可见性时出错: {ex.Message}", LogHelper.LogType.Error); } } public void MinimizeWindow() { try { if (_mainWindow != null) { _mainWindow.WindowState = WindowState.Minimized; } } catch (Exception ex) { LogHelper.WriteLogToFile($"最小化窗口时出错: {ex.Message}", LogHelper.LogType.Error); } } public void MaximizeWindow() { try { if (_mainWindow != null) { _mainWindow.WindowState = WindowState.Maximized; } } catch (Exception ex) { LogHelper.WriteLogToFile($"最大化窗口时出错: {ex.Message}", LogHelper.LogType.Error); } } public void RestoreWindow() { try { if (_mainWindow != null) { _mainWindow.WindowState = WindowState.Normal; } } catch (Exception ex) { LogHelper.WriteLogToFile($"还原窗口时出错: {ex.Message}", LogHelper.LogType.Error); } } public void CloseWindow() { try { _mainWindow?.Close(); } catch (Exception ex) { LogHelper.WriteLogToFile($"关闭窗口时出错: {ex.Message}", LogHelper.LogType.Error); } } public void SetWindowPosition(double x, double y) { try { if (_mainWindow != null) { _mainWindow.Left = x; _mainWindow.Top = y; } } catch (Exception ex) { LogHelper.WriteLogToFile($"设置窗口位置时出错: {ex.Message}", LogHelper.LogType.Error); } } public void SetWindowSize(double width, double height) { try { if (_mainWindow != null) { _mainWindow.Width = width; _mainWindow.Height = height; } } catch (Exception ex) { LogHelper.WriteLogToFile($"设置窗口大小时出错: {ex.Message}", LogHelper.LogType.Error); } } public (double x, double y) GetWindowPosition() { try { if (_mainWindow != null) { return (_mainWindow.Left, _mainWindow.Top); } } catch (Exception ex) { LogHelper.WriteLogToFile($"获取窗口位置时出错: {ex.Message}", LogHelper.LogType.Error); } return (0, 0); } public (double width, double height) GetWindowSize() { try { if (_mainWindow != null) { return (_mainWindow.Width, _mainWindow.Height); } } catch (Exception ex) { LogHelper.WriteLogToFile($"获取窗口大小时出错: {ex.Message}", LogHelper.LogType.Error); } return (800, 600); } #endregion #region 画布操作 public void ClearCanvas() { try { _mainWindow?.PluginHost_ClearInk(false); } catch (Exception ex) { LogHelper.WriteLogToFile($"清除画布时出错: {ex.Message}", LogHelper.LogType.Error); } } public void ClearAllCanvases() { try { // 这里需要调用清除所有画布的方法 LogHelper.WriteLogToFile("清除所有画布"); } catch (Exception ex) { LogHelper.WriteLogToFile($"清除所有画布时出错: {ex.Message}", LogHelper.LogType.Error); } } public void AddNewPage() { try { // 这里需要调用添加新页面的方法 LogHelper.WriteLogToFile("添加新页面"); } catch (Exception ex) { LogHelper.WriteLogToFile($"添加新页面时出错: {ex.Message}", LogHelper.LogType.Error); } } public void DeleteCurrentPage() { try { // 这里需要调用删除当前页面的方法 LogHelper.WriteLogToFile("删除当前页面"); } catch (Exception ex) { LogHelper.WriteLogToFile($"删除当前页面时出错: {ex.Message}", LogHelper.LogType.Error); } } public void SwitchToPage(int pageIndex) { try { // 这里需要调用切换页面的方法 LogHelper.WriteLogToFile($"切换到页面: {pageIndex}"); } catch (Exception ex) { LogHelper.WriteLogToFile($"切换页面时出错: {ex.Message}", LogHelper.LogType.Error); } } public void NextPage() { try { // 这里需要调用下一页的方法 LogHelper.WriteLogToFile("下一页"); } catch (Exception ex) { LogHelper.WriteLogToFile($"下一页时出错: {ex.Message}", LogHelper.LogType.Error); } } public void PreviousPage() { try { // 这里需要调用上一页的方法 LogHelper.WriteLogToFile("上一页"); } catch (Exception ex) { LogHelper.WriteLogToFile($"上一页时出错: {ex.Message}", LogHelper.LogType.Error); } } #endregion #region 绘制设置 public void SetDrawingMode(int mode) { try { // 这里需要调用设置绘制模式的方法 LogHelper.WriteLogToFile($"设置绘制模式: {mode}"); } catch (Exception ex) { LogHelper.WriteLogToFile($"设置绘制模式时出错: {ex.Message}", LogHelper.LogType.Error); } } public void SetInkWidth(double width) { try { // 这里需要调用设置墨迹宽度的方法 LogHelper.WriteLogToFile($"设置墨迹宽度: {width}"); } catch (Exception ex) { LogHelper.WriteLogToFile($"设置墨迹宽度时出错: {ex.Message}", LogHelper.LogType.Error); } } public void SetInkColor(Color color) { try { // 这里需要调用设置墨迹颜色的方法 LogHelper.WriteLogToFile($"设置墨迹颜色: {color}"); } catch (Exception ex) { LogHelper.WriteLogToFile($"设置墨迹颜色时出错: {ex.Message}", LogHelper.LogType.Error); } } public void SetHighlighterWidth(double width) { try { // 这里需要调用设置高亮笔宽度的方法 LogHelper.WriteLogToFile($"设置高亮笔宽度: {width}"); } catch (Exception ex) { LogHelper.WriteLogToFile($"设置高亮笔宽度时出错: {ex.Message}", LogHelper.LogType.Error); } } public void SetEraserSize(int size) { try { // 这里需要调用设置橡皮擦大小的方法 LogHelper.WriteLogToFile($"设置橡皮擦大小: {size}"); } catch (Exception ex) { LogHelper.WriteLogToFile($"设置橡皮擦大小时出错: {ex.Message}", LogHelper.LogType.Error); } } public void SetEraserType(int type) { try { // 这里需要调用设置橡皮擦类型的方法 LogHelper.WriteLogToFile($"设置橡皮擦类型: {type}"); } catch (Exception ex) { LogHelper.WriteLogToFile($"设置橡皮擦类型时出错: {ex.Message}", LogHelper.LogType.Error); } } public void SetEraserShape(int shape) { try { // 这里需要调用设置橡皮擦形状的方法 LogHelper.WriteLogToFile($"设置橡皮擦形状: {shape}"); } catch (Exception ex) { LogHelper.WriteLogToFile($"设置橡皮擦形状时出错: {ex.Message}", LogHelper.LogType.Error); } } public void SetInkAlpha(double alpha) { try { // 这里需要调用设置墨迹透明度的方法 LogHelper.WriteLogToFile($"设置墨迹透明度: {alpha}"); } catch (Exception ex) { LogHelper.WriteLogToFile($"设置墨迹透明度时出错: {ex.Message}", LogHelper.LogType.Error); } } public void SetInkStyle(int style) { try { // 这里需要调用设置墨迹样式的方法 LogHelper.WriteLogToFile($"设置墨迹样式: {style}"); } catch (Exception ex) { LogHelper.WriteLogToFile($"设置墨迹样式时出错: {ex.Message}", LogHelper.LogType.Error); } } public void SetBackgroundColor(string color) { try { // 这里需要调用设置背景颜色的方法 LogHelper.WriteLogToFile($"设置背景颜色: {color}"); } catch (Exception ex) { LogHelper.WriteLogToFile($"设置背景颜色时出错: {ex.Message}", LogHelper.LogType.Error); } } #endregion #region 文件操作 public void SaveCanvas(string filePath) { try { // 这里需要调用保存画布的方法 LogHelper.WriteLogToFile($"保存画布到: {filePath}"); } catch (Exception ex) { LogHelper.WriteLogToFile($"保存画布时出错: {ex.Message}", LogHelper.LogType.Error); } } public void LoadCanvas(string filePath) { try { // 这里需要调用加载画布的方法 LogHelper.WriteLogToFile($"加载画布从: {filePath}"); } catch (Exception ex) { LogHelper.WriteLogToFile($"加载画布时出错: {ex.Message}", LogHelper.LogType.Error); } } public void ExportAsImage(string filePath, string format) { try { // 这里需要调用导出为图片的方法 LogHelper.WriteLogToFile($"导出为图片: {filePath} ({format})"); } catch (Exception ex) { LogHelper.WriteLogToFile($"导出为图片时出错: {ex.Message}", LogHelper.LogType.Error); } } public void ExportAsPDF(string filePath) { try { // 这里需要调用导出为PDF的方法 LogHelper.WriteLogToFile($"导出为PDF: {filePath}"); } catch (Exception ex) { LogHelper.WriteLogToFile($"导出为PDF时出错: {ex.Message}", LogHelper.LogType.Error); } } #endregion #region 编辑操作 public void Undo() { try { _mainWindow?.PluginHost_Undo(); } catch (Exception ex) { LogHelper.WriteLogToFile($"撤销操作时出错: {ex.Message}", LogHelper.LogType.Error); } } public void Redo() { try { _mainWindow?.PluginHost_Redo(); } catch (Exception ex) { LogHelper.WriteLogToFile($"重做操作时出错: {ex.Message}", LogHelper.LogType.Error); } } public void SelectAll() { try { // 这里需要调用全选的方法 LogHelper.WriteLogToFile("全选"); } catch (Exception ex) { LogHelper.WriteLogToFile($"全选时出错: {ex.Message}", LogHelper.LogType.Error); } } public void DeselectAll() { try { // 这里需要调用取消选择的方法 LogHelper.WriteLogToFile("取消选择"); } catch (Exception ex) { LogHelper.WriteLogToFile($"取消选择时出错: {ex.Message}", LogHelper.LogType.Error); } } public void DeleteSelected() { try { // 这里需要调用删除选中项的方法 LogHelper.WriteLogToFile("删除选中项"); } catch (Exception ex) { LogHelper.WriteLogToFile($"删除选中项时出错: {ex.Message}", LogHelper.LogType.Error); } } public void CopySelected() { try { // 这里需要调用复制选中项的方法 LogHelper.WriteLogToFile("复制选中项"); } catch (Exception ex) { LogHelper.WriteLogToFile($"复制选中项时出错: {ex.Message}", LogHelper.LogType.Error); } } public void CutSelected() { try { // 这里需要调用剪切选中项的方法 LogHelper.WriteLogToFile("剪切选中项"); } catch (Exception ex) { LogHelper.WriteLogToFile($"剪切选中项时出错: {ex.Message}", LogHelper.LogType.Error); } } public void Paste() { try { // 这里需要调用粘贴的方法 LogHelper.WriteLogToFile("粘贴"); } catch (Exception ex) { LogHelper.WriteLogToFile($"粘贴时出错: {ex.Message}", LogHelper.LogType.Error); } } #endregion #region 事件系统 public void RegisterEventHandler(string eventName, EventHandler handler) { try { if (!_eventHandlers.ContainsKey(eventName)) { _eventHandlers[eventName] = handler; } else { _eventHandlers[eventName] += handler; } } catch (Exception ex) { LogHelper.WriteLogToFile($"注册事件处理器时出错: {ex.Message}", LogHelper.LogType.Error); } } public void UnregisterEventHandler(string eventName, EventHandler handler) { try { if (_eventHandlers.ContainsKey(eventName)) { _eventHandlers[eventName] -= handler; } } catch (Exception ex) { LogHelper.WriteLogToFile($"注销事件处理器时出错: {ex.Message}", LogHelper.LogType.Error); } } public void TriggerEvent(string eventName, object sender, EventArgs args) { try { if (_eventHandlers.ContainsKey(eventName)) { _eventHandlers[eventName]?.Invoke(sender, args); } } catch (Exception ex) { LogHelper.WriteLogToFile($"触发事件时出错: {ex.Message}", LogHelper.LogType.Error); } } #endregion #region 应用程序操作 public void RestartApplication() { try { var path = Process.GetCurrentProcess().MainModule?.FileName; if (!string.IsNullOrEmpty(path)) { Process.Start(new ProcessStartInfo { FileName = path, UseShellExecute = true }); } Application.Current?.Shutdown(0); } catch (Exception ex) { LogHelper.WriteLogToFile($"重启应用程序时出错: {ex.Message}", LogHelper.LogType.Error); } } public void ExitApplication() { try { Application.Current?.Shutdown(0); } catch (Exception ex) { LogHelper.WriteLogToFile($"退出应用程序时出错: {ex.Message}", LogHelper.LogType.Error); } } public void CheckForUpdates() { try { // 这里需要调用检查更新的方法 LogHelper.WriteLogToFile("检查更新"); } catch (Exception ex) { LogHelper.WriteLogToFile($"检查更新时出错: {ex.Message}", LogHelper.LogType.Error); } } public void OpenHelpDocument() { try { // 这里需要调用打开帮助文档的方法 LogHelper.WriteLogToFile("打开帮助文档"); } catch (Exception ex) { LogHelper.WriteLogToFile($"打开帮助文档时出错: {ex.Message}", LogHelper.LogType.Error); } } public void OpenAboutPage() { try { // 这里需要调用打开关于页面的方法 LogHelper.WriteLogToFile("打开关于页面"); } catch (Exception ex) { LogHelper.WriteLogToFile($"打开关于页面时出错: {ex.Message}", LogHelper.LogType.Error); } } #endregion #region 私有方法 - 获取当前状态 private int GetCurrentDrawingMode() { // 这里需要根据实际的绘制模式状态来实现 return 0; } private double GetCurrentInkWidth() { // 这里需要根据实际的墨迹宽度状态来实现 return 2.5; } private Color GetCurrentInkColor() { // 这里需要根据实际的墨迹颜色状态来实现 return Colors.Black; } private double GetCurrentHighlighterWidth() { // 这里需要根据实际的高亮笔宽度状态来实现 return 20.0; } private int GetCurrentEraserSize() { // 这里需要根据实际的橡皮擦大小状态来实现 return 2; } private int GetCurrentEraserType() { // 这里需要根据实际的橡皮擦类型状态来实现 return 0; } private int GetCurrentEraserShape() { // 这里需要根据实际的橡皮擦形状状态来实现 return 0; } private double GetCurrentInkAlpha() { // 这里需要根据实际的墨迹透明度状态来实现 return 255.0; } private int GetCurrentInkStyle() { // 这里需要根据实际的墨迹样式状态来实现 return 0; } private string GetCurrentBackgroundColor() { // 这里需要根据实际的背景颜色状态来实现 return "#162924"; } private bool GetIsDarkTheme() { // 这里需要根据实际的主题状态来实现 return false; } private bool GetIsWhiteboardMode() { // 这里需要根据实际的白板模式状态来实现 return false; } private bool GetIsPPTMode() { // 这里需要根据实际的PPT模式状态来实现 return false; } private bool GetIsFullScreenMode() { // 这里需要根据实际的全屏模式状态来实现 return false; } private bool GetIsCanvasMode() { // 这里需要根据实际的画布模式状态来实现 return true; } private bool GetIsSelectionMode() { // 这里需要根据实际的选择模式状态来实现 return false; } private bool GetIsEraserMode() { // 这里需要根据实际的橡皮擦模式状态来实现 return false; } private bool GetIsShapeDrawingMode() { // 这里需要根据实际的形状绘制模式状态来实现 return false; } private bool GetIsHighlighterMode() { // 这里需要根据实际的高亮笔模式状态来实现 return false; } private bool GetCanUndo() { return _mainWindow?.PluginHost_CanUndo() ?? false; } private bool GetCanRedo() { return _mainWindow?.PluginHost_CanRedo() ?? false; } #endregion #region IPluginService / IGetService 显式实现 List IGetService.GetAllPlugins() { return PluginManager.Instance.Plugins.ToList(); } IPlugin IGetService.GetPlugin(string pluginName) { return PluginManager.Instance.Plugins.FirstOrDefault(p => p.Name == pluginName); } List IGetService.AllCanvasPages { get { var pages = AllCanvasPages; return pages == null ? new List() : pages.ToList(); } } global::System.Windows.Controls.InkCanvas IGetService.CurrentCanvas => CurrentCanvas; void IWindowService.ShowNotification(string message, LegacyNotificationType type) { ShowNotification(message, MapLegacyNotification(type)); } private static InkCanvasForClass.PluginSdk.NotificationType MapLegacyNotification(LegacyNotificationType type) { switch (type) { case LegacyNotificationType.Success: return InkCanvasForClass.PluginSdk.NotificationType.Success; case LegacyNotificationType.Warning: return InkCanvasForClass.PluginSdk.NotificationType.Warning; case LegacyNotificationType.Error: return InkCanvasForClass.PluginSdk.NotificationType.Error; default: return InkCanvasForClass.PluginSdk.NotificationType.Info; } } #endregion } }