From 237ee74d378fd39f45b377c31d7aa1cbc438019f Mon Sep 17 00:00:00 2001 From: CJK_mkp <113243675+CJKmkp@users.noreply.github.com> Date: Mon, 1 Jun 2026 08:59:25 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"fix:=20PPT=E5=A2=9E=E5=BC=BA=E9=A2=84?= =?UTF-8?q?=E8=A7=88=E5=8A=9F=E8=83=BD=E5=90=AF=E7=94=A8=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E9=A1=B5=E7=A0=81=E4=B8=8D=E4=BC=9A=E6=89=93?= =?UTF-8?q?=E5=BC=80=E9=A2=84=E8=A7=88=E6=A1=86=EF=BC=8C=E5=B9=B6=E4=BC=9A?= =?UTF-8?q?=E4=BD=BF=E5=BE=97=E5=B7=A5=E5=85=B7=E6=A0=8F=E7=A7=BB=E5=8A=A8?= =?UTF-8?q?=E5=88=B0=E5=8F=B3=E4=B8=8B=E8=A7=92=EF=BC=9Bppt=E6=94=BE?= =?UTF-8?q?=E6=98=A0=E6=97=B6=E7=82=B9=E5=87=BB=E9=80=80=E5=87=BA=E6=94=BE?= =?UTF-8?q?=E6=98=A0=EF=BC=8C=E5=B7=A5=E5=85=B7=E6=A0=8F=E9=AB=98=E4=BA=AE?= =?UTF-8?q?=E5=9B=BE=E6=A0=87=E5=8F=98=E6=88=90=E4=BA=86=E9=BC=A0=E6=A0=87?= =?UTF-8?q?=E4=BD=86=E5=AE=9E=E9=99=85=E4=B8=8A=E8=BF=98=E6=98=AF=E6=89=B9?= =?UTF-8?q?=E6=B3=A8=E6=A8=A1=E5=BC=8F"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ink Canvas/Helpers/PPTUIManager.cs | 17 ++----- Ink Canvas/Helpers/ROTPPTManager.cs | 20 +++------ .../MainWindow_cs/MW_FloatingBarIcons.cs | 18 +++----- Ink Canvas/MainWindow_cs/MW_PPT.cs | 45 ++++++------------- 4 files changed, 30 insertions(+), 70 deletions(-) diff --git a/Ink Canvas/Helpers/PPTUIManager.cs b/Ink Canvas/Helpers/PPTUIManager.cs index 67cb5904..8ba7ebd7 100644 --- a/Ink Canvas/Helpers/PPTUIManager.cs +++ b/Ink Canvas/Helpers/PPTUIManager.cs @@ -76,15 +76,14 @@ public void UpdateConnectionStatus(bool isConnected) /// public void UpdateSlideShowStatus(bool isInSlideShow, int currentSlide = 0, int totalSlides = 0) { - void UpdateSlideShowStatusOnUi() + _dispatcher.InvokeAsync(() => { try { - _mainWindow.IsInPptPresentationMode = isInSlideShow; - if (isInSlideShow) { // Old UI removed: _mainWindow.BtnPPTSlideShow.Visibility = Visibility.Collapsed; + _mainWindow.IsInPptPresentationMode = true; _mainWindow.UpdateToolbarComponentVisibility(); // 同步页码到所有翻页条 + 兼容旧绑定的隐藏 placeholder @@ -116,6 +115,7 @@ void UpdateSlideShowStatusOnUi() else { // Old UI removed: _mainWindow.BtnPPTSlideShow.Visibility = Visibility.Visible; + _mainWindow.IsInPptPresentationMode = false; _mainWindow.UpdateToolbarComponentVisibility(); HideAllNavigationPanels(); _mainWindow.UpdatePPTTimeCapsuleVisibility(); @@ -142,16 +142,7 @@ void UpdateSlideShowStatusOnUi() { LogHelper.WriteLogToFile($"更新幻灯片放映状态UI失败: {ex}", LogHelper.LogType.Error); } - } - - if (_dispatcher.CheckAccess()) - { - UpdateSlideShowStatusOnUi(); - } - else - { - _dispatcher.Invoke(UpdateSlideShowStatusOnUi); - } + }); } /// diff --git a/Ink Canvas/Helpers/ROTPPTManager.cs b/Ink Canvas/Helpers/ROTPPTManager.cs index 7f981876..0028351d 100644 --- a/Ink Canvas/Helpers/ROTPPTManager.cs +++ b/Ink Canvas/Helpers/ROTPPTManager.cs @@ -1706,7 +1706,6 @@ public object GetCurrentActivePresentation() object slide = null; object activeWindow = null; object presentation = null; - object returnedPresentation = null; try { if (!IsConnected || PPTApplication == null) return null; @@ -1746,8 +1745,7 @@ public object GetCurrentActivePresentation() { dynamic slideObj = slide; presentation = slideObj.Parent; - returnedPresentation = presentation; - return returnedPresentation; + return presentation; } } } @@ -1762,13 +1760,11 @@ public object GetCurrentActivePresentation() presentation = aw.Presentation; if (presentation != null) { - returnedPresentation = presentation; - return returnedPresentation; + return presentation; } } - returnedPresentation = CurrentPresentation; - return returnedPresentation; + return CurrentPresentation; } catch (COMException comEx) { @@ -1782,20 +1778,16 @@ public object GetCurrentActivePresentation() return null; } LogHelper.WriteLogToFile($"获取当前活跃演示文稿失败: {comEx.Message}", LogHelper.LogType.Warning); - returnedPresentation = CurrentPresentation; - return returnedPresentation; + return CurrentPresentation; } catch (Exception ex) { LogHelper.WriteLogToFile($"获取当前活跃演示文稿失败: {ex}", LogHelper.LogType.Error); - returnedPresentation = CurrentPresentation; - return returnedPresentation; + return CurrentPresentation; } finally { - if (presentation != null && - !ReferenceEquals(presentation, CurrentPresentation) && - !ReferenceEquals(presentation, returnedPresentation)) + if (presentation != null && !ReferenceEquals(presentation, CurrentPresentation)) { SafeReleaseComObject(presentation); } diff --git a/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs b/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs index 4c672bc4..553c3eb6 100644 --- a/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs +++ b/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs @@ -3290,10 +3290,7 @@ private void RebuildCanvasOnTargetScreen(Screen targetScreen) /// /// 发送者 /// 路由事件参数 - internal void CursorIcon_Click(object sender, MouseButtonEventArgs e) - => CursorIcon_Click(sender, e, false); - - private async void CursorIcon_Click(object sender, MouseButtonEventArgs e, bool suppressFloatingBarMove) + internal async void CursorIcon_Click(object sender, MouseButtonEventArgs e) { if (lastBorderMouseDownObject is Panel panel) panel.Background = new SolidColorBrush(Colors.Transparent); @@ -3386,16 +3383,13 @@ private async void CursorIcon_Click(object sender, MouseButtonEventArgs e, bool if (!isFloatingBarFolded) { - HideSubPanels("cursor", !suppressFloatingBarMove); + HideSubPanels("cursor", true); await Task.Delay(50); - if (!suppressFloatingBarMove) - { - if (IsInPptPresentationMode) - ViewboxFloatingBarMarginAnimation(60); - else - ViewboxFloatingBarMarginAnimation(100, true); - } + if (IsInPptPresentationMode) + ViewboxFloatingBarMarginAnimation(60); + else + ViewboxFloatingBarMarginAnimation(100, true); } } diff --git a/Ink Canvas/MainWindow_cs/MW_PPT.cs b/Ink Canvas/MainWindow_cs/MW_PPT.cs index f4c66f1c..8152e1a5 100644 --- a/Ink Canvas/MainWindow_cs/MW_PPT.cs +++ b/Ink Canvas/MainWindow_cs/MW_PPT.cs @@ -1597,7 +1597,12 @@ await Application.Current.Dispatcher.InvokeAsync(() => // 注意:快捷调色盘的可见性现在完全由工具栏规则集管理 // 不需要手动设置,UpdateToolbarComponentVisibility 会处理好 - EnsureCursorModeAfterPptExit(); + if (GridTransparencyFakeBackground.Background != Brushes.Transparent) + BtnHideInkCanvas_Click(null, null); + SetCurrentToolMode(InkCanvasEditingMode.None); + + UpdateCurrentToolMode("cursor"); + SetFloatingBarHighlightPosition("cursor"); CheckMainWindowVisibility(); } @@ -2375,7 +2380,7 @@ private async Task OnPptNavBarPageClickAsync(Controls.PptNavBar bar) GridTransparencyFakeBackground.Opacity = 1; GridTransparencyFakeBackground.Background = new SolidColorBrush(StringToColor("#01FFFFFF")); SetTransparentNotHitThrough(); - CursorIcon_Click(null, null, true); + CursorIcon_Click(null, null); if (Settings.PowerPointSettings.EnablePPTButtonEnhancedPreview && bar != null) { @@ -2431,6 +2436,11 @@ private async Task OnPptNavBarPageClickAsync(Controls.PptNavBar bar) } } + if (!isFloatingBarFolded) + { + await Task.Delay(100); + ViewboxFloatingBarMarginAnimation(60); + } } catch (OperationCanceledException) { @@ -2986,7 +2996,8 @@ await Application.Current.Dispatcher.InvokeAsync(() => await HandleManualSlideShowEnd(); } - await Application.Current.Dispatcher.InvokeAsync(EnsureCursorModeAfterPptExit); + HideSubPanels("cursor"); + SetCurrentToolMode(InkCanvasEditingMode.None); await Task.Delay(150); if (!isFloatingBarFolded) @@ -3012,7 +3023,6 @@ await Application.Current.Dispatcher.InvokeAsync(() => _pptUIManager?.UpdateSlideShowStatus(false); _pptUIManager?.UpdateSidebarExitButtons(false); HideFloatingBarExitPPTBtn(); - EnsureCursorModeAfterPptExit(); CheckMainWindowVisibility(); }); @@ -3055,33 +3065,6 @@ private async Task HandleManualSlideShowEnd() } } - private void EnsureCursorModeAfterPptExit() - { - try - { - GridTransparencyFakeBackground.Opacity = 0; - GridTransparencyFakeBackground.Background = Brushes.Transparent; - SetTransparentHitThrough(); - - GridBackgroundCoverHolder.Visibility = Visibility.Collapsed; - inkCanvas.IsHitTestVisible = false; - inkCanvas.Visibility = Visibility.Visible; - inkCanvas.Select(new StrokeCollection()); - GridInkCanvasSelectionCover.Visibility = Visibility.Collapsed; - - RestoreFullScreenOnExitAnnotationMode(); - SetCurrentToolMode(InkCanvasEditingMode.None); - UpdateCurrentToolMode("cursor"); - UpdateToolbarComponentVisibility(); - HideSubPanels("cursor"); - SetFloatingBarHighlightPosition("cursor"); - } - catch (Exception ex) - { - LogHelper.WriteLogToFile($"同步PPT退出后的鼠标模式失败: {ex}", LogHelper.LogType.Error); - } - } - /// /// 处理PPT上一页控制按钮的鼠标按下事件 ///