From 0e8c41fb611a89a6c22646f953db73a770d1d1d7 Mon Sep 17 00:00:00 2001 From: tanglong <842690096@qq.com> Date: Fri, 17 Oct 2025 09:55:29 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E6=BB=9A=E5=8A=A8=E7=9A=84=E7=82=B9?= =?UTF-8?q?=EF=BC=8C=E5=88=9D=E5=A7=8B=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Wpf_AiSportsMicrospace/Dto/MusicJumpRopeContext.cs | 4 ++++ .../Views/JumpRope/GroupJumpRope.xaml.cs | 6 +++--- .../Views/JumpRope/MusicJumpRope.xaml.cs | 13 +++++++------ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Wpf_AiSportsMicrospace/Dto/MusicJumpRopeContext.cs b/Wpf_AiSportsMicrospace/Dto/MusicJumpRopeContext.cs index 3f01bd6..6190c8b 100644 --- a/Wpf_AiSportsMicrospace/Dto/MusicJumpRopeContext.cs +++ b/Wpf_AiSportsMicrospace/Dto/MusicJumpRopeContext.cs @@ -50,6 +50,8 @@ namespace Dto } }; + public Dictionary> MusicBeatsDic; + public MusicJumpRopeContext() { CirclePositions = new List<(double XNorm, double YNorm)> @@ -58,6 +60,8 @@ namespace Dto (0.50, 0.88), }; + MusicBeatsDic = MusicBeats["1"].GroupBy(b => (int)Math.Ceiling(b) - 1).ToDictionary(g => g.Key, g => g.ToList()); + UserList = new List(); UserNumberList = new List(); Sports = new List(); diff --git a/Wpf_AiSportsMicrospace/Views/JumpRope/GroupJumpRope.xaml.cs b/Wpf_AiSportsMicrospace/Views/JumpRope/GroupJumpRope.xaml.cs index 8a549d0..d2f8def 100644 --- a/Wpf_AiSportsMicrospace/Views/JumpRope/GroupJumpRope.xaml.cs +++ b/Wpf_AiSportsMicrospace/Views/JumpRope/GroupJumpRope.xaml.cs @@ -216,7 +216,7 @@ namespace Wpf_AiSportsMicrospace.Views } } - private int _currentCountdown = 3; + private double _currentCountdown = 3600; private DateTime _lastUpdateTime = DateTime.Now; private void StartCountdown(int start = 3) { @@ -233,10 +233,10 @@ namespace Wpf_AiSportsMicrospace.Views private void UpdateCountdown() { - if ((DateTime.Now - _lastUpdateTime).TotalSeconds >= 1) + if ((DateTime.Now - _lastUpdateTime).TotalMilliseconds >= 600) { _lastUpdateTime = DateTime.Now; - _currentCountdown--; + _currentCountdown -= 600; if (_currentCountdown > 0) { diff --git a/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml.cs b/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml.cs index 937cf72..b5b9310 100644 --- a/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml.cs +++ b/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml.cs @@ -234,10 +234,11 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope private DateTime _lastUpdateTime = DateTime.Now; private void StartCountdown(int start = 3) { - _currentCountdown = start; - countdownText.Text = _currentCountdown.ToString(); - countdownGrid.Visibility = Visibility.Visible; - _lastUpdateTime = DateTime.Now; + _mainWin.ShowCountDownAnimation(); + //_currentCountdown = start; + //countdownText.Text = _currentCountdown.ToString(); + //countdownGrid.Visibility = Visibility.Visible; + //_lastUpdateTime = DateTime.Now; Utils.PlayBackgroundMusic("countdown_3.mp3", false); } @@ -276,7 +277,7 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope // 播放背景音乐(循环) Utils.PlayBackgroundMusic("1.MP3", true); - //StartBeatScrollTimer(); + StartBeatScrollTimer(); for (int i = seconds; i >= 0; i--) { @@ -685,7 +686,6 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope var beats = _musicJumpRopeContext.MusicBeats["1"]; double lastX = 0; double scale = 300; // 间隔放大系数,可调 - for (int i = 0; i < beats.Count; i++) { double interval = i == 0 ? beats[0] : beats[i] - beats[i - 1]; @@ -730,6 +730,7 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope beatCanvasRight.Children.Add(rightEllipse); } beatCanvasRight.Width = totalWidth; + } private DispatcherTimer _beatScrollTimer; private double totalTime = 108.455; // 音乐总时长 From ec46f3799c00bd9dbe5e9f207875ef32d316acc9 Mon Sep 17 00:00:00 2001 From: tanglong <842690096@qq.com> Date: Fri, 17 Oct 2025 14:18:01 +0800 Subject: [PATCH 2/8] fff --- Wpf_AiSportsMicrospace/App.xaml | 4 + .../Converter/DotColorConverter.cs | 24 +++ .../MyUserControl/BeatScrollDots.xaml | 29 +++ .../MyUserControl/BeatScrollDots.xaml.cs | 136 +++++++++++++ .../Views/JumpRope/MusicJumpRope.xaml | 22 +-- .../Views/JumpRope/MusicJumpRope.xaml.cs | 178 ++++++------------ 6 files changed, 257 insertions(+), 136 deletions(-) create mode 100644 Wpf_AiSportsMicrospace/Converter/DotColorConverter.cs create mode 100644 Wpf_AiSportsMicrospace/MyUserControl/BeatScrollDots.xaml create mode 100644 Wpf_AiSportsMicrospace/MyUserControl/BeatScrollDots.xaml.cs diff --git a/Wpf_AiSportsMicrospace/App.xaml b/Wpf_AiSportsMicrospace/App.xaml index 7854626..61792fe 100644 --- a/Wpf_AiSportsMicrospace/App.xaml +++ b/Wpf_AiSportsMicrospace/App.xaml @@ -2,6 +2,8 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:Wpf_AiSportsMicrospace.Views" + xmlns:conv="clr-namespace:Wpf_AiSportsMicrospace.Converter" + StartupUri="Views/Main.xaml"> @@ -10,6 +12,8 @@ + + diff --git a/Wpf_AiSportsMicrospace/Converter/DotColorConverter.cs b/Wpf_AiSportsMicrospace/Converter/DotColorConverter.cs new file mode 100644 index 0000000..509040c --- /dev/null +++ b/Wpf_AiSportsMicrospace/Converter/DotColorConverter.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Text; +using System.Windows; +using System.Windows.Data; +using System.Windows.Media; +using Wpf_AiSportsMicrospace.MyUserControl; + +namespace Wpf_AiSportsMicrospace.Converter +{ + public class DotColorConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value is bool b && b) + return Brushes.Red; + return Brushes.Green; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + => throw new NotImplementedException(); + } +} diff --git a/Wpf_AiSportsMicrospace/MyUserControl/BeatScrollDots.xaml b/Wpf_AiSportsMicrospace/MyUserControl/BeatScrollDots.xaml new file mode 100644 index 0000000..08a15d6 --- /dev/null +++ b/Wpf_AiSportsMicrospace/MyUserControl/BeatScrollDots.xaml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/Wpf_AiSportsMicrospace/MyUserControl/BeatScrollDots.xaml.cs b/Wpf_AiSportsMicrospace/MyUserControl/BeatScrollDots.xaml.cs new file mode 100644 index 0000000..6111311 --- /dev/null +++ b/Wpf_AiSportsMicrospace/MyUserControl/BeatScrollDots.xaml.cs @@ -0,0 +1,136 @@ +using Emgu.CV.Flann; +using HandyControl.Controls; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Animation; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Wpf_AiSportsMicrospace.MyUserControl +{ + public partial class BeatScrollDots : UserControl + { + public ObservableCollection Dots { get; set; } = new ObservableCollection(); + + public BeatScrollDots() + { + InitializeComponent(); + DataContext = this; + } + + public int DotCount + { + get => (int)GetValue(DotCountProperty); + set => SetValue(DotCountProperty, value); + } + + public static readonly DependencyProperty DotCountProperty = + DependencyProperty.Register(nameof(DotCount), typeof(int), typeof(BeatScrollDots), + new PropertyMetadata(0, OnDotCountChanged)); + + private static void OnDotCountChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d is BeatScrollDots ctrl) + ctrl.GenerateDots(); + } + + private void GenerateDots() + { + Dots.Clear(); + for (int i = 0; i < DotCount; i++) + Dots.Add(new DotItem { IsSelected = false }); + } + + public void SetSelected(int index, bool selected) + { + if (index >= 0 && index < Dots.Count) + Dots[index].IsSelected = selected; + } + + public Thickness DotSpacing + { + get => (Thickness)GetValue(DotSpacingProperty); + set => SetValue(DotSpacingProperty, value); + } + + public static readonly DependencyProperty DotSpacingProperty = + DependencyProperty.Register(nameof(DotSpacing), typeof(Thickness), typeof(BeatScrollDots), new PropertyMetadata(new Thickness(5, 0, 5, 0))); + + public void ScrollToDotCenter(int index, bool mirror = false) + { + if (scrollViewer == null || Dots.Count == 0) return; + + double step = 20 + DotSpacing.Left + DotSpacing.Right; + double totalWidth = Dots.Count * step; + double dotCenter = index * step + step / 2; + + double targetOffset = !mirror + ? dotCenter - scrollViewer.ActualWidth / 2 + : totalWidth - dotCenter - scrollViewer.ActualWidth / 2; + + targetOffset = System.Math.Max(0, System.Math.Min(targetOffset, scrollViewer.ScrollableWidth)); + scrollViewer.ScrollToHorizontalOffset(targetOffset); + } + + public void UpdateSpacingForCount(int count) + { + if (count <= 0) count = 1; + double spacing = (ActualWidth / count) - 20; + if (spacing < 2) spacing = 2; + DotSpacing = new Thickness(spacing / 2, 0, spacing / 2, 0); + } + public Dictionary> MusicBeatsDic + { + get => (Dictionary>)GetValue(MusicBeatsDicProperty); + set => SetValue(MusicBeatsDicProperty, value); + } + + public static readonly DependencyProperty MusicBeatsDicProperty = + DependencyProperty.Register(nameof(MusicBeatsDic), typeof(Dictionary>), typeof(BeatScrollDots), + new PropertyMetadata(null, OnMusicBeatsDicChanged)); + + private static void OnMusicBeatsDicChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d is BeatScrollDots ctrl) + { + // 可选:根据第一个 key 初始化 DotCount + if (ctrl.MusicBeatsDic != null && ctrl.MusicBeatsDic.Any()) + { + int firstKey = ctrl.MusicBeatsDic.Keys.Min(); + ctrl.DotCount = ctrl.MusicBeatsDic[firstKey].Count; + ctrl.UpdateSpacingForCount(ctrl.DotCount); + } + } + } + } + + public class DotItem : INotifyPropertyChanged + { + private bool _isSelected; + + public bool IsSelected + { + get => _isSelected; + set + { + if (_isSelected != value) + { + _isSelected = value; + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsSelected))); + } + } + } + + public event PropertyChangedEventHandler PropertyChanged; + } +} \ No newline at end of file diff --git a/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml b/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml index 52d3bf4..94a9065 100644 --- a/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml +++ b/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml @@ -35,28 +35,18 @@ TextAlignment="Center" /> - + - + - - - - + + - - - - + + diff --git a/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml.cs b/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml.cs index b5b9310..fc21ab8 100644 --- a/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml.cs +++ b/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml.cs @@ -6,6 +6,7 @@ using System.Collections.ObjectModel; using System.Diagnostics; using System.IO; using System.Text; +using System.Text.RegularExpressions; using System.Windows; using System.Windows.Controls; using System.Windows.Data; @@ -37,7 +38,7 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope private readonly object _updateLock = new object(); private readonly Dictionary _jumpStatus = new Dictionary(); private MusicJumpRopeContext _musicJumpRopeContext; - + public Dictionary> _musicBeatsDic; private GameState _currentGameState = GameState.NotStarted; List RankingItemList = new(); @@ -70,7 +71,7 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope // 容忍时间(节拍误差) public double _beatTolerance = 0.15; // ±150ms - + private int _totalDots = 0; // 滚动显示的节拍点集合 public ObservableCollection BeatDisplayLeft { get; set; } = new(); public ObservableCollection BeatDisplayRight { get; set; } = new(); @@ -81,9 +82,17 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope Loaded += UserControl_Loaded; Unloaded += UserControl_Unloaded; _musicJumpRopeContext = new MusicJumpRopeContext(); + _musicBeatsDic = _musicJumpRopeContext.MusicBeatsDic; - // 初始化节拍点数据 - InitBeatDots(); + _totalDots = _musicJumpRopeContext.MusicBeats["1"].Count(); + + // 左控件 + LeftBeats.DotCount = _totalDots; + LeftBeats.MusicBeatsDic = _musicBeatsDic; + + // 右控件 + RightBeats.DotCount = _totalDots; + RightBeats.MusicBeatsDic = _musicBeatsDic; } private async void UserControl_Loaded(object sender, RoutedEventArgs e) @@ -234,11 +243,10 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope private DateTime _lastUpdateTime = DateTime.Now; private void StartCountdown(int start = 3) { - _mainWin.ShowCountDownAnimation(); - //_currentCountdown = start; - //countdownText.Text = _currentCountdown.ToString(); - //countdownGrid.Visibility = Visibility.Visible; - //_lastUpdateTime = DateTime.Now; + _currentCountdown = start; + countdownText.Text = _currentCountdown.ToString(); + countdownGrid.Visibility = Visibility.Visible; + _lastUpdateTime = DateTime.Now; Utils.PlayBackgroundMusic("countdown_3.mp3", false); } @@ -492,30 +500,29 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope userItem.ImageState = "2"; var currentTime = Utils.GetMusicCurrentTime(); - var beats = _musicJumpRopeContext.MusicBeats["1"]; + int currentSecond = (int)Math.Floor(currentTime); - for (int j = 0; j < beats.Count; j++) + // 判断是否命中节拍 + var beats = _musicJumpRopeContext.MusicBeats["1"]; + bool hit = beats.Any(b => Math.Abs(b - currentTime) <= _beatTolerance); + if (hit) { - int indexCopy2 = j; // 复制一份当前循环索引 - if (Math.Abs(beats[indexCopy2] - currentTime) <= _beatTolerance) - { - _musicJumpRopeContext.UserBeatSyncList[indexCopy]++; - Application.Current.Dispatcher.BeginInvoke(() => - { - if (indexCopy == 0) - { - ((Ellipse)beatCanvasLeft.Children[indexCopy2]).Fill = Brushes.Red; - } - else - { - ((Ellipse)beatCanvasRight.Children[indexCopy2]).Fill = Brushes.Red; - } - _musicBeatTextBlock[indexCopy].Text = $"卡点 x{_musicJumpRopeContext.UserBeatSyncList[indexCopy]}"; - }); - } + _musicJumpRopeContext.UserBeatSyncList[indexCopy]++; + _musicBeatTextBlock[indexCopy].Text = $"卡点 x{_musicJumpRopeContext.UserBeatSyncList[indexCopy]}"; + + if (indexCopy == 0) + LeftBeats.SetSelected(currentSecond, true); + else + RightBeats.SetSelected(currentSecond, true); + + //Application.Current.Dispatcher.BeginInvoke(() => + //{ + // if (indexCopy == 0) + // LeftBeats.SetSelected(currentSecond, true); + // else + // RightBeats.SetSelected(currentSecond, true); + //}); } - // 滚动条跳跃到当前点附近 - UpdateBeatScrollSudden(currentTime); }; sport.Start(); @@ -523,30 +530,6 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope } } - private void UpdateBeatScrollSudden(double currentTime) - { - int maxVisible = 5; // 最多显示 5 个点 - var beats = _musicJumpRopeContext.MusicBeats["1"]; - - // 找到最近的点索引 - int currentIndex = beats.FindIndex(bt => bt >= currentTime); - if (currentIndex == -1) currentIndex = beats.Count - 1; - - // 取前后最多 5 个点 - int startIndex = Math.Max(0, currentIndex - maxVisible / 2); - int endIndex = Math.Min(beats.Count - 1, startIndex + maxVisible - 1); - - // 左侧 ScrollViewer - double leftCenterX = BeatDisplayLeft[currentIndex].X - BeatScrollLeft.ViewportWidth / 2; - leftCenterX = Math.Max(0, Math.Min(leftCenterX, beatCanvasLeft.Width - BeatScrollLeft.ViewportWidth)); - BeatScrollLeft.ScrollToHorizontalOffset(leftCenterX); - - // 右侧 ScrollViewer - double rightCenterX = BeatDisplayRight[currentIndex].X - BeatScrollRight.ViewportWidth / 2; - rightCenterX = Math.Max(0, Math.Min(rightCenterX, beatCanvasRight.Width - BeatScrollRight.ViewportWidth)); - BeatScrollRight.ScrollToHorizontalOffset(rightCenterX); - } - private void UpdateCircleCounts(List humans) { double radiusNormX = 0.07; @@ -673,82 +656,37 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope return userItem; } - private List leftDots = new(); - private List rightDots = new(); - public double BeatPanelWidth { get; set; } - private void InitBeatDots() - { - BeatDisplayLeft.Clear(); - BeatDisplayRight.Clear(); - beatCanvasLeft.Children.Clear(); - beatCanvasRight.Children.Clear(); - var beats = _musicJumpRopeContext.MusicBeats["1"]; - double lastX = 0; - double scale = 300; // 间隔放大系数,可调 - for (int i = 0; i < beats.Count; i++) - { - double interval = i == 0 ? beats[0] : beats[i] - beats[i - 1]; - lastX += interval * scale; - } - double totalWidth = lastX + 50; - - // 左侧点 - lastX = 0; - for (int i = 0; i < beats.Count; i++) - { - double interval = i == 0 ? beats[0] : beats[i] - beats[i - 1]; - double xPos = lastX + interval * scale; - lastX = xPos; - - var leftItem = new BeatItem { X = xPos, Color = Brushes.Black }; - BeatDisplayLeft.Add(leftItem); - - var leftEllipse = new Ellipse { Width = 8, Height = 8, Fill = leftItem.Color }; - Canvas.SetLeft(leftEllipse, leftItem.X); - Canvas.SetTop(leftEllipse, 40); - beatCanvasLeft.Children.Add(leftEllipse); - } - beatCanvasLeft.Width = totalWidth; - - // 右侧点(倒序排列,但间隔顺序保持一致) - lastX = 0; - for (int i = 0; i < beats.Count; i++) - { - double interval = i == 0 ? beats[0] : beats[i] - beats[i - 1]; - double xPos = lastX + interval * scale; - lastX = xPos; - - // 倒序显示 - double rightX = totalWidth - xPos; - var rightItem = new BeatItem { X = rightX, Color = Brushes.Black }; - BeatDisplayRight.Add(rightItem); - - var rightEllipse = new Ellipse { Width = 8, Height = 8, Fill = rightItem.Color }; - Canvas.SetLeft(rightEllipse, rightItem.X); - Canvas.SetTop(rightEllipse, 40); - beatCanvasRight.Children.Add(rightEllipse); - } - beatCanvasRight.Width = totalWidth; - - } private DispatcherTimer _beatScrollTimer; private double totalTime = 108.455; // 音乐总时长 + private int _lastSecond = -1; // 上一次已经处理的秒数 private void StartBeatScrollTimer() { - if (_beatScrollTimer != null) _beatScrollTimer.Stop(); - _beatScrollTimer = new DispatcherTimer(); - _beatScrollTimer.Interval = TimeSpan.FromMilliseconds(1000); + _beatScrollTimer.Interval = TimeSpan.FromMilliseconds(500); // 每秒一次 + + int lastSecond = -1; + _beatScrollTimer.Tick += (s, e) => { double currentTime = Utils.GetMusicCurrentTime(); + int currentSecond = (int)Math.Floor(currentTime)+1; - double progress = currentTime / totalTime; - double maxOffsetLeft = beatCanvasLeft.Width - BeatScrollLeft.ViewportWidth; - double maxOffsetRight = beatCanvasRight.Width - BeatScrollRight.ViewportWidth; - BeatScrollLeft.ScrollToHorizontalOffset(progress * (beatCanvasLeft.Width - BeatScrollLeft.ViewportWidth)); - BeatScrollRight.ScrollToHorizontalOffset((1 - progress) * (beatCanvasRight.Width - BeatScrollRight.ViewportWidth)); + if (currentSecond <= lastSecond) return; + lastSecond = currentSecond; + // 左控件 + if (_musicBeatsDic.TryGetValue(currentSecond, out var leftBeats)) + { + LeftBeats.SetSelected(currentSecond, true); + LeftBeats.ScrollToDotCenter(currentSecond, mirror: true); + } + + // 右控件 + if (_musicBeatsDic.TryGetValue(currentSecond, out var rightBeats)) + { + RightBeats.SetSelected(currentSecond, true); + RightBeats.ScrollToDotCenter(currentSecond, mirror: false); + } }; _beatScrollTimer.Start(); } From c4fa3cfe3f35cd69352ad06a9261f557a8f7653e Mon Sep 17 00:00:00 2001 From: tanglong <842690096@qq.com> Date: Sat, 18 Oct 2025 10:44:56 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Wpf_AiSportsMicrospace/Common/SportOperate.cs | 2 +- .../MyUserControl/CoverFlowControl.xaml.cs | 2 +- .../Views/JumpRope/MusicJumpRope.xaml | 13 --- .../Views/JumpRope/MusicJumpRope.xaml.cs | 82 +------------------ 4 files changed, 6 insertions(+), 93 deletions(-) diff --git a/Wpf_AiSportsMicrospace/Common/SportOperate.cs b/Wpf_AiSportsMicrospace/Common/SportOperate.cs index 83f0d72..7148e16 100644 --- a/Wpf_AiSportsMicrospace/Common/SportOperate.cs +++ b/Wpf_AiSportsMicrospace/Common/SportOperate.cs @@ -155,7 +155,7 @@ namespace Wpf_AiSportsMicrospace.Common } var duration = DateTime.Now - _raiseStartTime.Value; - if (duration.TotalSeconds >= 3) + if (duration.TotalSeconds >= 1) { _raiseStartTime = null; _wristStartTime = null; diff --git a/Wpf_AiSportsMicrospace/MyUserControl/CoverFlowControl.xaml.cs b/Wpf_AiSportsMicrospace/MyUserControl/CoverFlowControl.xaml.cs index 14c5fe5..4d2df00 100644 --- a/Wpf_AiSportsMicrospace/MyUserControl/CoverFlowControl.xaml.cs +++ b/Wpf_AiSportsMicrospace/MyUserControl/CoverFlowControl.xaml.cs @@ -116,7 +116,7 @@ namespace Wpf_AiSportsMicrospace.MyUserControl { if (_currentItem.Progress < 1) { - _currentItem.Progress += 0.00556; // 控制速度 + _currentItem.Progress += 0.01; // 控制速度 if (spark != null) { var pos = GetSparkPosition(_currentItem.Progress, 150, 200); diff --git a/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml b/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml index 94a9065..d4c8c9b 100644 --- a/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml +++ b/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml @@ -35,18 +35,5 @@ TextAlignment="Center" /> - - - - - - - - - - - - - diff --git a/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml.cs b/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml.cs index fc21ab8..578c009 100644 --- a/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml.cs +++ b/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml.cs @@ -38,35 +38,8 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope private readonly object _updateLock = new object(); private readonly Dictionary _jumpStatus = new Dictionary(); private MusicJumpRopeContext _musicJumpRopeContext; - public Dictionary> _musicBeatsDic; private GameState _currentGameState = GameState.NotStarted; - List RankingItemList = new(); - private List _musicBeats = new List() - { - 0.545,1.09,1.635,2.18,2.725,3.27,3.815,4.36,4.905,5.45, - 5.995,6.54,7.085,7.63,8.175,8.72,9.265,9.81,10.355,10.9, - 11.445,11.99,12.535,13.08,13.625,14.17,14.715,15.26,15.805,16.35, - 16.895,17.44,17.985,18.53,19.075,19.62,20.165,20.71,21.255,21.8, - 22.345,22.89,23.435,23.98,24.525,25.07,25.615,26.16,26.705,27.25, - 27.795,28.34,28.885,29.43,29.975,30.52,31.065,31.61,32.155,32.7, - 33.245,33.79,34.335,34.88,35.425,35.97,36.515,37.06,37.605,38.15, - 38.695,39.24,39.785,40.33,40.875,41.42,41.965,42.51,43.055,43.6, - 44.145,44.69,45.235,45.78,46.325,46.87,47.415,47.96,48.505,49.05, - 49.595,50.14,50.685,51.23,51.775,52.32,52.865,53.41,53.955,54.5, - 55.045,55.59,56.135,56.68,57.225,57.77,58.315,58.86,59.405,59.95, - 60.495,61.04,61.585,62.13,62.675,63.22,63.765,64.31,64.855,65.4, - 65.945,66.49,67.035,67.58,68.125,68.67,69.215,69.76,70.305,70.85, - 71.395,71.94,72.485,73.03,73.575,74.12,74.665,75.21,75.755,76.3, - 76.845,77.39,77.935,78.48,79.025,79.57,80.115,80.66,81.205,81.75, - 82.295,82.84,83.385,83.93,84.475,85.02,85.565,86.11,86.655,87.2, - 87.745,88.29,88.835,89.38,89.925,90.47,91.015,91.56,92.105,92.65, - 93.195,93.74,94.285,94.83,95.375,95.92,96.465,97.01,97.555,98.1, - 98.645,99.19,99.735,100.28,100.825,101.37,101.915,102.46,103.005,103.55, - 104.095,104.64,105.185,105.73,106.275,106.82,107.365,107.91,108.455 - - }; - private List _musicBeatTextBlock = new List(); // 容忍时间(节拍误差) @@ -82,17 +55,6 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope Loaded += UserControl_Loaded; Unloaded += UserControl_Unloaded; _musicJumpRopeContext = new MusicJumpRopeContext(); - _musicBeatsDic = _musicJumpRopeContext.MusicBeatsDic; - - _totalDots = _musicJumpRopeContext.MusicBeats["1"].Count(); - - // 左控件 - LeftBeats.DotCount = _totalDots; - LeftBeats.MusicBeatsDic = _musicBeatsDic; - - // 右控件 - RightBeats.DotCount = _totalDots; - RightBeats.MusicBeatsDic = _musicBeatsDic; } private async void UserControl_Loaded(object sender, RoutedEventArgs e) @@ -285,8 +247,6 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope // 播放背景音乐(循环) Utils.PlayBackgroundMusic("1.MP3", true); - StartBeatScrollTimer(); - for (int i = seconds; i >= 0; i--) { countdownText.Text = i.ToString(); @@ -510,10 +470,10 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope _musicJumpRopeContext.UserBeatSyncList[indexCopy]++; _musicBeatTextBlock[indexCopy].Text = $"卡点 x{_musicJumpRopeContext.UserBeatSyncList[indexCopy]}"; - if (indexCopy == 0) - LeftBeats.SetSelected(currentSecond, true); - else - RightBeats.SetSelected(currentSecond, true); + //if (indexCopy == 0) + // LeftBeats.SetSelected(currentSecond, true); + //else + // RightBeats.SetSelected(currentSecond, true); //Application.Current.Dispatcher.BeginInvoke(() => //{ @@ -656,39 +616,5 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope return userItem; } - - private DispatcherTimer _beatScrollTimer; - private double totalTime = 108.455; // 音乐总时长 - private int _lastSecond = -1; // 上一次已经处理的秒数 - private void StartBeatScrollTimer() - { - _beatScrollTimer = new DispatcherTimer(); - _beatScrollTimer.Interval = TimeSpan.FromMilliseconds(500); // 每秒一次 - - int lastSecond = -1; - - _beatScrollTimer.Tick += (s, e) => - { - double currentTime = Utils.GetMusicCurrentTime(); - int currentSecond = (int)Math.Floor(currentTime)+1; - - if (currentSecond <= lastSecond) return; - lastSecond = currentSecond; - // 左控件 - if (_musicBeatsDic.TryGetValue(currentSecond, out var leftBeats)) - { - LeftBeats.SetSelected(currentSecond, true); - LeftBeats.ScrollToDotCenter(currentSecond, mirror: true); - } - - // 右控件 - if (_musicBeatsDic.TryGetValue(currentSecond, out var rightBeats)) - { - RightBeats.SetSelected(currentSecond, true); - RightBeats.ScrollToDotCenter(currentSecond, mirror: false); - } - }; - _beatScrollTimer.Start(); - } } } From 20b45d91d7879f05321185cee085032d5916280f Mon Sep 17 00:00:00 2001 From: tanglong <842690096@qq.com> Date: Sat, 18 Oct 2025 11:00:36 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E5=8E=BB=E6=8E=89=20=E5=9C=86=E5=A4=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Wpf_AiSportsMicrospace/MyUserControl/CoverFlowControl.xaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Wpf_AiSportsMicrospace/MyUserControl/CoverFlowControl.xaml b/Wpf_AiSportsMicrospace/MyUserControl/CoverFlowControl.xaml index 4f558a1..7cfde0b 100644 --- a/Wpf_AiSportsMicrospace/MyUserControl/CoverFlowControl.xaml +++ b/Wpf_AiSportsMicrospace/MyUserControl/CoverFlowControl.xaml @@ -38,9 +38,9 @@ - - + + From 9b9e4c82a829075577190fb1aed58ffc798dfda7 Mon Sep 17 00:00:00 2001 From: tanglong <842690096@qq.com> Date: Sat, 18 Oct 2025 11:47:22 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E8=BF=9B=E5=BA=A6=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyUserControl/WxProgressBar.xaml | 13 ++++ .../MyUserControl/WxProgressBar.xaml.cs | 71 +++++++++++++++++++ .../Views/JumpRope/MusicJumpRope.xaml | 4 ++ .../Views/JumpRope/MusicJumpRope.xaml.cs | 25 +++++++ 4 files changed, 113 insertions(+) create mode 100644 Wpf_AiSportsMicrospace/MyUserControl/WxProgressBar.xaml create mode 100644 Wpf_AiSportsMicrospace/MyUserControl/WxProgressBar.xaml.cs diff --git a/Wpf_AiSportsMicrospace/MyUserControl/WxProgressBar.xaml b/Wpf_AiSportsMicrospace/MyUserControl/WxProgressBar.xaml new file mode 100644 index 0000000..b5c3615 --- /dev/null +++ b/Wpf_AiSportsMicrospace/MyUserControl/WxProgressBar.xaml @@ -0,0 +1,13 @@ + + + + + + + diff --git a/Wpf_AiSportsMicrospace/MyUserControl/WxProgressBar.xaml.cs b/Wpf_AiSportsMicrospace/MyUserControl/WxProgressBar.xaml.cs new file mode 100644 index 0000000..59c1c79 --- /dev/null +++ b/Wpf_AiSportsMicrospace/MyUserControl/WxProgressBar.xaml.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Wpf_AiSportsMicrospace.MyUserControl +{ + /// + /// WxProgressBar.xaml 的交互逻辑 + /// + public partial class WxProgressBar : UserControl + { + public WxProgressBar() + { + InitializeComponent(); + } + + #region 左右进度属性 + private double _leftProgress; + public double LeftProgress + { + get => _leftProgress; + set + { + _leftProgress = Clamp(value, 0, 1); + RightProgress = 1 - _leftProgress; // 左多右少 + UpdateVisual(); + } + } + + private double _rightProgress; + public double RightProgress + { + get => _rightProgress; + set + { + _rightProgress = Clamp(value, 0, 1); + _leftProgress = 1 - _rightProgress; // 右多左少 + UpdateVisual(); + } + } + #endregion + + private void UpdateVisual() + { + double width = ActualWidth; + if (width <= 0) return; + + LeftBar.Width = width * _leftProgress; + RightBar.Width = width * _rightProgress; + + ProgressTextBlock.Text = $"{Math.Round(_leftProgress * 100)}% : {Math.Round(_rightProgress * 100)}%"; + } + + private double Clamp(double value, double min, double max) => value < min ? min : value > max ? max : value; + + protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo) + { + base.OnRenderSizeChanged(sizeInfo); + UpdateVisual(); + } + } +} diff --git a/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml b/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml index d4c8c9b..f046628 100644 --- a/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml +++ b/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml @@ -35,5 +35,9 @@ TextAlignment="Center" /> + + + + diff --git a/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml.cs b/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml.cs index 578c009..812de67 100644 --- a/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml.cs +++ b/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml.cs @@ -59,6 +59,31 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope private async void UserControl_Loaded(object sender, RoutedEventArgs e) { + Random _rand = new Random(); + // 初始化进度 + PkBar.LeftProgress = 0.5; // 左右各占50% + await Task.Delay(500); + + for (int i = 0; i < 20; i++) + { + await Task.Delay(300); + + // 随机生成一个变化值 0~0.1 + double delta = _rand.NextDouble() * 0.1; + + // 随机决定左增加还是右增加 + if (_rand.Next(0, 2) == 0) + { + // 左增加 → 右减少 + PkBar.LeftProgress = Math.Min(1, PkBar.LeftProgress + delta); + } + else + { + // 右增加 → 左减少 + PkBar.RightProgress = Math.Min(1, PkBar.RightProgress + delta); + } + } + DrawCirclesWithText(); // 播放音乐 PlayMusic("raisehand.mp3"); From a4a54a2f6916ca9fcb3440d5179337f8e1098887 Mon Sep 17 00:00:00 2001 From: tanglong <842690096@qq.com> Date: Sat, 18 Oct 2025 11:49:44 +0800 Subject: [PATCH 6/8] shiyong --- .../Views/JumpRope/MusicJumpRope.xaml.cs | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml.cs b/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml.cs index 812de67..6ad2b1f 100644 --- a/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml.cs +++ b/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml.cs @@ -59,30 +59,30 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope private async void UserControl_Loaded(object sender, RoutedEventArgs e) { - Random _rand = new Random(); - // 初始化进度 - PkBar.LeftProgress = 0.5; // 左右各占50% - await Task.Delay(500); + //Random _rand = new Random(); + //// 初始化进度 + //PkBar.LeftProgress = 0.5; // 左右各占50% + //await Task.Delay(500); - for (int i = 0; i < 20; i++) - { - await Task.Delay(300); + //for (int i = 0; i < 500; i++) + //{ + // await Task.Delay(300); - // 随机生成一个变化值 0~0.1 - double delta = _rand.NextDouble() * 0.1; + // // 随机生成一个变化值 0~0.1 + // double delta = _rand.NextDouble() * 0.1; - // 随机决定左增加还是右增加 - if (_rand.Next(0, 2) == 0) - { - // 左增加 → 右减少 - PkBar.LeftProgress = Math.Min(1, PkBar.LeftProgress + delta); - } - else - { - // 右增加 → 左减少 - PkBar.RightProgress = Math.Min(1, PkBar.RightProgress + delta); - } - } + // // 随机决定左增加还是右增加 + // if (_rand.Next(0, 2) == 0) + // { + // // 左增加 → 右减少 + // PkBar.LeftProgress = Math.Min(1, PkBar.LeftProgress + delta); + // } + // else + // { + // // 右增加 → 左减少 + // PkBar.RightProgress = Math.Min(1, PkBar.RightProgress + delta); + // } + //} DrawCirclesWithText(); // 播放音乐 From 41955de0d3cc969ee7f9763485af520e49084e69 Mon Sep 17 00:00:00 2001 From: tanglong <842690096@qq.com> Date: Sat, 18 Oct 2025 14:39:54 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E8=BF=9B=E5=BA=A6=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyUserControl/WxProgressBar.xaml | 22 ++++++-- .../MyUserControl/WxProgressBar.xaml.cs | 48 +++++++++++++----- .../Resources/Img/Album/vs.png | Bin 0 -> 2989 bytes .../Views/JumpRope/MusicJumpRope.xaml | 5 +- .../Views/JumpRope/MusicJumpRope.xaml.cs | 37 +++++--------- .../Wpf_AiSportsMicrospace.csproj | 4 ++ 6 files changed, 71 insertions(+), 45 deletions(-) create mode 100644 Wpf_AiSportsMicrospace/Resources/Img/Album/vs.png diff --git a/Wpf_AiSportsMicrospace/MyUserControl/WxProgressBar.xaml b/Wpf_AiSportsMicrospace/MyUserControl/WxProgressBar.xaml index b5c3615..bae8d89 100644 --- a/Wpf_AiSportsMicrospace/MyUserControl/WxProgressBar.xaml +++ b/Wpf_AiSportsMicrospace/MyUserControl/WxProgressBar.xaml @@ -5,9 +5,21 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" x:Name="root" Height="30" Width="600"> - - - - - + + + + + + + + + + diff --git a/Wpf_AiSportsMicrospace/MyUserControl/WxProgressBar.xaml.cs b/Wpf_AiSportsMicrospace/MyUserControl/WxProgressBar.xaml.cs index 59c1c79..81435d3 100644 --- a/Wpf_AiSportsMicrospace/MyUserControl/WxProgressBar.xaml.cs +++ b/Wpf_AiSportsMicrospace/MyUserControl/WxProgressBar.xaml.cs @@ -21,6 +21,12 @@ namespace Wpf_AiSportsMicrospace.MyUserControl public WxProgressBar() { InitializeComponent(); + this.SizeChanged += WxProgressBar_SizeChanged; + } + + private void WxProgressBar_SizeChanged(object sender, SizeChangedEventArgs e) + { + UpdateVisual(); } #region 左右进度属性 @@ -31,7 +37,7 @@ namespace Wpf_AiSportsMicrospace.MyUserControl set { _leftProgress = Clamp(value, 0, 1); - RightProgress = 1 - _leftProgress; // 左多右少 + _rightProgress = 1 - _leftProgress; UpdateVisual(); } } @@ -43,7 +49,7 @@ namespace Wpf_AiSportsMicrospace.MyUserControl set { _rightProgress = Clamp(value, 0, 1); - _leftProgress = 1 - _rightProgress; // 右多左少 + _leftProgress = 1 - _rightProgress; UpdateVisual(); } } @@ -51,21 +57,39 @@ namespace Wpf_AiSportsMicrospace.MyUserControl private void UpdateVisual() { - double width = ActualWidth; - if (width <= 0) return; + double totalWidth = ActualWidth; + double totalHeight = ActualHeight; + if (totalWidth <= 0 || totalHeight <= 0) return; - LeftBar.Width = width * _leftProgress; - RightBar.Width = width * _rightProgress; + double barHeight = 30; // 进度条高度 + double middleLineHeight = MiddleLine.Height; + // 左侧红条 + LeftBar.Width = totalWidth * _leftProgress; + LeftBar.Height = barHeight; + Canvas.SetLeft(LeftBar, 0); + Canvas.SetTop(LeftBar, (totalHeight - barHeight) / 2); + + // 右侧绿条 + RightBar.Width = totalWidth * _rightProgress; + RightBar.Height = barHeight; + Canvas.SetLeft(RightBar, totalWidth - RightBar.Width); + Canvas.SetTop(RightBar, (totalHeight - barHeight) / 2); + + // 分割线居中在红绿交界点 + double middleX = LeftBar.Width - MiddleLine.Width / 2; + if (middleX < 0) middleX = 0; + if (middleX > totalWidth - MiddleLine.Width) middleX = totalWidth - MiddleLine.Width; + + Canvas.SetLeft(MiddleLine, middleX); + Canvas.SetTop(MiddleLine, (totalHeight - middleLineHeight) / 2); + + // 百分比文本居中显示 ProgressTextBlock.Text = $"{Math.Round(_leftProgress * 100)}% : {Math.Round(_rightProgress * 100)}%"; + Canvas.SetLeft(ProgressTextBlock, (totalWidth - ProgressTextBlock.ActualWidth) / 2); + Canvas.SetTop(ProgressTextBlock, (totalHeight - ProgressTextBlock.ActualHeight) / 2); } private double Clamp(double value, double min, double max) => value < min ? min : value > max ? max : value; - - protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo) - { - base.OnRenderSizeChanged(sizeInfo); - UpdateVisual(); - } } } diff --git a/Wpf_AiSportsMicrospace/Resources/Img/Album/vs.png b/Wpf_AiSportsMicrospace/Resources/Img/Album/vs.png new file mode 100644 index 0000000000000000000000000000000000000000..924e879e440d16e7536d5b28a7d38a1c0812e323 GIT binary patch literal 2989 zcmXw52{=?=A0`swYeAHqDMJXUY<)4-k-eGhTh{DZBFm7-UYHqVi=ix)T?i>VGh>TN zGGkX{``ee9`<Ma>2k7PU}s=p;6&MsNCt*u&L##ZZ4iVYXv)GGPaSA1E6Y!gLJJCMV*IG))^s|Z zVr&UoFoma((E@_scK+nOE1E^4speKw=2p+DGf)D8sT2JWLx05D|WKIt{?U3yw+#vpDJijxqo^5fQ#90fEAqFH<{fT}T5kg~0d$%(S%~00S8` z8VzIz;{g*hkR1&EP4xd3LSTF+%q;==>cN(uq~w%^6+j>&eL&>!=ukb(8#_tXi4IuW z+r&}+rUv&U+6ssV3jqcM5ts+qzxpBdNWX)H#eXrt?DC6jlzFl;0cv@m|pzLUMOpTB6Ve$iBwKQmmhFb-%#TdMCSMOr3C?kz4>k-As< zY}>#&BL$in-T8akjSE&QJ(kH8wPx#+lGyBh0FMH^-i zugvJt5|pzot2Zq^v(nvw-mrL!wh`ocGnw&HQ39hSHXDBa{`=(M0aabH5%kI=2Kp%J zpwQ;@OSs$*-wK6@^{YguIZQyKj}-UI6Ak(FKYw}wm2M3pAi7J0;)FW{8AAn-Y;FxT zGuR56mTuJZRkryIuTK05`N{`EVtspYbF0A5^^5`~`s6^3BG3-XI(P()Ye0`jLiAle z95OJl3L~{NP$9XK*}IxtNba6m*BhR&EV$M^R*^hER`zHSL#=E$+*bWKcjwc@(QMCZ&%7WF>B0+HDkHe@bEQq*wqfwcQ4?)E?Fzs@~Qr_8jfo%?NVmQ z%T8w`Wv@`g(%(Jnua8IBPZh}^>hI)8i=kD^Y`>;vUBg`&xPUsL-DRao*o5~JP|r)? zi_*9CHre6j?Pt@yxwK7dP&aHeYTK2#HwJH>7W7Wls+`v25$enT`A16v?R>hP*jHGy z|8jvRZ=TTofYz;NaEaR7aaR}(_rpE-QV9RJX|g3C5j&UbmW;AjmmKp+*3x~W=Q!4F zayeXTRN%Qh>TRNP9Ur!flF(7^GJw=q6bmp0&JkBl@-6LbSr=BhZLQ6o*TjmJ-&>3V!oy504c zbz~bUZg~-MNNPs57G_ei@PbR}MX~a7wdlIMGs&R_YD?C_0b8ra%&}?)ek7L3jCdx~ zdcM72eO6`pC82=e7_x_vX<>`Ps7v9Bg9F>TG3&u1OwmSG{>J#iCHxc0(eF>uWA`R9 z9bg%3^fa|!vreZwu5+C*7aRS@nxWppy;+Hu@1QJ7Owf4UzLU8b`Ns-|8q-!<&Dno_ zlTi*cIM_!E@Ls&7tP;Z00DG5dLfn1FQrgt6w^e>5KAQ>iQq#Z9JC*Sbt}TrAzEi+w ziTTK7(uU3bL5@`53y4fCR&8Y8Y-Qk)&%2VX0O-2@5idJE0QFgOaTsAobrO|(n$rSv z1^Ogb0#j=}@o?T-b|jQ^)zKVGoqPAx)_+r9-WyiOMGX5)z_a;6;JU9ew^Lc}n?=D7 zHzbP+9p;S|Mg~vTLfo%(#ycwAE9{fS1xex9ru~bIupW};*`;dR*Oz2Ee3VA6q*dI^ zjXc44z>z)D&}+K0j%i>AyTf|Pv?7~}g0+7|n09-kc$`S7vrUi+5Ma`TQi;ZL1rmdz zqvrKecSpFoW_bL5GL)vgS68tR&X~Toyy!5|54$LBxaurYa^o05Hu@+xffg1PMOOLY zZ_}rbuf7lvs^Rs1`%;vGO2W4}*#*~gsx^m?Z}&x8ztb5f1;3GQ)$O?TlB(0gJpTDT z*H!MfMp62`aaXBJ>54tLuhrx1QcoTVl!L@r z15aswje7wvV^`@&Guw~C*KiiZ8!_N`N#UEHPfr#1+r=DiZ{B=Xg{L)k1)aeDI%1ys z;v#pFKzMK$d#1TRxXk7G>zQ*cEdE@!M&iFdrtIws7_$2s&tj(ATg*;61?7@TT9s2o zunX9Y4m$0_+1(t`z@{AZ?d$TV^h)jKm_yYSQiZ9=;!JUKzqU(-#I*Y|o%0gRLE;h& zyOkCaX{K$Rsh{GR>@AzH98(d|DoXNI=##PO9z=V6?ugnPj{97q<2y<_HY12a!v0e< z;dOi2qgNcq%b&5nD;{n0nz#G8!FlT+dMnH<>BxUHgp=C}Y27@|m%sd^vC{-*D=}_bQ}MB7 z`a`K8Y$0?t+8uS(vCH#Ek^f@f%4ksLx2`+ku|c-m7?jXl$j&KSw;4AlUtUR{KkNH; z770S>PnW7qV_kiNzDJ_8I?F9PCds}pz*@BY7A@bf-?Wl6E)!jR*1yKhZ0kRp*33w{Xi?=c zRH)9prD=DILWj!VkFL|ZP_Ny7x3QDz!Li4Q_) - - + - + diff --git a/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml.cs b/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml.cs index 6ad2b1f..9c7911a 100644 --- a/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml.cs +++ b/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml.cs @@ -59,34 +59,21 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope private async void UserControl_Loaded(object sender, RoutedEventArgs e) { - //Random _rand = new Random(); - //// 初始化进度 - //PkBar.LeftProgress = 0.5; // 左右各占50% - //await Task.Delay(500); - - //for (int i = 0; i < 500; i++) - //{ - // await Task.Delay(300); - - // // 随机生成一个变化值 0~0.1 - // double delta = _rand.NextDouble() * 0.1; - - // // 随机决定左增加还是右增加 - // if (_rand.Next(0, 2) == 0) - // { - // // 左增加 → 右减少 - // PkBar.LeftProgress = Math.Min(1, PkBar.LeftProgress + delta); - // } - // else - // { - // // 右增加 → 左减少 - // PkBar.RightProgress = Math.Min(1, PkBar.RightProgress + delta); - // } - //} - DrawCirclesWithText(); // 播放音乐 PlayMusic("raisehand.mp3"); + + Random rnd = new Random(); + + // 模拟 20 次随机更新 + for (int i = 0; i < 200; i++) + { + // 随机左右进度变化,保证总和=1 + double left = rnd.NextDouble(); // 0~1 + PkBar.LeftProgress = left; // RightProgress 自动 1-left + + await Task.Delay(1000); // 200ms 间隔,不卡UI线程 + } } private void UserControl_Unloaded(object sender, RoutedEventArgs e) diff --git a/Wpf_AiSportsMicrospace/Wpf_AiSportsMicrospace.csproj b/Wpf_AiSportsMicrospace/Wpf_AiSportsMicrospace.csproj index 50a781f..51d4079 100644 --- a/Wpf_AiSportsMicrospace/Wpf_AiSportsMicrospace.csproj +++ b/Wpf_AiSportsMicrospace/Wpf_AiSportsMicrospace.csproj @@ -28,6 +28,7 @@ + @@ -182,6 +183,9 @@ Always + + Always + Always From b9c3cac66aea6f9e738838eba293e87bd455bb04 Mon Sep 17 00:00:00 2001 From: tanglong <842690096@qq.com> Date: Sat, 18 Oct 2025 14:47:22 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E9=A2=9C=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Wpf_AiSportsMicrospace/MyUserControl/WxProgressBar.xaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Wpf_AiSportsMicrospace/MyUserControl/WxProgressBar.xaml b/Wpf_AiSportsMicrospace/MyUserControl/WxProgressBar.xaml index bae8d89..3901272 100644 --- a/Wpf_AiSportsMicrospace/MyUserControl/WxProgressBar.xaml +++ b/Wpf_AiSportsMicrospace/MyUserControl/WxProgressBar.xaml @@ -6,8 +6,8 @@ x:Name="root" Height="30" Width="600"> - - + +