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
+18 -1
View File
@@ -460,6 +460,12 @@ namespace Ink_Canvas.Helpers
{
Thread.Sleep(2000);
if (_disposed)
{
_isModuleUnloading = false;
return;
}
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
@@ -467,7 +473,18 @@ namespace Ink_Canvas.Helpers
Thread.Sleep(1000);
_isModuleUnloading = false;
_unifiedPptTimer?.Start();
try
{
if (!_disposed)
{
_unifiedPptTimer?.Start();
}
}
catch (ObjectDisposedException)
{
LogHelper.WriteLogToFile("PPT联动模块重载时计时器已释放,跳过重启", LogHelper.LogType.Trace);
}
LogHelper.WriteLogToFile("PPT联动模块已重新加载", LogHelper.LogType.Trace);
}
File diff suppressed because it is too large Load Diff
+69 -26
View File
@@ -724,23 +724,13 @@ namespace Ink_Canvas
LogHelper.WriteLogToFile("PPT连接已断开", LogHelper.LogType.Event);
_singlePPTInkManager?.ClearAllStrokes();
_exitPPTModeAfterDisconnectTimer?.Stop();
_exitPPTModeAfterDisconnectTimer = new DispatcherTimer
{
Interval = TimeSpan.FromMilliseconds(ExitPPTModeAfterDisconnectDelayMs)
};
_exitPPTModeAfterDisconnectTimer.Tick += (s, e) =>
{
_exitPPTModeAfterDisconnectTimer?.Stop();
_exitPPTModeAfterDisconnectTimer = null;
if (_pptManager?.IsConnected != true)
{
_pptUIManager?.UpdateSlideShowStatus(false);
_pptUIManager?.UpdateSidebarExitButtons(false);
ResetPPTStateVariables();
_ = HandleManualSlideShowEnd();
}
};
_exitPPTModeAfterDisconnectTimer.Start();
_exitPPTModeAfterDisconnectTimer = null;
_pptUIManager?.UpdateSlideShowStatus(false);
_pptUIManager?.UpdateSidebarExitButtons(false);
ResetPPTStateVariables();
_ = HandleManualSlideShowEnd();
if (Settings.PowerPointSettings.UseRotPptLink)
_pptManager?.ReloadConnection();
}
});
}
@@ -921,14 +911,36 @@ namespace Ink_Canvas
string presentationName = null;
Presentation activePresentation = null;
if (wn?.View != null && wn.Presentation != null)
if (wn != null)
{
activePresentation = wn.Presentation;
currentSlide = wn.View.CurrentShowPosition;
totalSlides = activePresentation.Slides.Count;
presentationName = activePresentation.Name;
try
{
if (wn.View != null && wn.Presentation != null)
{
activePresentation = wn.Presentation;
currentSlide = wn.View.CurrentShowPosition;
totalSlides = activePresentation.Slides.Count;
presentationName = activePresentation.Name;
}
}
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;
}
}
else
if (activePresentation == null)
{
activePresentation = _pptManager?.GetCurrentActivePresentation() as Presentation;
currentSlide = _pptManager?.GetCurrentSlideNumber() ?? 0;
@@ -1134,10 +1146,41 @@ namespace Ink_Canvas
{
try
{
if (wn?.View == null || wn.Presentation == null) return;
int currentSlide = 0;
int totalSlides = 0;
int currentSlide = wn.View.CurrentShowPosition;
int totalSlides = wn.Presentation.Slides.Count;
if (wn != null)
{
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;