fix:issue # 262
This commit is contained in:
@@ -11,6 +11,7 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Ink;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
using Application = System.Windows.Application;
|
using Application = System.Windows.Application;
|
||||||
@@ -104,6 +105,7 @@ namespace Ink_Canvas
|
|||||||
#region PPT Managers
|
#region PPT Managers
|
||||||
private PPTManager _pptManager;
|
private PPTManager _pptManager;
|
||||||
private MultiPPTInkManager _multiPPTInkManager;
|
private MultiPPTInkManager _multiPPTInkManager;
|
||||||
|
private PPTInkManager _singlePPTInkManager;
|
||||||
private PPTUIManager _pptUIManager;
|
private PPTUIManager _pptUIManager;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -133,11 +135,19 @@ namespace Ink_Canvas
|
|||||||
_pptManager.PresentationClose += OnPPTPresentationClose;
|
_pptManager.PresentationClose += OnPPTPresentationClose;
|
||||||
_pptManager.SlideShowStateChanged += OnPPTSlideShowStateChanged;
|
_pptManager.SlideShowStateChanged += OnPPTSlideShowStateChanged;
|
||||||
|
|
||||||
// 初始化多PPT墨迹管理器
|
if (Settings.PowerPointSettings.IsSupportWPS)
|
||||||
_multiPPTInkManager = new MultiPPTInkManager();
|
{
|
||||||
_multiPPTInkManager.IsAutoSaveEnabled = Settings.PowerPointSettings.IsAutoSaveStrokesInPowerPoint;
|
_singlePPTInkManager = new PPTInkManager();
|
||||||
_multiPPTInkManager.AutoSaveLocation = Settings.Automation.AutoSavedStrokesLocation;
|
_singlePPTInkManager.IsAutoSaveEnabled = Settings.PowerPointSettings.IsAutoSaveStrokesInPowerPoint;
|
||||||
_multiPPTInkManager.PPTManager = _pptManager;
|
_singlePPTInkManager.AutoSaveLocation = Settings.Automation.AutoSavedStrokesLocation;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_multiPPTInkManager = new MultiPPTInkManager();
|
||||||
|
_multiPPTInkManager.IsAutoSaveEnabled = Settings.PowerPointSettings.IsAutoSaveStrokesInPowerPoint;
|
||||||
|
_multiPPTInkManager.AutoSaveLocation = Settings.Automation.AutoSavedStrokesLocation;
|
||||||
|
_multiPPTInkManager.PPTManager = _pptManager;
|
||||||
|
}
|
||||||
|
|
||||||
// 初始化UI管理器
|
// 初始化UI管理器
|
||||||
_pptUIManager = new PPTUIManager(this);
|
_pptUIManager = new PPTUIManager(this);
|
||||||
@@ -421,10 +431,12 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
_pptManager?.Dispose();
|
_pptManager?.Dispose();
|
||||||
_multiPPTInkManager?.Dispose();
|
_multiPPTInkManager?.Dispose();
|
||||||
|
_singlePPTInkManager?.Dispose();
|
||||||
_longPressTimer?.Stop();
|
_longPressTimer?.Stop();
|
||||||
_longPressTimer = null;
|
_longPressTimer = null;
|
||||||
_pptManager = null;
|
_pptManager = null;
|
||||||
_multiPPTInkManager = null;
|
_multiPPTInkManager = null;
|
||||||
|
_singlePPTInkManager = null;
|
||||||
_pptUIManager = null;
|
_pptUIManager = null;
|
||||||
|
|
||||||
// 清理PowerPoint进程守护
|
// 清理PowerPoint进程守护
|
||||||
@@ -509,8 +521,14 @@ namespace Ink_Canvas
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogHelper.WriteLogToFile("PPT连接已断开", LogHelper.LogType.Event);
|
LogHelper.WriteLogToFile("PPT连接已断开", LogHelper.LogType.Event);
|
||||||
// 清理墨迹管理器
|
if (Settings.PowerPointSettings.IsSupportWPS)
|
||||||
_multiPPTInkManager?.ClearAllStrokes();
|
{
|
||||||
|
_singlePPTInkManager?.ClearAllStrokes();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_multiPPTInkManager?.ClearAllStrokes();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -535,8 +553,14 @@ namespace Ink_Canvas
|
|||||||
TimeMachineHistories[0] = null;
|
TimeMachineHistories[0] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 初始化多PPT墨迹管理器
|
if (Settings.PowerPointSettings.IsSupportWPS)
|
||||||
_multiPPTInkManager?.InitializePresentation(pres);
|
{
|
||||||
|
_singlePPTInkManager?.InitializePresentation(pres);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_multiPPTInkManager?.InitializePresentation(pres);
|
||||||
|
}
|
||||||
|
|
||||||
// 处理跳转到首页或上次播放页的逻辑
|
// 处理跳转到首页或上次播放页的逻辑
|
||||||
HandlePresentationOpenNavigation(pres);
|
HandlePresentationOpenNavigation(pres);
|
||||||
@@ -570,11 +594,15 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
Application.Current.Dispatcher.InvokeAsync(() =>
|
Application.Current.Dispatcher.InvokeAsync(() =>
|
||||||
{
|
{
|
||||||
// 保存所有墨迹
|
if (Settings.PowerPointSettings.IsSupportWPS)
|
||||||
_multiPPTInkManager?.SaveAllStrokesToFile(pres);
|
{
|
||||||
|
_singlePPTInkManager?.SaveAllStrokesToFile(pres);
|
||||||
// 移除演示文稿管理器
|
}
|
||||||
_multiPPTInkManager?.RemovePresentation(pres);
|
else
|
||||||
|
{
|
||||||
|
_multiPPTInkManager?.SaveAllStrokesToFile(pres);
|
||||||
|
_multiPPTInkManager?.RemovePresentation(pres);
|
||||||
|
}
|
||||||
|
|
||||||
_pptUIManager?.UpdateConnectionStatus(false);
|
_pptUIManager?.UpdateConnectionStatus(false);
|
||||||
});
|
});
|
||||||
@@ -639,11 +667,16 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
Application.Current.Dispatcher.Invoke(() =>
|
Application.Current.Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
// 获取当前活跃的演示文稿并切换到对应的墨迹管理器
|
|
||||||
var activePresentation = _pptManager?.GetCurrentActivePresentation();
|
var activePresentation = _pptManager?.GetCurrentActivePresentation();
|
||||||
if (activePresentation != null)
|
if (activePresentation != null)
|
||||||
{
|
{
|
||||||
_multiPPTInkManager?.SwitchToPresentation(activePresentation);
|
if (Settings.PowerPointSettings.IsSupportWPS)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_multiPPTInkManager?.SwitchToPresentation(activePresentation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理跳转到首页或上次播放位置
|
// 处理跳转到首页或上次播放位置
|
||||||
@@ -767,11 +800,16 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
Application.Current.Dispatcher.InvokeAsync(() =>
|
Application.Current.Dispatcher.InvokeAsync(() =>
|
||||||
{
|
{
|
||||||
// 获取当前活跃的演示文稿并确保切换到正确的墨迹管理器
|
|
||||||
var activePresentation = _pptManager?.GetCurrentActivePresentation();
|
var activePresentation = _pptManager?.GetCurrentActivePresentation();
|
||||||
if (activePresentation != null)
|
if (activePresentation != null)
|
||||||
{
|
{
|
||||||
_multiPPTInkManager?.SwitchToPresentation(activePresentation);
|
if (Settings.PowerPointSettings.IsSupportWPS)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_multiPPTInkManager?.SwitchToPresentation(activePresentation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentSlide = _pptManager?.GetCurrentSlideNumber() ?? 0;
|
var currentSlide = _pptManager?.GetCurrentSlideNumber() ?? 0;
|
||||||
@@ -824,8 +862,14 @@ namespace Ink_Canvas
|
|||||||
if (isEnteredSlideShowEndEvent) return;
|
if (isEnteredSlideShowEndEvent) return;
|
||||||
isEnteredSlideShowEndEvent = true;
|
isEnteredSlideShowEndEvent = true;
|
||||||
|
|
||||||
// 保存所有墨迹
|
if (Settings.PowerPointSettings.IsSupportWPS)
|
||||||
_multiPPTInkManager?.SaveAllStrokesToFile(pres);
|
{
|
||||||
|
_singlePPTInkManager?.SaveAllStrokesToFile(pres);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_multiPPTInkManager?.SaveAllStrokesToFile(pres);
|
||||||
|
}
|
||||||
|
|
||||||
await Application.Current.Dispatcher.InvokeAsync(() =>
|
await Application.Current.Dispatcher.InvokeAsync(() =>
|
||||||
{
|
{
|
||||||
@@ -1084,7 +1128,16 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var strokes = _multiPPTInkManager?.LoadSlideStrokes(slideIndex);
|
StrokeCollection strokes = null;
|
||||||
|
if (Settings.PowerPointSettings.IsSupportWPS)
|
||||||
|
{
|
||||||
|
strokes = _singlePPTInkManager?.LoadSlideStrokes(slideIndex);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strokes = _multiPPTInkManager?.LoadSlideStrokes(slideIndex);
|
||||||
|
}
|
||||||
|
|
||||||
if (strokes != null)
|
if (strokes != null)
|
||||||
{
|
{
|
||||||
inkCanvas.Strokes.Clear();
|
inkCanvas.Strokes.Clear();
|
||||||
@@ -1104,15 +1157,18 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// 获取当前活跃的演示文稿
|
if (Settings.PowerPointSettings.IsSupportWPS)
|
||||||
var activePresentation = _pptManager?.GetCurrentActivePresentation();
|
|
||||||
if (activePresentation != null)
|
|
||||||
{
|
{
|
||||||
// 切换到对应的墨迹管理器
|
_singlePPTInkManager?.ResetLockState();
|
||||||
_multiPPTInkManager?.SwitchToPresentation(activePresentation);
|
}
|
||||||
|
else
|
||||||
// 重置锁定状态
|
{
|
||||||
_multiPPTInkManager?.ResetCurrentPresentationLockState();
|
var activePresentation = _pptManager?.GetCurrentActivePresentation();
|
||||||
|
if (activePresentation != null)
|
||||||
|
{
|
||||||
|
_multiPPTInkManager?.SwitchToPresentation(activePresentation);
|
||||||
|
_multiPPTInkManager?.ResetCurrentPresentationLockState();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -1226,26 +1282,41 @@ namespace Ink_Canvas
|
|||||||
// 如果有当前墨迹且不是第一次切换,先保存到当前页面
|
// 如果有当前墨迹且不是第一次切换,先保存到当前页面
|
||||||
if (inkCanvas.Strokes.Count > 0 && currentSlideIndex > 0 && currentSlideIndex != newSlideIndex)
|
if (inkCanvas.Strokes.Count > 0 && currentSlideIndex > 0 && currentSlideIndex != newSlideIndex)
|
||||||
{
|
{
|
||||||
// 检查是否可以写入墨迹
|
bool canWrite = false;
|
||||||
bool canWrite = _multiPPTInkManager?.CanWriteInk(currentSlideIndex) == true;
|
if (Settings.PowerPointSettings.IsSupportWPS)
|
||||||
|
|
||||||
if (canWrite)
|
|
||||||
{
|
{
|
||||||
// 正常保存
|
canWrite = _singlePPTInkManager?.CanWriteInk(currentSlideIndex) == true;
|
||||||
_multiPPTInkManager?.SaveCurrentSlideStrokes(currentSlideIndex, inkCanvas.Strokes);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 墨迹被锁定,跳过保存以避免墨迹错页
|
canWrite = _multiPPTInkManager?.CanWriteInk(currentSlideIndex) == true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canWrite)
|
||||||
|
{
|
||||||
|
if (Settings.PowerPointSettings.IsSupportWPS)
|
||||||
|
{
|
||||||
|
_singlePPTInkManager?.SaveCurrentSlideStrokes(currentSlideIndex, inkCanvas.Strokes);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_multiPPTInkManager?.SaveCurrentSlideStrokes(currentSlideIndex, inkCanvas.Strokes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (inkCanvas.Strokes.Count > 0 && currentSlideIndex <= 0)
|
else if (inkCanvas.Strokes.Count > 0 && currentSlideIndex <= 0)
|
||||||
{
|
{
|
||||||
// 无法获取当前页面索引时,不保存墨迹,直接清空
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 切换到新页面并加载墨迹
|
StrokeCollection newStrokes = null;
|
||||||
var newStrokes = _multiPPTInkManager?.SwitchToSlide(newSlideIndex, null);
|
if (Settings.PowerPointSettings.IsSupportWPS)
|
||||||
|
{
|
||||||
|
newStrokes = _singlePPTInkManager?.SwitchToSlide(newSlideIndex, null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newStrokes = _multiPPTInkManager?.SwitchToSlide(newSlideIndex, null);
|
||||||
|
}
|
||||||
if (newStrokes != null)
|
if (newStrokes != null)
|
||||||
{
|
{
|
||||||
inkCanvas.Strokes.Clear();
|
inkCanvas.Strokes.Clear();
|
||||||
@@ -1386,7 +1457,14 @@ namespace Ink_Canvas
|
|||||||
var currentSlide = _pptManager?.GetCurrentSlideNumber() ?? 0;
|
var currentSlide = _pptManager?.GetCurrentSlideNumber() ?? 0;
|
||||||
if (currentSlide > 0)
|
if (currentSlide > 0)
|
||||||
{
|
{
|
||||||
_multiPPTInkManager?.SaveCurrentSlideStrokes(currentSlide, inkCanvas.Strokes);
|
if (Settings.PowerPointSettings.IsSupportWPS)
|
||||||
|
{
|
||||||
|
_singlePPTInkManager?.SaveCurrentSlideStrokes(currentSlide, inkCanvas.Strokes);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_multiPPTInkManager?.SaveCurrentSlideStrokes(currentSlide, inkCanvas.Strokes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 保存截图(如果启用)
|
// 保存截图(如果启用)
|
||||||
@@ -1426,7 +1504,14 @@ namespace Ink_Canvas
|
|||||||
var currentSlide = _pptManager?.GetCurrentSlideNumber() ?? 0;
|
var currentSlide = _pptManager?.GetCurrentSlideNumber() ?? 0;
|
||||||
if (currentSlide > 0)
|
if (currentSlide > 0)
|
||||||
{
|
{
|
||||||
_multiPPTInkManager?.SaveCurrentSlideStrokes(currentSlide, inkCanvas.Strokes);
|
if (Settings.PowerPointSettings.IsSupportWPS)
|
||||||
|
{
|
||||||
|
_singlePPTInkManager?.SaveCurrentSlideStrokes(currentSlide, inkCanvas.Strokes);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_multiPPTInkManager?.SaveCurrentSlideStrokes(currentSlide, inkCanvas.Strokes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 保存截图(如果启用)
|
// 保存截图(如果启用)
|
||||||
@@ -1585,7 +1670,14 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
Application.Current.Dispatcher.Invoke(() =>
|
Application.Current.Dispatcher.Invoke(() =>
|
||||||
{
|
{
|
||||||
_multiPPTInkManager?.SaveCurrentSlideStrokes(currentSlide, inkCanvas.Strokes);
|
if (Settings.PowerPointSettings.IsSupportWPS)
|
||||||
|
{
|
||||||
|
_singlePPTInkManager?.SaveCurrentSlideStrokes(currentSlide, inkCanvas.Strokes);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_multiPPTInkManager?.SaveCurrentSlideStrokes(currentSlide, inkCanvas.Strokes);
|
||||||
|
}
|
||||||
timeMachine.ClearStrokeHistory();
|
timeMachine.ClearStrokeHistory();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user