improve:ROT模块

This commit is contained in:
2026-02-24 12:21:46 +08:00
parent 5c3056aea0
commit c76021194a
3 changed files with 3214 additions and 820 deletions
+17
View File
@@ -460,6 +460,12 @@ namespace Ink_Canvas.Helpers
{ {
Thread.Sleep(2000); Thread.Sleep(2000);
if (_disposed)
{
_isModuleUnloading = false;
return;
}
GC.Collect(); GC.Collect();
GC.WaitForPendingFinalizers(); GC.WaitForPendingFinalizers();
GC.Collect(); GC.Collect();
@@ -467,7 +473,18 @@ namespace Ink_Canvas.Helpers
Thread.Sleep(1000); Thread.Sleep(1000);
_isModuleUnloading = false; _isModuleUnloading = false;
try
{
if (!_disposed)
{
_unifiedPptTimer?.Start(); _unifiedPptTimer?.Start();
}
}
catch (ObjectDisposedException)
{
LogHelper.WriteLogToFile("PPT联动模块重载时计时器已释放,跳过重启", LogHelper.LogType.Trace);
}
LogHelper.WriteLogToFile("PPT联动模块已重新加载", LogHelper.LogType.Trace); LogHelper.WriteLogToFile("PPT联动模块已重新加载", LogHelper.LogType.Trace);
} }
File diff suppressed because it is too large Load Diff
+60 -17
View File
@@ -723,24 +723,14 @@ namespace Ink_Canvas
{ {
LogHelper.WriteLogToFile("PPT连接已断开", LogHelper.LogType.Event); LogHelper.WriteLogToFile("PPT连接已断开", LogHelper.LogType.Event);
_singlePPTInkManager?.ClearAllStrokes(); _singlePPTInkManager?.ClearAllStrokes();
_exitPPTModeAfterDisconnectTimer?.Stop();
_exitPPTModeAfterDisconnectTimer = new DispatcherTimer
{
Interval = TimeSpan.FromMilliseconds(ExitPPTModeAfterDisconnectDelayMs)
};
_exitPPTModeAfterDisconnectTimer.Tick += (s, e) =>
{
_exitPPTModeAfterDisconnectTimer?.Stop(); _exitPPTModeAfterDisconnectTimer?.Stop();
_exitPPTModeAfterDisconnectTimer = null; _exitPPTModeAfterDisconnectTimer = null;
if (_pptManager?.IsConnected != true)
{
_pptUIManager?.UpdateSlideShowStatus(false); _pptUIManager?.UpdateSlideShowStatus(false);
_pptUIManager?.UpdateSidebarExitButtons(false); _pptUIManager?.UpdateSidebarExitButtons(false);
ResetPPTStateVariables(); ResetPPTStateVariables();
_ = HandleManualSlideShowEnd(); _ = HandleManualSlideShowEnd();
} if (Settings.PowerPointSettings.UseRotPptLink)
}; _pptManager?.ReloadConnection();
_exitPPTModeAfterDisconnectTimer.Start();
} }
}); });
} }
@@ -921,14 +911,36 @@ namespace Ink_Canvas
string presentationName = null; string presentationName = null;
Presentation activePresentation = null; Presentation activePresentation = null;
if (wn?.View != null && wn.Presentation != null) if (wn != null)
{
try
{
if (wn.View != null && wn.Presentation != null)
{ {
activePresentation = wn.Presentation; activePresentation = wn.Presentation;
currentSlide = wn.View.CurrentShowPosition; currentSlide = wn.View.CurrentShowPosition;
totalSlides = activePresentation.Slides.Count; totalSlides = activePresentation.Slides.Count;
presentationName = activePresentation.Name; presentationName = activePresentation.Name;
} }
else }
catch (COMException comEx)
{
var hr = (uint)comEx.HResult;
activePresentation = null;
currentSlide = 0;
totalSlides = 0;
presentationName = null;
}
catch (Exception ex)
{
activePresentation = null;
currentSlide = 0;
totalSlides = 0;
presentationName = null;
}
}
if (activePresentation == null)
{ {
activePresentation = _pptManager?.GetCurrentActivePresentation() as Presentation; activePresentation = _pptManager?.GetCurrentActivePresentation() as Presentation;
currentSlide = _pptManager?.GetCurrentSlideNumber() ?? 0; currentSlide = _pptManager?.GetCurrentSlideNumber() ?? 0;
@@ -1134,10 +1146,41 @@ namespace Ink_Canvas
{ {
try try
{ {
if (wn?.View == null || wn.Presentation == null) return; int currentSlide = 0;
int totalSlides = 0;
int currentSlide = wn.View.CurrentShowPosition; if (wn != null)
int totalSlides = wn.Presentation.Slides.Count; {
try
{
if (wn.View != null)
{
currentSlide = wn.View.CurrentShowPosition;
}
}
catch (COMException comEx)
{
var hr = (uint)comEx.HResult;
LogHelper.WriteLogToFile(
$"通过 SlideShowWindow.View 获取当前页失败: {comEx.Message} (HR: 0x{hr:X8}),将回退到 PPT 管理器获取",
LogHelper.LogType.Warning);
currentSlide = 0;
}
catch (Exception ex)
{
LogHelper.WriteLogToFile(
$"通过 SlideShowWindow.View 获取当前页时发生异常,将回退到 PPT 管理器获取: {ex}",
LogHelper.LogType.Warning);
currentSlide = 0;
}
}
if (currentSlide <= 0)
{
currentSlide = _pptManager?.GetCurrentSlideNumber() ?? 0;
}
totalSlides = _pptManager?.SlidesCount ?? 0;
if (currentSlide == _previousSlideID) return; if (currentSlide == _previousSlideID) return;