improve:截图及浮动栏

This commit is contained in:
2025-08-31 09:59:49 +08:00
parent 9bb00489fe
commit fa7f3d44e4
5 changed files with 50 additions and 22 deletions
+5 -1
View File
@@ -100,7 +100,11 @@ namespace Ink_Canvas
(workingArea.Width - floatingBarWidth) / 2, (workingArea.Width - floatingBarWidth) / 2,
workingArea.Bottom - 60 - workingArea.Top, workingArea.Bottom - 60 - workingArea.Top,
-2000, -200); -2000, -200);
ViewboxFloatingBarMarginAnimation(100, true); // 新增:只在屏幕模式下初始化浮动栏动画
if (currentMode == 0)
{
ViewboxFloatingBarMarginAnimation(100, true);
}
try try
{ {
+8 -4
View File
@@ -269,10 +269,14 @@ namespace Ink_Canvas
if (dopsc[3] == '2' && !isDisplayingOrHidingBlackboard) AnimationsHelper.ShowWithFadeIn(RightSidePanelForPPTNavigation); if (dopsc[3] == '2' && !isDisplayingOrHidingBlackboard) AnimationsHelper.ShowWithFadeIn(RightSidePanelForPPTNavigation);
} }
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) // 新增:只在屏幕模式下显示浮动栏
ViewboxFloatingBarMarginAnimation(60); if (currentMode == 0)
else {
ViewboxFloatingBarMarginAnimation(100, true); if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible)
ViewboxFloatingBarMarginAnimation(60);
else
ViewboxFloatingBarMarginAnimation(100, true);
}
SidePannelMarginAnimation(-50, !unfoldFloatingBarByUser); SidePannelMarginAnimation(-50, !unfoldFloatingBarByUser);
}); });
@@ -1298,6 +1298,12 @@ namespace Ink_Canvas
public async void ViewboxFloatingBarMarginAnimation(int MarginFromEdge, public async void ViewboxFloatingBarMarginAnimation(int MarginFromEdge,
bool PosXCaculatedWithTaskbarHeight = false) bool PosXCaculatedWithTaskbarHeight = false)
{ {
// 新增:在白板模式下不执行浮动栏动画
if (currentMode == 1)
{
return;
}
if (MarginFromEdge == 60) MarginFromEdge = 55; if (MarginFromEdge == 60) MarginFromEdge = 55;
await Dispatcher.InvokeAsync(() => await Dispatcher.InvokeAsync(() =>
{ {
@@ -1417,6 +1423,12 @@ namespace Ink_Canvas
public async void PureViewboxFloatingBarMarginAnimationInDesktopMode() public async void PureViewboxFloatingBarMarginAnimationInDesktopMode()
{ {
// 新增:在白板模式下不执行浮动栏动画
if (currentMode == 1)
{
return;
}
await Dispatcher.InvokeAsync(() => await Dispatcher.InvokeAsync(() =>
{ {
ViewboxFloatingBar.Visibility = Visibility.Visible; ViewboxFloatingBar.Visibility = Visibility.Visible;
@@ -1493,6 +1505,12 @@ namespace Ink_Canvas
public async void PureViewboxFloatingBarMarginAnimationInPPTMode() public async void PureViewboxFloatingBarMarginAnimationInPPTMode()
{ {
// 新增:在白板模式下不执行浮动栏动画
if (currentMode == 1)
{
return;
}
await Dispatcher.InvokeAsync(() => await Dispatcher.InvokeAsync(() =>
{ {
ViewboxFloatingBar.Visibility = Visibility.Visible; ViewboxFloatingBar.Visibility = Visibility.Visible;
+12 -9
View File
@@ -197,11 +197,14 @@ namespace Ink_Canvas
val > 0.5 && val < 1.25 ? val : val <= 0.5 ? 0.5 : val >= 1.25 ? 1.25 : 1; val > 0.5 && val < 1.25 ? val : val <= 0.5 ? 0.5 : val >= 1.25 ? 1.25 : 1;
ViewboxFloatingBarScaleTransform.ScaleY = ViewboxFloatingBarScaleTransform.ScaleY =
val > 0.5 && val < 1.25 ? val : val <= 0.5 ? 0.5 : val >= 1.25 ? 1.25 : 1; val > 0.5 && val < 1.25 ? val : val <= 0.5 ? 0.5 : val >= 1.25 ? 1.25 : 1;
// auto align // auto align - 新增:只在屏幕模式下重新计算浮动栏位置
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) if (currentMode == 0)
ViewboxFloatingBarMarginAnimation(60); {
else if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible)
ViewboxFloatingBarMarginAnimation(100, true); ViewboxFloatingBarMarginAnimation(60);
else
ViewboxFloatingBarMarginAnimation(100, true);
}
} }
private void ViewboxFloatingBarOpacityValueSlider_ValueChanged(object sender, RoutedEventArgs e) private void ViewboxFloatingBarOpacityValueSlider_ValueChanged(object sender, RoutedEventArgs e)
@@ -2687,14 +2690,14 @@ namespace Ink_Canvas
await Task.Delay(100); await Task.Delay(100);
// 获取当前选中的模式并重新设置高光位置 // 获取当前选中的模式并重新设置高光位置
string currentMode = GetCurrentSelectedMode(); string selectedToolMode = GetCurrentSelectedMode();
if (!string.IsNullOrEmpty(currentMode)) if (!string.IsNullOrEmpty(selectedToolMode))
{ {
SetFloatingBarHighlightPosition(currentMode); SetFloatingBarHighlightPosition(selectedToolMode);
} }
// 重新计算浮动栏位置,因为按钮可见性变化会影响浮动栏宽度 // 重新计算浮动栏位置,因为按钮可见性变化会影响浮动栏宽度
if (!isFloatingBarFolded) if (!isFloatingBarFolded && currentMode == 0) // 新增:只在屏幕模式下重新计算浮动栏位置
{ {
if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible) if (BtnPPTSlideShowEnd.Visibility == Visibility.Visible)
{ {
@@ -282,15 +282,14 @@ namespace Ink_Canvas
if (_isFreehandMode) if (_isFreehandMode)
{ {
// 自由绘制模式:一笔完成,直接截图 // 自由绘制模式:一笔完成,直接截图
if (_freehandPoints.Count > 3) // 确保有足够的点 if (_freehandPoints.Count > 1) // 只要有点就可以截图
{ {
// 创建路径的副本,避免修改原始列表 // 创建路径的副本,避免修改原始列表
var pathPoints = new List<Point>(_freehandPoints); var pathPoints = new List<Point>(_freehandPoints);
// 确保路径闭合(如果最后一个点不是起始点,则添加起始点) // 简化路径处理,不强制闭合
if (pathPoints.Count > 0 && // 如果路径没有闭合,自动添加起始点
(Math.Abs(pathPoints[pathPoints.Count - 1].X - _startPoint.X) > 15 || if (pathPoints.Count > 0)
Math.Abs(pathPoints[pathPoints.Count - 1].Y - _startPoint.Y) > 15))
{ {
pathPoints.Add(_startPoint); pathPoints.Add(_startPoint);
} }
@@ -305,7 +304,7 @@ namespace Ink_Canvas
var bounds = CalculatePathBounds(optimizedPath); var bounds = CalculatePathBounds(optimizedPath);
// 确保边界矩形有效 // 确保边界矩形有效
if (bounds.Width > 1 && bounds.Height > 1) if (bounds.Width >= 0 && bounds.Height >= 0)
{ {
var dpiScale = GetDpiScale(); var dpiScale = GetDpiScale();
var virtualScreen = SystemInformation.VirtualScreen; var virtualScreen = SystemInformation.VirtualScreen;
@@ -654,8 +653,8 @@ namespace Ink_Canvas
// 计算当前点到前后两点连线的距离 // 计算当前点到前后两点连线的距离
var distance = DistanceToLine(current, prev, next); var distance = DistanceToLine(current, prev, next);
// 如果距离大于阈值,保留这个点 // 进一步降低阈值,保留更多点,确保路径质量
if (distance > 2.0) if (distance > 0.1) // 从0.5降低到0.1
{ {
optimized.Add(current); optimized.Add(current);
} }