From 52d95173d7e5b0627edceaafb52801d10b88b414 Mon Sep 17 00:00:00 2001
From: CJKmkp <2564608840@qq.com>
Date: Sat, 6 Sep 2025 14:18:09 +0800
Subject: [PATCH] =?UTF-8?q?improve:PPT=E6=A8=A1=E5=9D=97=E5=8F=8A=E6=B5=AE?=
=?UTF-8?q?=E5=8A=A8=E6=A0=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Ink Canvas/MainWindow_cs/MW_AutoFold.cs | 29 ++++-
.../MainWindow_cs/MW_FloatingBarIcons.cs | 109 ++++++++++++++++--
Ink Canvas/MainWindow_cs/MW_Settings.cs | 12 +-
Ink Canvas/Windows/CountdownTimerWindow.xaml | 15 ++-
Ink Canvas/Windows/OperatingGuideWindow.xaml | 4 +-
5 files changed, 150 insertions(+), 19 deletions(-)
diff --git a/Ink Canvas/MainWindow_cs/MW_AutoFold.cs b/Ink Canvas/MainWindow_cs/MW_AutoFold.cs
index 76b3bf37..d17e5745 100644
--- a/Ink Canvas/MainWindow_cs/MW_AutoFold.cs
+++ b/Ink Canvas/MainWindow_cs/MW_AutoFold.cs
@@ -259,7 +259,11 @@ namespace Ink_Canvas
PenIcon_Click(null, null);
}
- if (StackPanelPPTControls.Visibility == Visibility.Visible)
+ // 只有在PPT放映模式下且页数有效时才显示翻页按钮
+ if (StackPanelPPTControls.Visibility == Visibility.Visible &&
+ BtnPPTSlideShowEnd.Visibility == Visibility.Visible &&
+ PPTManager?.IsInSlideShow == true &&
+ PPTManager?.SlidesCount > 0)
{
var dops = Settings.PowerPointSettings.PPTButtonsDisplayOption.ToString();
var dopsc = dops.ToCharArray();
@@ -267,11 +271,34 @@ namespace Ink_Canvas
if (dopsc[1] == '2' && !isDisplayingOrHidingBlackboard) AnimationsHelper.ShowWithFadeIn(RightBottomPanelForPPTNavigation);
if (dopsc[2] == '2' && !isDisplayingOrHidingBlackboard) AnimationsHelper.ShowWithFadeIn(LeftSidePanelForPPTNavigation);
if (dopsc[3] == '2' && !isDisplayingOrHidingBlackboard) AnimationsHelper.ShowWithFadeIn(RightSidePanelForPPTNavigation);
+ LogHelper.WriteLogToFile($"从收纳模式恢复时显示PPT翻页按钮 - 放映状态: {PPTManager?.IsInSlideShow}, 页数: {PPTManager?.SlidesCount}", LogHelper.LogType.Trace);
+ }
+ else
+ {
+ // 如果条件不满足,确保隐藏翻页按钮
+ LeftBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed;
+ RightBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed;
+ LeftSidePanelForPPTNavigation.Visibility = Visibility.Collapsed;
+ RightSidePanelForPPTNavigation.Visibility = Visibility.Collapsed;
+ LogHelper.WriteLogToFile($"从收纳模式恢复时隐藏PPT翻页按钮 - 放映状态: {PPTManager?.IsInSlideShow}, 页数: {PPTManager?.SlidesCount}", LogHelper.LogType.Trace);
}
// 新增:只在屏幕模式下显示浮动栏
if (currentMode == 0)
{
+ // 强制更新布局以确保ActualWidth正确
+ ViewboxFloatingBar.UpdateLayout();
+
+ // 等待一小段时间让布局完全更新
+ await Task.Delay(50);
+
+ // 再次强制更新布局
+ ViewboxFloatingBar.UpdateLayout();
+
+ // 强制重新测量和排列
+ ViewboxFloatingBar.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
+ ViewboxFloatingBar.Arrange(new Rect(ViewboxFloatingBar.DesiredSize));
+
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible)
ViewboxFloatingBarMarginAnimation(60);
else
diff --git a/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs b/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs
index 80b400cb..4922d32a 100644
--- a/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs
+++ b/Ink Canvas/MainWindow_cs/MW_FloatingBarIcons.cs
@@ -652,10 +652,11 @@ namespace Ink_Canvas
//关闭黑板
HideSubPanelsImmediately();
- // 只有在PPT放映模式下才显示翻页按钮
+ // 只有在PPT放映模式下且页数有效时才显示翻页按钮
if (StackPanelPPTControls.Visibility == Visibility.Visible &&
BtnPPTSlideShowEnd.Visibility == Visibility.Visible &&
- PPTManager?.IsInSlideShow == true)
+ PPTManager?.IsInSlideShow == true &&
+ PPTManager?.SlidesCount > 0)
{
var dops = Settings.PowerPointSettings.PPTButtonsDisplayOption.ToString();
var dopsc = dops.ToCharArray();
@@ -663,24 +664,38 @@ namespace Ink_Canvas
if (dopsc[1] == '2' && !isDisplayingOrHidingBlackboard) AnimationsHelper.ShowWithFadeIn(RightBottomPanelForPPTNavigation);
if (dopsc[2] == '2' && !isDisplayingOrHidingBlackboard) AnimationsHelper.ShowWithFadeIn(LeftSidePanelForPPTNavigation);
if (dopsc[3] == '2' && !isDisplayingOrHidingBlackboard) AnimationsHelper.ShowWithFadeIn(RightSidePanelForPPTNavigation);
+ LogHelper.WriteLogToFile($"显示PPT翻页按钮 - 放映状态: {PPTManager?.IsInSlideShow}, 页数: {PPTManager?.SlidesCount}", LogHelper.LogType.Trace);
}
else
{
- // 如果不在放映模式,隐藏所有翻页按钮
+ // 如果不在放映模式或页数无效,隐藏所有翻页按钮
LeftBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed;
RightBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed;
LeftSidePanelForPPTNavigation.Visibility = Visibility.Collapsed;
RightSidePanelForPPTNavigation.Visibility = Visibility.Collapsed;
+ LogHelper.WriteLogToFile($"隐藏PPT翻页按钮 - 放映状态: {PPTManager?.IsInSlideShow}, 页数: {PPTManager?.SlidesCount}", LogHelper.LogType.Trace);
}
// 修复PPT放映时点击白板按钮后翻页按钮不显示的问题
- // 只有在确实在放映模式下才强制显示翻页按钮
- if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible && PPTManager?.IsInSlideShow == true)
+ // 只有在确实在放映模式下且页数有效时才强制显示翻页按钮
+ if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible &&
+ PPTManager?.IsInSlideShow == true &&
+ PPTManager?.SlidesCount > 0)
{
// 强制显示PPT翻页按钮
LeftBottomPanelForPPTNavigation.Visibility = Visibility.Visible;
RightBottomPanelForPPTNavigation.Visibility = Visibility.Visible;
LeftSidePanelForPPTNavigation.Visibility = Visibility.Visible;
RightSidePanelForPPTNavigation.Visibility = Visibility.Visible;
+ LogHelper.WriteLogToFile($"强制显示PPT翻页按钮 - 放映状态: {PPTManager?.IsInSlideShow}, 页数: {PPTManager?.SlidesCount}", LogHelper.LogType.Trace);
+ }
+ else
+ {
+ // 如果条件不满足,确保隐藏翻页按钮
+ LeftBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed;
+ RightBottomPanelForPPTNavigation.Visibility = Visibility.Collapsed;
+ LeftSidePanelForPPTNavigation.Visibility = Visibility.Collapsed;
+ RightSidePanelForPPTNavigation.Visibility = Visibility.Collapsed;
+ LogHelper.WriteLogToFile($"隐藏PPT翻页按钮 - 放映状态: {PPTManager?.IsInSlideShow}, 页数: {PPTManager?.SlidesCount}", LogHelper.LogType.Trace);
}
if (Settings.Automation.IsAutoSaveStrokesAtClear &&
@@ -1383,9 +1398,33 @@ namespace Ink_Canvas
var toolbarHeight = ForegroundWindowInfo.GetTaskbarHeight(screen, dpiScaleY);
// 计算浮动栏位置,考虑快捷调色盘的显示状态
- // 确保获取到正确的浮动栏宽度,如果ActualWidth为0则使用DesiredSize
- double baseWidth = ViewboxFloatingBar.ActualWidth > 0 ? ViewboxFloatingBar.ActualWidth : ViewboxFloatingBar.DesiredSize.Width;
+ // 使用更可靠的方法获取浮动栏宽度
+ double baseWidth = ViewboxFloatingBar.ActualWidth;
+
+ // 如果ActualWidth为0,尝试使用DesiredSize
+ if (baseWidth <= 0)
+ {
+ baseWidth = ViewboxFloatingBar.DesiredSize.Width;
+ }
+
+ // 如果仍然为0,使用RenderSize
+ if (baseWidth <= 0)
+ {
+ baseWidth = ViewboxFloatingBar.RenderSize.Width;
+ }
+
+ // 如果所有方法都失败,使用一个基于内容的估算值
+ if (baseWidth <= 0)
+ {
+ // 根据浮动栏内容估算宽度
+ baseWidth = 200; // 最小宽度
+ LogHelper.WriteLogToFile($"浮动栏宽度无法获取,使用估算值: {baseWidth}");
+ }
+
double floatingBarWidth = baseWidth * ViewboxFloatingBarScaleTransform.ScaleX;
+
+ // 添加调试日志
+ LogHelper.WriteLogToFile($"浮动栏居中计算 - ActualWidth: {ViewboxFloatingBar.ActualWidth}, DesiredSize.Width: {ViewboxFloatingBar.DesiredSize.Width}, RenderSize.Width: {ViewboxFloatingBar.RenderSize.Width}, baseWidth: {baseWidth}, ScaleX: {ViewboxFloatingBarScaleTransform.ScaleX}, floatingBarWidth: {floatingBarWidth}, screenWidth: {screenWidth}");
// 如果快捷调色盘显示,确保有足够空间
if ((QuickColorPalettePanel != null && QuickColorPalettePanel.Visibility == Visibility.Visible) ||
@@ -1506,9 +1545,33 @@ namespace Ink_Canvas
var toolbarHeight = ForegroundWindowInfo.GetTaskbarHeight(screen, dpiScaleY);
// 计算浮动栏位置,考虑快捷调色盘的显示状态
- // 确保获取到正确的浮动栏宽度,如果ActualWidth为0则使用DesiredSize
- double baseWidth = ViewboxFloatingBar.ActualWidth > 0 ? ViewboxFloatingBar.ActualWidth : ViewboxFloatingBar.DesiredSize.Width;
+ // 使用更可靠的方法获取浮动栏宽度
+ double baseWidth = ViewboxFloatingBar.ActualWidth;
+
+ // 如果ActualWidth为0,尝试使用DesiredSize
+ if (baseWidth <= 0)
+ {
+ baseWidth = ViewboxFloatingBar.DesiredSize.Width;
+ }
+
+ // 如果仍然为0,使用RenderSize
+ if (baseWidth <= 0)
+ {
+ baseWidth = ViewboxFloatingBar.RenderSize.Width;
+ }
+
+ // 如果所有方法都失败,使用一个基于内容的估算值
+ if (baseWidth <= 0)
+ {
+ // 根据浮动栏内容估算宽度
+ baseWidth = 200; // 最小宽度
+ LogHelper.WriteLogToFile($"浮动栏宽度无法获取,使用估算值: {baseWidth}");
+ }
+
double floatingBarWidth = baseWidth * ViewboxFloatingBarScaleTransform.ScaleX;
+
+ // 添加调试日志
+ LogHelper.WriteLogToFile($"浮动栏居中计算 - ActualWidth: {ViewboxFloatingBar.ActualWidth}, DesiredSize.Width: {ViewboxFloatingBar.DesiredSize.Width}, RenderSize.Width: {ViewboxFloatingBar.RenderSize.Width}, baseWidth: {baseWidth}, ScaleX: {ViewboxFloatingBarScaleTransform.ScaleX}, floatingBarWidth: {floatingBarWidth}, screenWidth: {screenWidth}");
// 如果快捷调色盘显示,确保有足够空间
if ((QuickColorPalettePanel != null && QuickColorPalettePanel.Visibility == Visibility.Visible) ||
@@ -1590,9 +1653,33 @@ namespace Ink_Canvas
var toolbarHeight = ForegroundWindowInfo.GetTaskbarHeight(screen, dpiScaleY);
// 计算浮动栏位置,考虑快捷调色盘的显示状态
- // 确保获取到正确的浮动栏宽度,如果ActualWidth为0则使用DesiredSize
- double baseWidth = ViewboxFloatingBar.ActualWidth > 0 ? ViewboxFloatingBar.ActualWidth : ViewboxFloatingBar.DesiredSize.Width;
+ // 使用更可靠的方法获取浮动栏宽度
+ double baseWidth = ViewboxFloatingBar.ActualWidth;
+
+ // 如果ActualWidth为0,尝试使用DesiredSize
+ if (baseWidth <= 0)
+ {
+ baseWidth = ViewboxFloatingBar.DesiredSize.Width;
+ }
+
+ // 如果仍然为0,使用RenderSize
+ if (baseWidth <= 0)
+ {
+ baseWidth = ViewboxFloatingBar.RenderSize.Width;
+ }
+
+ // 如果所有方法都失败,使用一个基于内容的估算值
+ if (baseWidth <= 0)
+ {
+ // 根据浮动栏内容估算宽度
+ baseWidth = 200; // 最小宽度
+ LogHelper.WriteLogToFile($"浮动栏宽度无法获取,使用估算值: {baseWidth}");
+ }
+
double floatingBarWidth = baseWidth * ViewboxFloatingBarScaleTransform.ScaleX;
+
+ // 添加调试日志
+ LogHelper.WriteLogToFile($"浮动栏居中计算 - ActualWidth: {ViewboxFloatingBar.ActualWidth}, DesiredSize.Width: {ViewboxFloatingBar.DesiredSize.Width}, RenderSize.Width: {ViewboxFloatingBar.RenderSize.Width}, baseWidth: {baseWidth}, ScaleX: {ViewboxFloatingBarScaleTransform.ScaleX}, floatingBarWidth: {floatingBarWidth}, screenWidth: {screenWidth}");
// 如果快捷调色盘显示,确保有足够空间
if ((QuickColorPalettePanel != null && QuickColorPalettePanel.Visibility == Visibility.Visible) ||
diff --git a/Ink Canvas/MainWindow_cs/MW_Settings.cs b/Ink Canvas/MainWindow_cs/MW_Settings.cs
index eafd870b..07277670 100644
--- a/Ink Canvas/MainWindow_cs/MW_Settings.cs
+++ b/Ink Canvas/MainWindow_cs/MW_Settings.cs
@@ -199,11 +199,21 @@ namespace Ink_Canvas
val > 0.5 && val < 1.25 ? val : val <= 0.5 ? 0.5 : val >= 1.25 ? 1.25 : 1;
// 等待UI更新后再重新计算浮动栏位置,确保居中计算准确
- Dispatcher.BeginInvoke(new Action(() =>
+ Dispatcher.BeginInvoke(new Action(async () =>
{
// 强制更新布局以确保ActualWidth正确
ViewboxFloatingBar.UpdateLayout();
+ // 等待一小段时间让布局完全更新
+ await Task.Delay(100);
+
+ // 再次强制更新布局
+ ViewboxFloatingBar.UpdateLayout();
+
+ // 强制重新测量和排列
+ ViewboxFloatingBar.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
+ ViewboxFloatingBar.Arrange(new Rect(ViewboxFloatingBar.DesiredSize));
+
// auto align - 新增:只在屏幕模式下重新计算浮动栏位置
if (currentMode == 0)
{
diff --git a/Ink Canvas/Windows/CountdownTimerWindow.xaml b/Ink Canvas/Windows/CountdownTimerWindow.xaml
index 37372edb..a361e609 100644
--- a/Ink Canvas/Windows/CountdownTimerWindow.xaml
+++ b/Ink Canvas/Windows/CountdownTimerWindow.xaml
@@ -12,7 +12,14 @@
Title="Ink Canvas 画板 - 计时器" Height="700" Width="1100">
-
+
+
+
+
+
@@ -179,7 +186,7 @@
-
+
-
+
-
+
diff --git a/Ink Canvas/Windows/OperatingGuideWindow.xaml b/Ink Canvas/Windows/OperatingGuideWindow.xaml
index fc5325d6..8d706606 100644
--- a/Ink Canvas/Windows/OperatingGuideWindow.xaml
+++ b/Ink Canvas/Windows/OperatingGuideWindow.xaml
@@ -80,7 +80,7 @@
-
+
-
+