Skip to content
17 changes: 13 additions & 4 deletions Ink Canvas/Helpers/PPTUIManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,15 @@ public void UpdateConnectionStatus(bool isConnected)
/// </summary>
public void UpdateSlideShowStatus(bool isInSlideShow, int currentSlide = 0, int totalSlides = 0)
{
_dispatcher.InvokeAsync(() =>
void UpdateSlideShowStatusOnUi()
{
try
{
_mainWindow.IsInPptPresentationMode = isInSlideShow;

if (isInSlideShow)
{
// Old UI removed: _mainWindow.BtnPPTSlideShow.Visibility = Visibility.Collapsed;
_mainWindow.IsInPptPresentationMode = true;
_mainWindow.UpdateToolbarComponentVisibility();

// 同步页码到所有翻页条 + 兼容旧绑定的隐藏 placeholder
Expand Down Expand Up @@ -115,7 +116,6 @@ public void UpdateSlideShowStatus(bool isInSlideShow, int currentSlide = 0, int
else
{
// Old UI removed: _mainWindow.BtnPPTSlideShow.Visibility = Visibility.Visible;
_mainWindow.IsInPptPresentationMode = false;
_mainWindow.UpdateToolbarComponentVisibility();
HideAllNavigationPanels();
_mainWindow.UpdatePPTTimeCapsuleVisibility();
Expand All @@ -142,7 +142,16 @@ public void UpdateSlideShowStatus(bool isInSlideShow, int currentSlide = 0, int
{
LogHelper.WriteLogToFile($"更新幻灯片放映状态UI失败: {ex}", LogHelper.LogType.Error);
}
});
}

if (_dispatcher.CheckAccess())
{
UpdateSlideShowStatusOnUi();
}
else
{
_dispatcher.Invoke(UpdateSlideShowStatusOnUi);
}
}

/// <summary>
Expand Down
20 changes: 14 additions & 6 deletions Ink Canvas/Helpers/ROTPPTManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1706,6 +1706,7 @@ public object GetCurrentActivePresentation()
object slide = null;
object activeWindow = null;
object presentation = null;
object returnedPresentation = null;
try
{
if (!IsConnected || PPTApplication == null) return null;
Expand Down Expand Up @@ -1745,7 +1746,8 @@ public object GetCurrentActivePresentation()
{
dynamic slideObj = slide;
presentation = slideObj.Parent;
return presentation;
returnedPresentation = presentation;
return returnedPresentation;
}
}
}
Expand All @@ -1760,11 +1762,13 @@ public object GetCurrentActivePresentation()
presentation = aw.Presentation;
if (presentation != null)
{
return presentation;
returnedPresentation = presentation;
return returnedPresentation;
}
}

return CurrentPresentation;
returnedPresentation = CurrentPresentation;
return returnedPresentation;
}
catch (COMException comEx)
{
Expand All @@ -1778,16 +1782,20 @@ public object GetCurrentActivePresentation()
return null;
}
LogHelper.WriteLogToFile($"获取当前活跃演示文稿失败: {comEx.Message}", LogHelper.LogType.Warning);
return CurrentPresentation;
returnedPresentation = CurrentPresentation;
return returnedPresentation;
}
catch (Exception ex)
{
LogHelper.WriteLogToFile($"获取当前活跃演示文稿失败: {ex}", LogHelper.LogType.Error);
return CurrentPresentation;
returnedPresentation = CurrentPresentation;
return returnedPresentation;
}
finally
{
if (presentation != null && !ReferenceEquals(presentation, CurrentPresentation))
if (presentation != null &&
!ReferenceEquals(presentation, CurrentPresentation) &&
!ReferenceEquals(presentation, returnedPresentation))
{
SafeReleaseComObject(presentation);
}
Expand Down
18 changes: 12 additions & 6 deletions Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3290,7 +3290,10 @@ private void RebuildCanvasOnTargetScreen(Screen targetScreen)
/// </summary>
/// <param name="sender">发送者</param>
/// <param name="e">路由事件参数</param>
internal async void CursorIcon_Click(object sender, MouseButtonEventArgs e)
internal void CursorIcon_Click(object sender, MouseButtonEventArgs e)
=> CursorIcon_Click(sender, e, false);

private async void CursorIcon_Click(object sender, MouseButtonEventArgs e, bool suppressFloatingBarMove)
{
if (lastBorderMouseDownObject is Panel panel)
panel.Background = new SolidColorBrush(Colors.Transparent);
Expand Down Expand Up @@ -3383,13 +3386,16 @@ internal async void CursorIcon_Click(object sender, MouseButtonEventArgs e)

if (!isFloatingBarFolded)
{
HideSubPanels("cursor", true);
HideSubPanels("cursor", !suppressFloatingBarMove);
await Task.Delay(50);

if (IsInPptPresentationMode)
ViewboxFloatingBarMarginAnimation(60);
else
ViewboxFloatingBarMarginAnimation(100, true);
if (!suppressFloatingBarMove)
{
if (IsInPptPresentationMode)
ViewboxFloatingBarMarginAnimation(60);
else
ViewboxFloatingBarMarginAnimation(100, true);
}
}
}

Expand Down
45 changes: 31 additions & 14 deletions Ink Canvas/MainWindow_cs/MW_PPT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1597,12 +1597,7 @@ await Application.Current.Dispatcher.InvokeAsync(() =>
// 注意:快捷调色盘的可见性现在完全由工具栏规则集管理
// 不需要手动设置,UpdateToolbarComponentVisibility 会处理好

if (GridTransparencyFakeBackground.Background != Brushes.Transparent)
BtnHideInkCanvas_Click(null, null);
SetCurrentToolMode(InkCanvasEditingMode.None);

UpdateCurrentToolMode("cursor");
SetFloatingBarHighlightPosition("cursor");
EnsureCursorModeAfterPptExit();

CheckMainWindowVisibility();
}
Expand Down Expand Up @@ -2380,7 +2375,7 @@ private async Task OnPptNavBarPageClickAsync(Controls.PptNavBar bar)
GridTransparencyFakeBackground.Opacity = 1;
GridTransparencyFakeBackground.Background = new SolidColorBrush(StringToColor("#01FFFFFF"));
SetTransparentNotHitThrough();
CursorIcon_Click(null, null);
CursorIcon_Click(null, null, true);

if (Settings.PowerPointSettings.EnablePPTButtonEnhancedPreview && bar != null)
{
Expand Down Expand Up @@ -2436,11 +2431,6 @@ private async Task OnPptNavBarPageClickAsync(Controls.PptNavBar bar)
}
}

if (!isFloatingBarFolded)
{
await Task.Delay(100);
ViewboxFloatingBarMarginAnimation(60);
}
}
catch (OperationCanceledException)
{
Expand Down Expand Up @@ -2996,8 +2986,7 @@ await Application.Current.Dispatcher.InvokeAsync(() =>
await HandleManualSlideShowEnd();
}

HideSubPanels("cursor");
SetCurrentToolMode(InkCanvasEditingMode.None);
await Application.Current.Dispatcher.InvokeAsync(EnsureCursorModeAfterPptExit);

await Task.Delay(150);
if (!isFloatingBarFolded)
Expand All @@ -3023,6 +3012,7 @@ await Application.Current.Dispatcher.InvokeAsync(() =>
_pptUIManager?.UpdateSlideShowStatus(false);
_pptUIManager?.UpdateSidebarExitButtons(false);
HideFloatingBarExitPPTBtn();
EnsureCursorModeAfterPptExit();
CheckMainWindowVisibility();
});

Expand Down Expand Up @@ -3065,6 +3055,33 @@ 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);
}
}

/// <summary>
/// 处理PPT上一页控制按钮的鼠标按下事件
/// </summary>
Expand Down
Loading