From dbb88d49998b8a0a4e492137db48bcd3e5993b8c Mon Sep 17 00:00:00 2001
From: CJKmkp <2564608840@qq.com>
Date: Sat, 13 Sep 2025 18:07:42 +0800
Subject: [PATCH] add:issue #190
---
Ink Canvas/Helpers/MultiPPTInkManager.cs | 553 ++++++++++++++++++
Ink Canvas/Helpers/PPTManager.cs | 76 ++-
Ink Canvas/MainWindow_cs/MW_PPT.cs | 57 +-
.../MainWindow_cs/MW_Save&OpenStrokes.cs | 8 +-
4 files changed, 667 insertions(+), 27 deletions(-)
create mode 100644 Ink Canvas/Helpers/MultiPPTInkManager.cs
diff --git a/Ink Canvas/Helpers/MultiPPTInkManager.cs b/Ink Canvas/Helpers/MultiPPTInkManager.cs
new file mode 100644
index 00000000..24e6f271
--- /dev/null
+++ b/Ink Canvas/Helpers/MultiPPTInkManager.cs
@@ -0,0 +1,553 @@
+using Microsoft.Office.Interop.PowerPoint;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Security.Cryptography;
+using System.Text;
+using System.Windows.Ink;
+
+namespace Ink_Canvas.Helpers
+{
+ ///
+ /// 多PPT墨迹管理器 - 支持多个PPT窗口分别管理墨迹
+ ///
+ public class MultiPPTInkManager : IDisposable
+ {
+ #region Properties
+ public bool IsAutoSaveEnabled { get; set; } = true;
+ public string AutoSaveLocation { get; set; } = "";
+ #endregion
+
+ #region Private Fields
+ private readonly Dictionary _presentationManagers;
+ private readonly Dictionary _presentationInfos;
+ private readonly object _lockObject = new object();
+ private bool _disposed;
+ private string _currentActivePresentationId = "";
+ #endregion
+
+ #region Constructor
+ public MultiPPTInkManager()
+ {
+ _presentationManagers = new Dictionary();
+ _presentationInfos = new Dictionary();
+ }
+ #endregion
+
+ #region Public Methods
+ ///
+ /// 初始化新的演示文稿
+ ///
+ public void InitializePresentation(Presentation presentation)
+ {
+ if (presentation == null) return;
+
+ lock (_lockObject)
+ {
+ try
+ {
+ var presentationId = GeneratePresentationId(presentation);
+
+ // 如果已存在该演示文稿的管理器,先清理
+ if (_presentationManagers.ContainsKey(presentationId))
+ {
+ _presentationManagers[presentationId].Dispose();
+ _presentationManagers.Remove(presentationId);
+ }
+
+ // 创建新的墨迹管理器
+ var inkManager = new PPTInkManager();
+ inkManager.IsAutoSaveEnabled = IsAutoSaveEnabled;
+ inkManager.AutoSaveLocation = AutoSaveLocation;
+ inkManager.InitializePresentation(presentation);
+
+ // 保存管理器和演示文稿信息
+ _presentationManagers[presentationId] = inkManager;
+ _presentationInfos[presentationId] = new PresentationInfo
+ {
+ Id = presentationId,
+ Name = presentation.Name,
+ FullName = presentation.FullName,
+ SlideCount = presentation.Slides.Count,
+ CreatedTime = DateTime.Now,
+ LastAccessTime = DateTime.Now
+ };
+
+ // 设置为当前活跃的演示文稿
+ _currentActivePresentationId = presentationId;
+
+ LogHelper.WriteLogToFile($"已初始化多PPT墨迹管理: {presentation.Name} (ID: {presentationId})", LogHelper.LogType.Event);
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteLogToFile($"初始化多PPT墨迹管理失败: {ex}", LogHelper.LogType.Error);
+ }
+ }
+ }
+
+ ///
+ /// 切换到指定的演示文稿
+ ///
+ public bool SwitchToPresentation(Presentation presentation)
+ {
+ if (presentation == null) return false;
+
+ lock (_lockObject)
+ {
+ try
+ {
+ var presentationId = GeneratePresentationId(presentation);
+
+ if (_presentationManagers.ContainsKey(presentationId))
+ {
+ _currentActivePresentationId = presentationId;
+
+ // 更新最后访问时间
+ if (_presentationInfos.ContainsKey(presentationId))
+ {
+ _presentationInfos[presentationId].LastAccessTime = DateTime.Now;
+ }
+
+ LogHelper.WriteLogToFile($"已切换到演示文稿: {presentation.Name} (ID: {presentationId})", LogHelper.LogType.Trace);
+ return true;
+ }
+ else
+ {
+ // 如果不存在,尝试初始化
+ InitializePresentation(presentation);
+ return true;
+ }
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteLogToFile($"切换到演示文稿失败: {ex}", LogHelper.LogType.Error);
+ return false;
+ }
+ }
+ }
+
+ ///
+ /// 保存当前页面的墨迹
+ ///
+ public void SaveCurrentSlideStrokes(int slideIndex, StrokeCollection strokes)
+ {
+ if (slideIndex <= 0 || strokes == null) return;
+
+ lock (_lockObject)
+ {
+ try
+ {
+ var manager = GetCurrentManager();
+ if (manager != null)
+ {
+ manager.SaveCurrentSlideStrokes(slideIndex, strokes);
+ }
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteLogToFile($"保存当前页面墨迹失败: {ex}", LogHelper.LogType.Error);
+ }
+ }
+ }
+
+ ///
+ /// 加载指定页面的墨迹
+ ///
+ public StrokeCollection LoadSlideStrokes(int slideIndex)
+ {
+ if (slideIndex <= 0) return new StrokeCollection();
+
+ lock (_lockObject)
+ {
+ try
+ {
+ var manager = GetCurrentManager();
+ if (manager != null)
+ {
+ return manager.LoadSlideStrokes(slideIndex);
+ }
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteLogToFile($"加载页面墨迹失败: {ex}", LogHelper.LogType.Error);
+ }
+ }
+
+ return new StrokeCollection();
+ }
+
+ ///
+ /// 切换到指定页面并加载墨迹
+ ///
+ public StrokeCollection SwitchToSlide(int slideIndex, StrokeCollection currentStrokes = null)
+ {
+ lock (_lockObject)
+ {
+ try
+ {
+ var manager = GetCurrentManager();
+ if (manager != null)
+ {
+ return manager.SwitchToSlide(slideIndex, currentStrokes);
+ }
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteLogToFile($"切换页面墨迹失败: {ex}", LogHelper.LogType.Error);
+ }
+ }
+
+ return new StrokeCollection();
+ }
+
+ ///
+ /// 保存所有墨迹到文件
+ ///
+ public void SaveAllStrokesToFile(Presentation presentation)
+ {
+ if (!IsAutoSaveEnabled || string.IsNullOrEmpty(AutoSaveLocation) || presentation == null) return;
+
+ lock (_lockObject)
+ {
+ try
+ {
+ var presentationId = GeneratePresentationId(presentation);
+ if (_presentationManagers.ContainsKey(presentationId))
+ {
+ _presentationManagers[presentationId].SaveAllStrokesToFile(presentation);
+ }
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteLogToFile($"保存所有墨迹到文件失败: {ex}", LogHelper.LogType.Error);
+ }
+ }
+ }
+
+ ///
+ /// 从文件加载已保存的墨迹
+ ///
+ public void LoadSavedStrokes(Presentation presentation)
+ {
+ if (!IsAutoSaveEnabled || string.IsNullOrEmpty(AutoSaveLocation) || presentation == null) return;
+
+ lock (_lockObject)
+ {
+ try
+ {
+ var presentationId = GeneratePresentationId(presentation);
+ if (_presentationManagers.ContainsKey(presentationId))
+ {
+ _presentationManagers[presentationId].LoadSavedStrokes();
+ }
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteLogToFile($"从文件加载墨迹失败: {ex}", LogHelper.LogType.Error);
+ }
+ }
+ }
+
+ ///
+ /// 清除指定演示文稿的所有墨迹
+ ///
+ public void ClearPresentationStrokes(Presentation presentation)
+ {
+ if (presentation == null) return;
+
+ lock (_lockObject)
+ {
+ try
+ {
+ var presentationId = GeneratePresentationId(presentation);
+ if (_presentationManagers.ContainsKey(presentationId))
+ {
+ _presentationManagers[presentationId].ClearAllStrokes();
+ LogHelper.WriteLogToFile($"已清除演示文稿墨迹: {presentation.Name}", LogHelper.LogType.Trace);
+ }
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteLogToFile($"清除演示文稿墨迹失败: {ex}", LogHelper.LogType.Error);
+ }
+ }
+ }
+
+ ///
+ /// 清除所有演示文稿的墨迹
+ ///
+ public void ClearAllStrokes()
+ {
+ lock (_lockObject)
+ {
+ try
+ {
+ foreach (var manager in _presentationManagers.Values)
+ {
+ manager?.ClearAllStrokes();
+ }
+ LogHelper.WriteLogToFile("已清除所有演示文稿墨迹", LogHelper.LogType.Trace);
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteLogToFile($"清除所有墨迹失败: {ex}", LogHelper.LogType.Error);
+ }
+ }
+ }
+
+ ///
+ /// 翻页后锁定墨迹写入
+ ///
+ public void LockInkForSlide(int slideIndex)
+ {
+ lock (_lockObject)
+ {
+ try
+ {
+ var manager = GetCurrentManager();
+ if (manager != null)
+ {
+ manager.LockInkForSlide(slideIndex);
+ }
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteLogToFile($"锁定墨迹写入失败: {ex}", LogHelper.LogType.Error);
+ }
+ }
+ }
+
+ ///
+ /// 检查是否可以写入墨迹
+ ///
+ public bool CanWriteInk(int currentSlideIndex)
+ {
+ lock (_lockObject)
+ {
+ try
+ {
+ var manager = GetCurrentManager();
+ if (manager != null)
+ {
+ return manager.CanWriteInk(currentSlideIndex);
+ }
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteLogToFile($"检查墨迹写入权限失败: {ex}", LogHelper.LogType.Error);
+ }
+ }
+
+ return false;
+ }
+
+ ///
+ /// 移除演示文稿管理器
+ ///
+ public void RemovePresentation(Presentation presentation)
+ {
+ if (presentation == null) return;
+
+ lock (_lockObject)
+ {
+ try
+ {
+ var presentationId = GeneratePresentationId(presentation);
+
+ if (_presentationManagers.ContainsKey(presentationId))
+ {
+ // 保存墨迹到文件
+ _presentationManagers[presentationId].SaveAllStrokesToFile(presentation);
+
+ // 释放资源
+ _presentationManagers[presentationId].Dispose();
+ _presentationManagers.Remove(presentationId);
+ }
+
+ if (_presentationInfos.ContainsKey(presentationId))
+ {
+ _presentationInfos.Remove(presentationId);
+ }
+
+ // 如果移除的是当前活跃的演示文稿,重置活跃ID
+ if (_currentActivePresentationId == presentationId)
+ {
+ _currentActivePresentationId = "";
+ }
+
+ LogHelper.WriteLogToFile($"已移除演示文稿管理器: {presentation.Name}", LogHelper.LogType.Trace);
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteLogToFile($"移除演示文稿管理器失败: {ex}", LogHelper.LogType.Error);
+ }
+ }
+ }
+
+ ///
+ /// 获取当前管理的演示文稿数量
+ ///
+ public int GetPresentationCount()
+ {
+ lock (_lockObject)
+ {
+ return _presentationManagers.Count;
+ }
+ }
+
+ ///
+ /// 获取所有演示文稿信息
+ ///
+ public List GetAllPresentationInfos()
+ {
+ lock (_lockObject)
+ {
+ return _presentationInfos.Values.ToList();
+ }
+ }
+
+ ///
+ /// 清理长时间未访问的演示文稿管理器
+ ///
+ public void CleanupInactivePresentations(TimeSpan inactiveThreshold)
+ {
+ lock (_lockObject)
+ {
+ try
+ {
+ var inactiveIds = new List();
+ var cutoffTime = DateTime.Now - inactiveThreshold;
+
+ foreach (var info in _presentationInfos.Values)
+ {
+ if (info.LastAccessTime < cutoffTime && info.Id != _currentActivePresentationId)
+ {
+ inactiveIds.Add(info.Id);
+ }
+ }
+
+ foreach (var id in inactiveIds)
+ {
+ if (_presentationManagers.ContainsKey(id))
+ {
+ _presentationManagers[id].Dispose();
+ _presentationManagers.Remove(id);
+ }
+ _presentationInfos.Remove(id);
+
+ LogHelper.WriteLogToFile($"已清理非活跃演示文稿: {id}", LogHelper.LogType.Trace);
+ }
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteLogToFile($"清理非活跃演示文稿失败: {ex}", LogHelper.LogType.Error);
+ }
+ }
+ }
+ #endregion
+
+ #region Private Methods
+ private PPTInkManager GetCurrentManager()
+ {
+ if (string.IsNullOrEmpty(_currentActivePresentationId) ||
+ !_presentationManagers.ContainsKey(_currentActivePresentationId))
+ {
+ return null;
+ }
+
+ return _presentationManagers[_currentActivePresentationId];
+ }
+
+ private string GeneratePresentationId(Presentation presentation)
+ {
+ try
+ {
+ var presentationPath = presentation.FullName;
+ var fileHash = GetFileHash(presentationPath);
+ var processId = GetProcessId(presentation);
+ return $"{presentation.Name}_{presentation.Slides.Count}_{fileHash}_{processId}";
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteLogToFile($"生成演示文稿ID失败: {ex}", LogHelper.LogType.Error);
+ return $"unknown_{DateTime.Now.Ticks}";
+ }
+ }
+
+ private string GetFileHash(string filePath)
+ {
+ try
+ {
+ if (string.IsNullOrEmpty(filePath)) return "unknown";
+
+ using (var md5 = MD5.Create())
+ {
+ byte[] hashBytes = md5.ComputeHash(Encoding.UTF8.GetBytes(filePath));
+ return BitConverter.ToString(hashBytes).Replace("-", "").Substring(0, 8);
+ }
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteLogToFile($"计算文件哈希值失败: {ex}", LogHelper.LogType.Error);
+ return "error";
+ }
+ }
+
+ private string GetProcessId(Presentation presentation)
+ {
+ try
+ {
+ // 尝试获取PowerPoint应用程序的进程ID
+ if (presentation.Application != null)
+ {
+ // 通过COM对象获取进程信息
+ var hwnd = presentation.Application.HWND;
+ if (hwnd != 0)
+ {
+ return hwnd.ToString();
+ }
+ }
+ return "unknown";
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteLogToFile($"获取进程ID失败: {ex}", LogHelper.LogType.Error);
+ return "error";
+ }
+ }
+ #endregion
+
+ #region Dispose
+ public void Dispose()
+ {
+ if (!_disposed)
+ {
+ lock (_lockObject)
+ {
+ foreach (var manager in _presentationManagers.Values)
+ {
+ manager?.Dispose();
+ }
+ _presentationManagers.Clear();
+ _presentationInfos.Clear();
+ }
+ _disposed = true;
+ }
+ }
+ #endregion
+ }
+
+ ///
+ /// 演示文稿信息
+ ///
+ public class PresentationInfo
+ {
+ public string Id { get; set; }
+ public string Name { get; set; }
+ public string FullName { get; set; }
+ public int SlideCount { get; set; }
+ public DateTime CreatedTime { get; set; }
+ public DateTime LastAccessTime { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Ink Canvas/Helpers/PPTManager.cs b/Ink Canvas/Helpers/PPTManager.cs
index 47235093..b0951a34 100644
--- a/Ink Canvas/Helpers/PPTManager.cs
+++ b/Ink Canvas/Helpers/PPTManager.cs
@@ -874,14 +874,86 @@ namespace Ink_Canvas.Helpers
}
}
+ ///
+ /// 获取当前活跃的演示文稿(用于多窗口墨迹分离)
+ ///
+ public Presentation GetCurrentActivePresentation()
+ {
+ try
+ {
+ if (!IsConnected || PPTApplication == null) return null;
+ if (!Marshal.IsComObject(PPTApplication)) return null;
+
+ // 如果在放映模式,获取放映窗口的演示文稿
+ if (IsInSlideShow && PPTApplication.SlideShowWindows.Count > 0)
+ {
+ var slideShowWindow = PPTApplication.SlideShowWindows[1];
+ if (slideShowWindow?.View != null)
+ {
+ return (Presentation)slideShowWindow.View.Slide.Parent;
+ }
+ }
+
+ // 如果不在放映模式,获取活动窗口的演示文稿
+ if (PPTApplication.ActiveWindow?.Presentation != null)
+ {
+ return PPTApplication.ActiveWindow.Presentation;
+ }
+
+ // 如果没有活动窗口,返回当前演示文稿
+ return CurrentPresentation;
+ }
+ catch (COMException comEx)
+ {
+ var hr = (uint)comEx.HResult;
+ if (hr == 0x8001010E || hr == 0x80004005)
+ {
+ // COM对象已失效,触发断开连接
+ DisconnectFromPPT();
+ }
+ LogHelper.WriteLogToFile($"获取当前活跃演示文稿失败: {comEx.Message}", LogHelper.LogType.Warning);
+ return CurrentPresentation;
+ }
+ catch (Exception ex)
+ {
+ LogHelper.WriteLogToFile($"获取当前活跃演示文稿失败: {ex}", LogHelper.LogType.Error);
+ return CurrentPresentation;
+ }
+ }
+
+ ///
+ /// 获取当前幻灯片编号
+ ///
public int GetCurrentSlideNumber()
{
try
{
- if (!IsConnected || !IsInSlideShow || PPTApplication == null) return 0;
+ if (!IsConnected || PPTApplication == null) return 0;
if (!Marshal.IsComObject(PPTApplication)) return 0;
- return PPTApplication.SlideShowWindows[1]?.View?.CurrentShowPosition ?? 0;
+ // 如果在放映模式,获取放映窗口的当前幻灯片编号
+ if (IsInSlideShow && PPTApplication.SlideShowWindows.Count > 0)
+ {
+ var slideShowWindow = PPTApplication.SlideShowWindows[1];
+ if (slideShowWindow?.View != null)
+ {
+ return slideShowWindow.View.CurrentShowPosition;
+ }
+ }
+
+ // 如果不在放映模式,获取活动窗口的当前幻灯片编号
+ if (PPTApplication.ActiveWindow?.Selection?.SlideRange?.SlideNumber > 0)
+ {
+ return PPTApplication.ActiveWindow.Selection.SlideRange.SlideNumber;
+ }
+
+ // 如果CurrentSlide存在,尝试获取其编号
+ if (CurrentSlide != null && Marshal.IsComObject(CurrentSlide))
+ {
+ return CurrentSlide.SlideNumber;
+ }
+
+ return 0;
}
catch (COMException comEx)
{
diff --git a/Ink Canvas/MainWindow_cs/MW_PPT.cs b/Ink Canvas/MainWindow_cs/MW_PPT.cs
index 582cfd0a..ea4a3876 100644
--- a/Ink Canvas/MainWindow_cs/MW_PPT.cs
+++ b/Ink Canvas/MainWindow_cs/MW_PPT.cs
@@ -87,7 +87,7 @@ namespace Ink_Canvas
// PowerPoint应用程序守护相关字段
private DispatcherTimer _powerPointProcessMonitorTimer;
- private const int ProcessMonitorInterval = 5000; // 应用程序监控间隔(毫秒)
+ private const int ProcessMonitorInterval = 1000; // 应用程序监控间隔(毫秒)
// 上次播放位置相关字段
private int _lastPlaybackPage = 0;
@@ -96,7 +96,7 @@ namespace Ink_Canvas
#region PPT Managers
private PPTManager _pptManager;
- private PPTInkManager _pptInkManager;
+ private MultiPPTInkManager _multiPPTInkManager;
private PPTUIManager _pptUIManager;
///
@@ -126,10 +126,10 @@ namespace Ink_Canvas
_pptManager.PresentationClose += OnPPTPresentationClose;
_pptManager.SlideShowStateChanged += OnPPTSlideShowStateChanged;
- // 初始化墨迹管理器
- _pptInkManager = new PPTInkManager();
- _pptInkManager.IsAutoSaveEnabled = Settings.PowerPointSettings.IsAutoSaveStrokesInPowerPoint;
- _pptInkManager.AutoSaveLocation = Settings.Automation.AutoSavedStrokesLocation;
+ // 初始化多PPT墨迹管理器
+ _multiPPTInkManager = new MultiPPTInkManager();
+ _multiPPTInkManager.IsAutoSaveEnabled = Settings.PowerPointSettings.IsAutoSaveStrokesInPowerPoint;
+ _multiPPTInkManager.AutoSaveLocation = Settings.Automation.AutoSavedStrokesLocation;
// 初始化UI管理器
_pptUIManager = new PPTUIManager(this);
@@ -412,11 +412,11 @@ namespace Ink_Canvas
try
{
_pptManager?.Dispose();
- _pptInkManager?.Dispose();
+ _multiPPTInkManager?.Dispose();
_longPressTimer?.Stop();
_longPressTimer = null;
_pptManager = null;
- _pptInkManager = null;
+ _multiPPTInkManager = null;
_pptUIManager = null;
// 清理PowerPoint进程守护
@@ -502,7 +502,7 @@ namespace Ink_Canvas
{
LogHelper.WriteLogToFile("PPT连接已断开", LogHelper.LogType.Event);
// 清理墨迹管理器
- _pptInkManager?.ClearAllStrokes();
+ _multiPPTInkManager?.ClearAllStrokes();
}
});
}
@@ -527,8 +527,8 @@ namespace Ink_Canvas
TimeMachineHistories[0] = null;
}
- // 初始化墨迹管理器
- _pptInkManager?.InitializePresentation(pres);
+ // 初始化多PPT墨迹管理器
+ _multiPPTInkManager?.InitializePresentation(pres);
// 处理跳转到首页或上次播放页的逻辑
HandlePresentationOpenNavigation(pres);
@@ -563,10 +563,10 @@ namespace Ink_Canvas
Application.Current.Dispatcher.InvokeAsync(() =>
{
// 保存所有墨迹
- _pptInkManager?.SaveAllStrokesToFile(pres);
+ _multiPPTInkManager?.SaveAllStrokesToFile(pres);
- // 清理墨迹管理器
- _pptInkManager?.ClearAllStrokes();
+ // 移除演示文稿管理器
+ _multiPPTInkManager?.RemovePresentation(pres);
_pptUIManager?.UpdateConnectionStatus(false);
});
@@ -617,6 +617,14 @@ namespace Ink_Canvas
await Application.Current.Dispatcher.InvokeAsync(() =>
{
+ // 获取当前活跃的演示文稿并切换到对应的墨迹管理器
+ var activePresentation = _pptManager?.GetCurrentActivePresentation();
+ if (activePresentation != null)
+ {
+ _multiPPTInkManager?.SwitchToPresentation(activePresentation);
+ LogHelper.WriteLogToFile($"已切换到活跃演示文稿: {activePresentation.Name}", LogHelper.LogType.Trace);
+ }
+
// 处理跳转到首页或上次播放位置
if (Settings.PowerPointSettings.IsAlwaysGoToFirstPageOnReenter)
{
@@ -709,6 +717,13 @@ namespace Ink_Canvas
{
Application.Current.Dispatcher.InvokeAsync(() =>
{
+ // 获取当前活跃的演示文稿并确保切换到正确的墨迹管理器
+ var activePresentation = _pptManager?.GetCurrentActivePresentation();
+ if (activePresentation != null)
+ {
+ _multiPPTInkManager?.SwitchToPresentation(activePresentation);
+ }
+
var currentSlide = _pptManager?.GetCurrentSlideNumber() ?? 0;
var totalSlides = _pptManager?.SlidesCount ?? 0;
@@ -745,7 +760,7 @@ namespace Ink_Canvas
isEnteredSlideShowEndEvent = true;
// 保存所有墨迹
- _pptInkManager?.SaveAllStrokesToFile(pres);
+ _multiPPTInkManager?.SaveAllStrokesToFile(pres);
await Application.Current.Dispatcher.InvokeAsync(() =>
{
@@ -982,7 +997,7 @@ namespace Ink_Canvas
{
try
{
- var strokes = _pptInkManager?.LoadSlideStrokes(slideIndex);
+ var strokes = _multiPPTInkManager?.LoadSlideStrokes(slideIndex);
if (strokes != null)
{
inkCanvas.Strokes.Clear();
@@ -999,7 +1014,7 @@ namespace Ink_Canvas
{
try
{
- var newStrokes = _pptInkManager?.SwitchToSlide(newSlideIndex, inkCanvas.Strokes);
+ var newStrokes = _multiPPTInkManager?.SwitchToSlide(newSlideIndex, inkCanvas.Strokes);
if (newStrokes != null)
{
inkCanvas.Strokes.Clear();
@@ -1007,7 +1022,7 @@ namespace Ink_Canvas
}
// 设置墨迹锁定
- _pptInkManager?.LockInkForSlide(newSlideIndex);
+ _multiPPTInkManager?.LockInkForSlide(newSlideIndex);
}
catch (Exception ex)
{
@@ -1143,7 +1158,7 @@ namespace Ink_Canvas
var currentSlide = _pptManager?.GetCurrentSlideNumber() ?? 0;
if (currentSlide > 0)
{
- _pptInkManager?.SaveCurrentSlideStrokes(currentSlide, inkCanvas.Strokes);
+ _multiPPTInkManager?.SaveCurrentSlideStrokes(currentSlide, inkCanvas.Strokes);
}
// 保存截图(如果启用)
@@ -1184,7 +1199,7 @@ namespace Ink_Canvas
var currentSlide = _pptManager?.GetCurrentSlideNumber() ?? 0;
if (currentSlide > 0)
{
- _pptInkManager?.SaveCurrentSlideStrokes(currentSlide, inkCanvas.Strokes);
+ _multiPPTInkManager?.SaveCurrentSlideStrokes(currentSlide, inkCanvas.Strokes);
}
// 保存截图(如果启用)
@@ -1345,7 +1360,7 @@ namespace Ink_Canvas
{
Application.Current.Dispatcher.Invoke(() =>
{
- _pptInkManager?.SaveCurrentSlideStrokes(currentSlide, inkCanvas.Strokes);
+ _multiPPTInkManager?.SaveCurrentSlideStrokes(currentSlide, inkCanvas.Strokes);
timeMachine.ClearStrokeHistory();
});
}
diff --git a/Ink Canvas/MainWindow_cs/MW_Save&OpenStrokes.cs b/Ink Canvas/MainWindow_cs/MW_Save&OpenStrokes.cs
index c949fdca..a3e252e1 100644
--- a/Ink Canvas/MainWindow_cs/MW_Save&OpenStrokes.cs
+++ b/Ink Canvas/MainWindow_cs/MW_Save&OpenStrokes.cs
@@ -78,7 +78,7 @@ namespace Ink_Canvas
for (int i = 1; i <= totalSlides; i++)
{
- var slideStrokes = _pptInkManager?.LoadSlideStrokes(i);
+ var slideStrokes = _multiPPTInkManager?.LoadSlideStrokes(i);
if (slideStrokes != null && slideStrokes.Count > 0)
{
allPageStrokes.Add(slideStrokes);
@@ -528,7 +528,7 @@ namespace Ink_Canvas
timeMachine.ClearStrokeHistory();
// 重置PPT墨迹存储
- _pptInkManager?.ClearAllStrokes();
+ _multiPPTInkManager?.ClearAllStrokes();
// 读取所有页面的墨迹文件
var files = Directory.GetFiles(tempDir, "page_*.icstk");
@@ -542,7 +542,7 @@ namespace Ink_Canvas
var strokes = new StrokeCollection(fs);
if (strokes.Count > 0)
{
- _pptInkManager?.SaveCurrentSlideStrokes(pageNumber, strokes);
+ _multiPPTInkManager?.SaveCurrentSlideStrokes(pageNumber, strokes);
}
}
}
@@ -552,7 +552,7 @@ namespace Ink_Canvas
if (_pptManager?.IsInSlideShow == true)
{
int currentSlide = _pptManager.GetCurrentSlideNumber();
- var currentStrokes = _pptInkManager?.LoadSlideStrokes(currentSlide);
+ var currentStrokes = _multiPPTInkManager?.LoadSlideStrokes(currentSlide);
if (currentStrokes != null && currentStrokes.Count > 0)
{
inkCanvas.Strokes.Add(currentStrokes);