From cf4fe864ebd1087df830acf8dc5ccb27c22e8bd0 Mon Sep 17 00:00:00 2001
From: ltx <1006158920@qq.com>
Date: Wed, 28 Jan 2026 17:29:04 +0800
Subject: [PATCH] =?UTF-8?q?update=EF=BC=9A=E6=8B=96=E6=8B=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Wpf_AiSportsMicrospace/Common/SportOperate.cs | 10 +-
Wpf_AiSportsMicrospace/Views/Home.xaml.cs | 13 +-
.../Views/Setting/MultiJumpRope.xaml.cs | 132 ++++++++++++------
3 files changed, 103 insertions(+), 52 deletions(-)
diff --git a/Wpf_AiSportsMicrospace/Common/SportOperate.cs b/Wpf_AiSportsMicrospace/Common/SportOperate.cs
index 01354f5..09baee1 100644
--- a/Wpf_AiSportsMicrospace/Common/SportOperate.cs
+++ b/Wpf_AiSportsMicrospace/Common/SportOperate.cs
@@ -88,9 +88,15 @@ namespace Wpf_AiSportsMicrospace.Common
// 控制点
double cx = AppSettings.ControlPoint.X; // 已经是归一化 0~1
double cy = AppSettings.ControlPoint.Y;
+ double halfWidth = 0.08;
+ double halfHeight = 0.08;
+ if (AppSettings.AreaSize != null)
+ {
+ halfWidth = AppSettings.AreaSize.X;
+ halfHeight = AppSettings.AreaSize.Y;
+ }
- double halfWidth = AppSettings.AreaSize.X;
- double halfHeight = AppSettings.AreaSize.Y;
+
return xNorm >= (cx - halfWidth) && xNorm <= (cx + halfWidth) &&
yNorm >= (cy - halfHeight) && yNorm <= (cy + halfHeight);
diff --git a/Wpf_AiSportsMicrospace/Views/Home.xaml.cs b/Wpf_AiSportsMicrospace/Views/Home.xaml.cs
index 1dadfac..d95b495 100644
--- a/Wpf_AiSportsMicrospace/Views/Home.xaml.cs
+++ b/Wpf_AiSportsMicrospace/Views/Home.xaml.cs
@@ -11,6 +11,7 @@ using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Threading;
using Views.JumpRope;
+using Views.SquatFu;
using Wpf_AiSportsMicrospace.Common;
using Wpf_AiSportsMicrospace.Enum;
using Wpf_AiSportsMicrospace.MyUserControl;
@@ -24,8 +25,8 @@ namespace Wpf_AiSportsMicrospace
///
public partial class Home : UserControl
{
- public static Uri loadingImage = new Uri("/Resources/Img/Album/1.gif", UriKind.Relative);
- public static Uri countDownGif = new Uri("/Resources/Img/gif/time_3.gif", UriKind.Relative);
+ public static Uri loadingImage = new Uri("pack://application:,,,/Resources/Img/Album/1.gif");
+ public static Uri countDownGif = new Uri("pack://application:,,,/Resources/Img/gif/time_3.gif");
private int _adminClickCount = 0;
private readonly DispatcherTimer _resetTimer;
private Main _mainWin => Application.Current.MainWindow as Main;
@@ -158,12 +159,12 @@ namespace Wpf_AiSportsMicrospace
if (coverFlow.SelectedIndex == 0)
{
- var newPage = new GroupJumpRope();
- mainWin?.SwitchPageWithMaskAnimation(newPage, true);
+ //var newPage = new GroupJumpRope();
+ //mainWin?.SwitchPageWithMaskAnimation(newPage, true);
//var newPage = new BambooDragonfly();
- //var newPage = new WhackAMole();
- //mainWin?.SwitchPageWithMaskAnimation(newPage, true);
+ var newPage = new WhackAMole();
+ mainWin?.SwitchPageWithMaskAnimation(newPage, true);
}
else if (coverFlow.SelectedIndex == 1)
{
diff --git a/Wpf_AiSportsMicrospace/Views/Setting/MultiJumpRope.xaml.cs b/Wpf_AiSportsMicrospace/Views/Setting/MultiJumpRope.xaml.cs
index eb59010..82d5bac 100644
--- a/Wpf_AiSportsMicrospace/Views/Setting/MultiJumpRope.xaml.cs
+++ b/Wpf_AiSportsMicrospace/Views/Setting/MultiJumpRope.xaml.cs
@@ -32,6 +32,8 @@ namespace Wpf_AiSportsMicrospace.Views
private Ellipse _draggedEllipse;
private double _dragStartY;
private double _originalY;
+ private double _dragStartX;
+ private double _originalX;
///
/// 点位数据列表
@@ -404,7 +406,8 @@ namespace Wpf_AiSportsMicrospace.Views
},
Stroke = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#059669")),
StrokeThickness = 2,
- Cursor = Cursors.SizeNS // 垂直方向光标
+ //Cursor = Cursors.SizeNS // 垂直方向光标
+ Cursor = Cursors.SizeAll
};
// 绑定数据
@@ -437,6 +440,8 @@ namespace Wpf_AiSportsMicrospace.Views
var labelBorder = new Border
{
Child = label,
+ Name = $"label{point.Id}",
+
Width = PointRadiusX * 2,
Height = PointRadiusY * 2,
Background = Brushes.Transparent,
@@ -446,23 +451,40 @@ namespace Wpf_AiSportsMicrospace.Views
Canvas.SetTop(labelBorder, point.Y - PointRadiusY);
Canvas.SetZIndex(labelBorder, 11);
- // 创建 X 轴引导线(虚线)
- var guideLine = new Line
+ // 创建 X 轴引导线(垂直虚线)
+ var xGuideLine = new Line
{
+ Name = $"XGuideLine_{point.Id}",
X1 = point.X,
Y1 = 0,
X2 = point.X,
Y2 = MainCanvas.ActualHeight > 0 ? MainCanvas.ActualHeight : 800,
- Stroke = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#fff")),
- StrokeThickness = 2,
+ Stroke = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#6366F1")),
+ StrokeThickness = 1,
StrokeDashArray = new DoubleCollection { 5, 5 },
- Opacity = 0.8
+ Opacity = 0.4
};
- Canvas.SetZIndex(guideLine, 2);
+ Canvas.SetZIndex(xGuideLine, 2);
+
+ // 创建 Y 轴引导线(水平虚线)
+ var yGuideLine = new Line
+ {
+ Name = $"YGuideLine_{point.Id}",
+ X1 = 0,
+ Y1 = point.Y,
+ X2 = MainCanvas.ActualWidth > 0 ? MainCanvas.ActualWidth : 1920,
+ Y2 = point.Y,
+ Stroke = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#10B981")),
+ StrokeThickness = 1,
+ StrokeDashArray = new DoubleCollection { 5, 5 },
+ Opacity = 0.4
+ };
+ Canvas.SetZIndex(yGuideLine, 2);
// 添加到画布
MainCanvas.Children.Add(glow);
- MainCanvas.Children.Add(guideLine);
+ MainCanvas.Children.Add(xGuideLine);
+ MainCanvas.Children.Add(yGuideLine);
MainCanvas.Children.Add(ellipse);
MainCanvas.Children.Add(labelBorder);
}
@@ -641,12 +663,23 @@ namespace Wpf_AiSportsMicrospace.Views
{
_isDragging = true;
_draggedEllipse = sender as Ellipse;
- _dragStartY = e.GetPosition(MainCanvas).Y;
+ //_dragStartY = e.GetPosition(MainCanvas).Y;
+ //if (_draggedEllipse.Tag is JumpRopePoint point)
+ //{
+ // _originalY = point.Y;
+ //}
+
+ // 现在:同时捕获X和Y坐标
+ var currentPos = e.GetPosition(MainCanvas);
+ _dragStartX = currentPos.X;
+ _dragStartY = currentPos.Y;
if (_draggedEllipse.Tag is JumpRopePoint point)
{
+ _originalX = point.X;
_originalY = point.Y;
}
+
_draggedEllipse.CaptureMouse();
@@ -676,24 +709,29 @@ namespace Wpf_AiSportsMicrospace.Views
{
if (_isDragging && _draggedEllipse != null)
{
- var currentY = e.GetPosition(MainCanvas).Y;
- var deltaY = currentY - _dragStartY;
-
+ var currentPos = e.GetPosition(MainCanvas);
+ var deltaY = currentPos.Y - _dragStartY;
+ var deltaX = currentPos.X - _dragStartX;
if (_draggedEllipse.Tag is JumpRopePoint point)
{
- // 计算新位置(只允许 Y 轴移动)
+ // 同时计算X和Y轴移动
double newY = _originalY + deltaY;
+ double newX = _originalX + deltaX;
// 限制在画布范围内
double canvasHeight = MainCanvas.ActualHeight > 0 ? MainCanvas.ActualHeight : 1080;
newY = Math.Max(PointRadiusY, Math.Min(canvasHeight - PointRadiusY, newY));
+ double canvasWidth = MainCanvas.ActualWidth > 0 ? MainCanvas.ActualWidth : 1920;
+ newX = Math.Max(PointRadiusX, Math.Min(canvasWidth - PointRadiusX, newX));
+
// 更新点位数据
point.Y = newY;
+ point.X = newX;
// 更新椭圆位置
Canvas.SetTop(_draggedEllipse, newY - PointRadiusY);
-
+ Canvas.SetLeft(_draggedEllipse, newX - PointRadiusX);
// 更新光晕位置
UpdateGlowPosition(point);
@@ -701,7 +739,8 @@ namespace Wpf_AiSportsMicrospace.Views
UpdateLabelPosition(point);
// 更新引导线
- UpdateGuideLine(point, canvasHeight);
+
+ UpdateGuideLines(point, canvasWidth, canvasHeight);
// 更新连接线
UpdateConnectionLine();
@@ -713,7 +752,9 @@ namespace Wpf_AiSportsMicrospace.Views
RefreshPointsDataList();
// 重置拖动起始位置
- _dragStartY = currentY;
+ _dragStartX = currentPos.X;
+ _dragStartY = currentPos.Y;
+ _originalX = newX;
_originalY = newY;
}
}
@@ -763,23 +804,25 @@ namespace Wpf_AiSportsMicrospace.Views
///
private void UpdateGlowPosition(JumpRopePoint point)
{
+ // 找到对应的椭圆
var ellipse = MainCanvas.Children
.OfType()
.FirstOrDefault(e => e.Name == $"PointEllipse_{point.Id}");
if (ellipse != null)
{
- // 光晕尺寸
+ // 光晕宽度
double glowWidth = (PointRadiusX + 10) * 2;
double glowHeight = (PointRadiusY + 10) * 2;
double expectedLeft = point.X - glowWidth / 2;
- // 根据尺寸和位置查找光晕
+ // 查找光晕(根据尺寸和位置判断)
var glow = MainCanvas.Children
.OfType()
.FirstOrDefault(e =>
{
var left = Canvas.GetLeft(e);
+ var top = Canvas.GetTop(e);
return e.Width == glowWidth &&
e.Height == glowHeight &&
Math.Abs(left - expectedLeft) < 10;
@@ -787,7 +830,8 @@ namespace Wpf_AiSportsMicrospace.Views
if (glow != null)
{
- Canvas.SetTop(glow, point.Y - glow.Height / 2);
+ Canvas.SetLeft(glow, point.X - glowWidth / 2);
+ Canvas.SetTop(glow, point.Y - glowHeight / 2);
}
}
}
@@ -797,45 +841,45 @@ namespace Wpf_AiSportsMicrospace.Views
///
private void UpdateLabelPosition(JumpRopePoint point)
{
- var ellipse = MainCanvas.Children
- .OfType()
- .FirstOrDefault(e => e.Name == $"PointEllipse_{point.Id}");
-
- if (ellipse != null)
- {
- var labelBorder = MainCanvas.Children
- .OfType()
- .FirstOrDefault(b =>
- {
- var parent = b.Parent as Canvas;
- if (parent != null)
- {
- return Canvas.GetLeft(b) == Canvas.GetLeft(ellipse) &&
- Canvas.GetTop(b) == Canvas.GetTop(ellipse);
- }
- return false;
- });
+
+ var labelBorder = MainCanvas.Children.OfType().FirstOrDefault(e => e.Name == $"label{point.Id}");
if (labelBorder != null)
{
+ Canvas.SetLeft(labelBorder, point.X - PointRadiusX);
Canvas.SetTop(labelBorder, point.Y - PointRadiusY);
}
- }
}
///
/// 更新引导线
///
- private void UpdateGuideLine(JumpRopePoint point, double canvasHeight)
+ private void UpdateGuideLines(JumpRopePoint point, double canvasWidth, double canvasHeight)
{
- var guideLine = MainCanvas.Children
+ // 更新 X 轴引导线(垂直线)
+ var xGuideLine = MainCanvas.Children
.OfType()
- .FirstOrDefault(l => Math.Abs(l.X1 - point.X) < 5);
+ .FirstOrDefault(l => l.Name == $"XGuideLine_{point.Id}");
- if (guideLine != null)
+ if (xGuideLine != null)
{
- guideLine.Y1 = 0;
- guideLine.Y2 = canvasHeight;
+ xGuideLine.X1 = point.X;
+ xGuideLine.X2 = point.X;
+ xGuideLine.Y1 = 0;
+ xGuideLine.Y2 = canvasHeight;
+ }
+
+ // 更新 Y 轴引导线(水平线)
+ var yGuideLine = MainCanvas.Children
+ .OfType()
+ .FirstOrDefault(l => l.Name == $"YGuideLine_{point.Id}");
+
+ if (yGuideLine != null)
+ {
+ yGuideLine.X1 = 0;
+ yGuideLine.X2 = canvasWidth;
+ yGuideLine.Y1 = point.Y;
+ yGuideLine.Y2 = point.Y;
}
}