优化代码
This commit is contained in:
@@ -354,9 +354,6 @@ namespace Ink_Canvas.Helpers
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogToFile("快捷键注册功能已经启用,重新加载快捷键设置");
|
||||
// 即使已经启用,也要重新加载快捷键设置以确保快捷键正常工作
|
||||
LoadHotkeysFromSettings();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -79,7 +79,6 @@ namespace Ink_Canvas.Helpers
|
||||
// 设置为当前活跃的演示文稿
|
||||
_currentActivePresentationId = presentationId;
|
||||
|
||||
LogHelper.WriteLogToFile($"已初始化多PPT墨迹管理: {presentation.Name}, 幻灯片数量: {presentation.Slides.Count}", LogHelper.LogType.Event);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -405,7 +404,6 @@ namespace Ink_Canvas.Helpers
|
||||
if (manager != null)
|
||||
{
|
||||
manager.ResetLockState();
|
||||
LogHelper.WriteLogToFile("已重置当前演示文稿的墨迹锁定状态", LogHelper.LogType.Trace);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -94,7 +94,6 @@ namespace Ink_Canvas.Helpers
|
||||
LoadSavedStrokes();
|
||||
}
|
||||
|
||||
LogHelper.WriteLogToFile($"已初始化演示文稿墨迹管理: {presentation.Name}, 幻灯片数量: {slideCount}", LogHelper.LogType.Trace);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -192,7 +191,6 @@ namespace Ink_Canvas.Helpers
|
||||
{
|
||||
_memoryStreams[slideIndex].Position = 0;
|
||||
var strokes = new StrokeCollection(_memoryStreams[slideIndex]);
|
||||
LogHelper.WriteLogToFile($"已加载第{slideIndex}页墨迹,笔画数量: {strokes.Count}", LogHelper.LogType.Trace);
|
||||
return strokes;
|
||||
}
|
||||
}
|
||||
@@ -236,7 +234,6 @@ namespace Ink_Canvas.Helpers
|
||||
|
||||
if (newStrokes.Count > 0)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"已切换到第{slideIndex}页,加载墨迹数量: {newStrokes.Count}", LogHelper.LogType.Trace);
|
||||
}
|
||||
|
||||
return newStrokes;
|
||||
@@ -328,7 +325,6 @@ namespace Ink_Canvas.Helpers
|
||||
}
|
||||
}
|
||||
|
||||
LogHelper.WriteLogToFile($"已保存{savedCount}页墨迹到文件", LogHelper.LogType.Event);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -375,7 +371,6 @@ namespace Ink_Canvas.Helpers
|
||||
}
|
||||
}
|
||||
|
||||
LogHelper.WriteLogToFile($"已从文件加载{loadedCount}页墨迹", LogHelper.LogType.Event);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -450,7 +445,6 @@ namespace Ink_Canvas.Helpers
|
||||
_lockedSlideIndex = -1;
|
||||
_lastSwitchTime = DateTime.MinValue;
|
||||
_lastSwitchSlideIndex = -1;
|
||||
LogHelper.WriteLogToFile("已重置墨迹锁定状态", LogHelper.LogType.Trace);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -249,7 +249,6 @@ namespace Ink_Canvas.Helpers
|
||||
|
||||
if (!currentSlideShowState)
|
||||
{
|
||||
LogHelper.WriteLogToFile("检测到PPT放映已结束", LogHelper.LogType.Trace);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -629,7 +628,6 @@ namespace Ink_Canvas.Helpers
|
||||
try
|
||||
{
|
||||
PresentationClose?.Invoke(pres);
|
||||
LogHelper.WriteLogToFile($"演示文稿已关闭: {pres?.Name}", LogHelper.LogType.Event);
|
||||
|
||||
// 重新启动连接检查
|
||||
_connectionCheckTimer?.Start();
|
||||
@@ -646,7 +644,6 @@ namespace Ink_Canvas.Helpers
|
||||
{
|
||||
UpdateCurrentPresentationInfo();
|
||||
SlideShowBegin?.Invoke(wn);
|
||||
LogHelper.WriteLogToFile("幻灯片放映开始", LogHelper.LogType.Event);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -678,7 +675,6 @@ namespace Ink_Canvas.Helpers
|
||||
}
|
||||
|
||||
SlideShowEnd?.Invoke(pres);
|
||||
LogHelper.WriteLogToFile("幻灯片放映结束", LogHelper.LogType.Event);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -1139,7 +1135,7 @@ namespace Ink_Canvas.Helpers
|
||||
_wpsProcessCheckTimer.Dispose();
|
||||
}
|
||||
|
||||
// 优化:增加检查间隔到2秒,减少性能开销
|
||||
// 增加检查间隔到2秒,减少性能开销
|
||||
_wpsProcessCheckTimer = new Timer(2000);
|
||||
_wpsProcessCheckTimer.Elapsed += OnWpsProcessCheckTimerElapsed;
|
||||
_wpsProcessCheckTimer.Start();
|
||||
@@ -1173,7 +1169,7 @@ namespace Ink_Canvas.Helpers
|
||||
}
|
||||
|
||||
|
||||
// 检查前台WPS窗口是否存在(优化版)
|
||||
// 检查前台WPS窗口是否存在
|
||||
bool isForegroundWpsWindowActive = IsForegroundWpsWindowStillActiveOptimized();
|
||||
|
||||
if (isForegroundWpsWindowActive)
|
||||
@@ -1185,7 +1181,7 @@ namespace Ink_Canvas.Helpers
|
||||
return;
|
||||
}
|
||||
|
||||
// 优化:多重验证确保准确性
|
||||
// 多重验证确保准确性
|
||||
if (!PerformMultipleWpsWindowChecks())
|
||||
{
|
||||
LogHelper.WriteLogToFile("多重验证显示WPS窗口仍然存在,跳过查杀", LogHelper.LogType.Trace);
|
||||
@@ -1206,7 +1202,7 @@ namespace Ink_Canvas.Helpers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 优化版的前台WPS窗口检测,减少性能开销
|
||||
/// 前台WPS窗口检测
|
||||
/// </summary>
|
||||
private bool IsForegroundWpsWindowStillActiveOptimized()
|
||||
{
|
||||
@@ -1232,7 +1228,7 @@ namespace Ink_Canvas.Helpers
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"优化版WPS窗口检测失败: {ex}", LogHelper.LogType.Error);
|
||||
LogHelper.WriteLogToFile($"WPS窗口检测失败: {ex}", LogHelper.LogType.Error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +155,6 @@ namespace Ink_Canvas.Helpers
|
||||
{
|
||||
// 如果不在放映模式,隐藏所有导航面板
|
||||
HideAllNavigationPanels();
|
||||
LogHelper.WriteLogToFile("PPT放映状态变化:隐藏导航面板", LogHelper.LogType.Trace);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -602,7 +602,6 @@ namespace Ink_Canvas
|
||||
|
||||
if (!isInSlideShow)
|
||||
{
|
||||
LogHelper.WriteLogToFile("PPT放映状态变化:退出放映模式", LogHelper.LogType.Trace);
|
||||
}
|
||||
|
||||
// 检查主窗口可见性(用于仅PPT模式)
|
||||
@@ -636,7 +635,6 @@ namespace Ink_Canvas
|
||||
if (activePresentation != null)
|
||||
{
|
||||
_multiPPTInkManager?.SwitchToPresentation(activePresentation);
|
||||
LogHelper.WriteLogToFile($"已切换到活跃演示文稿: {activePresentation.Name}", LogHelper.LogType.Trace);
|
||||
}
|
||||
|
||||
// 处理跳转到首页或上次播放位置
|
||||
@@ -1039,8 +1037,6 @@ namespace Ink_Canvas
|
||||
|
||||
// 重置锁定状态
|
||||
_multiPPTInkManager?.ResetCurrentPresentationLockState();
|
||||
|
||||
LogHelper.WriteLogToFile($"已重置墨迹管理器锁定状态", LogHelper.LogType.Trace);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -1193,7 +1189,6 @@ namespace Ink_Canvas
|
||||
|
||||
Settings.PowerPointSettings.EnablePowerPointEnhancement = ToggleSwitchPowerPointEnhancement.IsOn;
|
||||
|
||||
// 与WPS支持互斥
|
||||
if (Settings.PowerPointSettings.EnablePowerPointEnhancement)
|
||||
{
|
||||
Settings.PowerPointSettings.IsSupportWPS = false;
|
||||
@@ -1225,7 +1220,6 @@ namespace Ink_Canvas
|
||||
|
||||
Settings.PowerPointSettings.IsSupportWPS = ToggleSwitchSupportWPS.IsOn;
|
||||
|
||||
// 与PowerPoint联动增强互斥
|
||||
if (Settings.PowerPointSettings.IsSupportWPS)
|
||||
{
|
||||
Settings.PowerPointSettings.EnablePowerPointEnhancement = false;
|
||||
@@ -1272,7 +1266,6 @@ namespace Ink_Canvas
|
||||
if (_pptManager?.TryNavigatePrevious() == true)
|
||||
{
|
||||
// 翻页成功,等待事件处理墨迹切换
|
||||
LogHelper.WriteLogToFile("成功切换到上一页", LogHelper.LogType.Trace);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1466,7 +1459,6 @@ namespace Ink_Canvas
|
||||
// 结束放映
|
||||
if (_pptManager?.TryEndSlideShow() == true)
|
||||
{
|
||||
LogHelper.WriteLogToFile("成功结束幻灯片放映", LogHelper.LogType.Event);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user