撤销至c760211

This commit is contained in:
CJK_mkp
2026-03-07 12:15:14 +08:00
committed by GitHub
parent 134c90508d
commit 4f99f11a33
+8 -73
View File
@@ -67,7 +67,6 @@ namespace Ink_Canvas.Helpers
private readonly object _lockObject = new object();
private bool _disposed;
private static bool IsPptBusyHResult(uint hr) => hr == 0x80010001 || hr == 0x8001010A;
private static bool IsNoActivePresentationOrWindowHResult(uint hr) => hr == 0x80048240;
#endregion
#region Constructor & Initialization
@@ -538,7 +537,7 @@ namespace Ink_Canvas.Helpers
}
}
private void UpdateCurrentPresentationInfo(bool preferSlideShowWindow = false, SlideShowWindow knownSlideShowWindow = null)
private void UpdateCurrentPresentationInfo()
{
object activePresentation = null;
object slideShowWindows = null;
@@ -554,7 +553,7 @@ namespace Ink_Canvas.Helpers
{
try
{
activePresentation = TryGetActivePresentation(knownSlideShowWindow);
activePresentation = PPTApplication.ActivePresentation;
if (activePresentation != null)
{
SafeReleaseComObject(CurrentPresentation, "CurrentPresentation");
@@ -584,22 +583,12 @@ namespace Ink_Canvas.Helpers
try
{
slideShowWindows = PPTApplication.SlideShowWindows;
var shouldUseSlideShowWindow = preferSlideShowWindow || IsInSlideShow;
if (shouldUseSlideShowWindow && slideShowWindows != null)
{
if (knownSlideShowWindow != null)
{
slideShowWindow = knownSlideShowWindow;
}
else
if (IsInSlideShow && slideShowWindows != null)
{
dynamic ssw = slideShowWindows;
if (ssw.Count > 0)
{
slideShowWindow = ssw[1];
}
}
if (slideShowWindow != null)
{
dynamic sswObj = slideShowWindow;
@@ -611,6 +600,7 @@ namespace Ink_Canvas.Helpers
}
}
}
}
else
{
activeWindow = PPTApplication.ActiveWindow;
@@ -643,7 +633,7 @@ namespace Ink_Canvas.Helpers
catch (COMException comEx)
{
var hr = (uint)comEx.HResult;
if (hr != 0x8001010E && hr != 0x80004005 && !IsNoActivePresentationOrWindowHResult(hr))
if (hr != 0x8001010E && hr != 0x80004005)
{
LogHelper.WriteLogToFile($"获取当前幻灯片失败: {comEx.Message}", LogHelper.LogType.Warning);
}
@@ -665,7 +655,7 @@ namespace Ink_Canvas.Helpers
catch (COMException comEx)
{
var hr = (uint)comEx.HResult;
if (hr == 0x8001010E || hr == 0x80004005 || IsNoActivePresentationOrWindowHResult(hr))
if (hr == 0x8001010E || hr == 0x80004005)
{
CurrentPresentation = null;
CurrentSlides = null;
@@ -708,61 +698,6 @@ namespace Ink_Canvas.Helpers
}
}
}
private object TryGetActivePresentation(SlideShowWindow knownSlideShowWindow)
{
try
{
return PPTApplication.ActivePresentation;
}
catch (COMException comEx)
{
var hr = (uint)comEx.HResult;
if (!IsNoActivePresentationOrWindowHResult(hr))
{
throw;
}
}
try
{
if (knownSlideShowWindow != null)
{
return knownSlideShowWindow.Presentation;
}
var slideShowWindows = PPTApplication.SlideShowWindows;
if (slideShowWindows == null)
{
return null;
}
dynamic ssw = slideShowWindows;
if (ssw.Count == 0)
{
return null;
}
var slideShowWindow = ssw[1];
if (slideShowWindow == null)
{
return null;
}
dynamic sswObj = slideShowWindow;
return sswObj.Presentation;
}
catch (COMException comEx)
{
var hr = (uint)comEx.HResult;
if (!IsNoActivePresentationOrWindowHResult(hr))
{
throw;
}
}
return null;
}
#endregion
#region Event Handlers
@@ -799,7 +734,7 @@ namespace Ink_Canvas.Helpers
_cachedIsInSlideShow = true;
try
{
UpdateCurrentPresentationInfo(preferSlideShowWindow: true, knownSlideShowWindow: wn);
UpdateCurrentPresentationInfo();
SlideShowBegin?.Invoke(wn);
}
catch (Exception ex)
@@ -812,7 +747,7 @@ namespace Ink_Canvas.Helpers
{
try
{
UpdateCurrentPresentationInfo(preferSlideShowWindow: true, knownSlideShowWindow: wn);
UpdateCurrentPresentationInfo();
SlideShowNextSlide?.Invoke(wn);
}
catch (Exception ex)