improve:ROT联动

This commit is contained in:
2026-02-14 15:01:39 +08:00
parent f722f3516b
commit 698478d826
4 changed files with 24 additions and 10 deletions
@@ -268,8 +268,6 @@ namespace Ink_Canvas.Helpers
if (currentPriority > 0) if (currentPriority > 0)
{ {
LogHelper.WriteLogToFile($"ROT扫描: {displayName}: priority={currentPriority}", LogHelper.LogType.Trace);
if (currentPriority > highestPriority) if (currentPriority > highestPriority)
{ {
highestPriority = currentPriority; highestPriority = currentPriority;
-7
View File
@@ -200,14 +200,12 @@ namespace Ink_Canvas.Helpers
if (_disposed) return; if (_disposed) return;
_unifiedRotTimer?.Start(); _unifiedRotTimer?.Start();
LogHelper.WriteLogToFile("[ROT] PPT 监控已启动", LogHelper.LogType.Trace);
} }
public void StopMonitoring() public void StopMonitoring()
{ {
_unifiedRotTimer?.Stop(); _unifiedRotTimer?.Stop();
DisconnectFromPPT(); DisconnectFromPPT();
LogHelper.WriteLogToFile("[ROT] PPT 监控已停止", LogHelper.LogType.Trace);
} }
public void ReloadConnection() public void ReloadConnection()
@@ -341,8 +339,6 @@ namespace Ink_Canvas.Helpers
app.SlideShowBegin += OnSlideShowBeginInternal; app.SlideShowBegin += OnSlideShowBeginInternal;
app.SlideShowNextSlide += OnSlideShowNextSlideInternal; app.SlideShowNextSlide += OnSlideShowNextSlideInternal;
app.SlideShowEnd += OnSlideShowEndInternal; app.SlideShowEnd += OnSlideShowEndInternal;
LogHelper.WriteLogToFile("[ROT] PPT 事件注册成功", LogHelper.LogType.Trace);
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -410,7 +406,6 @@ namespace Ink_Canvas.Helpers
catch (Exception ex) catch (Exception ex)
{ {
LogHelper.WriteLogToFile($"[ROT] 取消 PPT 事件注册异常: {ex}", LogHelper.LogType.Warning); LogHelper.WriteLogToFile($"[ROT] 取消 PPT 事件注册异常: {ex}", LogHelper.LogType.Warning);
LogHelper.WriteLogToFile(ex.ToString(), LogHelper.LogType.Trace);
} }
}, DispatcherPriority.Normal); }, DispatcherPriority.Normal);
} }
@@ -463,8 +458,6 @@ namespace Ink_Canvas.Helpers
_isModuleUnloading = false; _isModuleUnloading = false;
_unifiedRotTimer?.Start(); _unifiedRotTimer?.Start();
LogHelper.WriteLogToFile("[ROT] PPT 联动模块已重新进入联动状态(热重载)", LogHelper.LogType.Trace);
} }
catch (Exception ex) catch (Exception ex)
{ {
+1 -1
View File
@@ -1514,7 +1514,7 @@
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left"> <ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<Image Source="/Resources/Icons-png/Powerpoint.png" Margin="0,0,6,0" Width="28" <Image Source="/Resources/Icons-png/Powerpoint.png" Margin="0,0,6,0" Width="28"
Height="28" VerticalAlignment="Center" /> Height="28" VerticalAlignment="Center" />
<TextBlock Foreground="#fafafa" Text="使用 ROT 联动(需要重启)" VerticalAlignment="Center" <TextBlock Foreground="#fafafa" Text="使用 ROT 联动" VerticalAlignment="Center"
FontSize="14" Margin="0,0,16,0" /> FontSize="14" Margin="0,0,16,0" />
<ui:ToggleSwitch OnContent="" OffContent="" Name="ToggleSwitchUseRotPptLink" <ui:ToggleSwitch OnContent="" OffContent="" Name="ToggleSwitchUseRotPptLink"
IsOn="False" FontFamily="Microsoft YaHei UI" FontWeight="Bold" IsOn="False" FontFamily="Microsoft YaHei UI" FontWeight="Bold"
+23
View File
@@ -102,6 +102,9 @@ namespace Ink_Canvas
private int _pendingSlideIndex = -1; private int _pendingSlideIndex = -1;
private System.Timers.Timer _slideSwitchDebounceTimer; private System.Timers.Timer _slideSwitchDebounceTimer;
private const int SlideSwitchDebounceMs = 150; // 防抖延迟150毫秒 private const int SlideSwitchDebounceMs = 150; // 防抖延迟150毫秒
private DispatcherTimer _exitPPTModeAfterDisconnectTimer;
private const int ExitPPTModeAfterDisconnectDelayMs = 800;
#endregion #endregion
#region PPT Managers #region PPT Managers
@@ -573,12 +576,32 @@ namespace Ink_Canvas
if (isConnected) if (isConnected)
{ {
_exitPPTModeAfterDisconnectTimer?.Stop();
_exitPPTModeAfterDisconnectTimer = null;
LogHelper.WriteLogToFile("PPT连接已建立", LogHelper.LogType.Event); LogHelper.WriteLogToFile("PPT连接已建立", LogHelper.LogType.Event);
} }
else else
{ {
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 = null;
if (_pptManager?.IsConnected != true)
{
_pptUIManager?.UpdateSlideShowStatus(false);
_pptUIManager?.UpdateSidebarExitButtons(false);
ResetPPTStateVariables();
_ = HandleManualSlideShowEnd();
}
};
_exitPPTModeAfterDisconnectTimer.Start();
} }
}); });
} }