From 708541ea741c538b4e84bf9e1cd7ce94eab309a9 Mon Sep 17 00:00:00 2001 From: ltx <1006158920@qq.com> Date: Sat, 18 Oct 2025 17:50:25 +0800 Subject: [PATCH] =?UTF-8?q?uodate=EF=BC=9A=E6=A0=B7=E5=BC=8F=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyUserControl/PopSilder.xaml | 27 +++--- .../MyUserControl/PopSilder.xaml.cs | 8 +- .../MyUserControl/WxProgressBar.xaml | 54 ++++++++---- .../MyUserControl/WxProgressBar.xaml.cs | 85 +++++++++++++------ .../Views/JumpRope/MusicJumpRope.xaml | 14 +-- .../Views/JumpRope/MusicJumpRope.xaml.cs | 15 +++- 6 files changed, 140 insertions(+), 63 deletions(-) diff --git a/Wpf_AiSportsMicrospace/MyUserControl/PopSilder.xaml b/Wpf_AiSportsMicrospace/MyUserControl/PopSilder.xaml index def6c5c..638efd1 100644 --- a/Wpf_AiSportsMicrospace/MyUserControl/PopSilder.xaml +++ b/Wpf_AiSportsMicrospace/MyUserControl/PopSilder.xaml @@ -9,31 +9,38 @@ > + + + + + + + - + + BorderThickness="3" + CornerRadius="5" + Padding="0" + Margin="10"> + --> + + + --> - + \ No newline at end of file diff --git a/Wpf_AiSportsMicrospace/MyUserControl/PopSilder.xaml.cs b/Wpf_AiSportsMicrospace/MyUserControl/PopSilder.xaml.cs index be5490b..0088a61 100644 --- a/Wpf_AiSportsMicrospace/MyUserControl/PopSilder.xaml.cs +++ b/Wpf_AiSportsMicrospace/MyUserControl/PopSilder.xaml.cs @@ -148,24 +148,26 @@ namespace Wpf_AiSportsMicrospace.MyUserControl if (_isMiss) { head_m.Visibility = Visibility.Visible; + miss.Visibility = Visibility.Visible; //200ms后隐藏 var hideTimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(200) }; hideTimer.Tick += (s, e) => { - head_m.Visibility = Visibility.Hidden; - _isMiss = true; + //head_m.Visibility = Visibility.Hidden; + //_isMiss = true; hideTimer.Stop(); }; } else { head_g.Visibility = Visibility.Visible; + great.Visibility = Visibility.Visible; //200ms后隐藏 var hideTimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(200) }; hideTimer.Tick += (s, e) => { head_g.Visibility = Visibility.Hidden; - _isMiss = false; + great.Visibility = Visibility.Hidden; hideTimer.Stop(); }; } diff --git a/Wpf_AiSportsMicrospace/MyUserControl/WxProgressBar.xaml b/Wpf_AiSportsMicrospace/MyUserControl/WxProgressBar.xaml index 3901272..2c0a062 100644 --- a/Wpf_AiSportsMicrospace/MyUserControl/WxProgressBar.xaml +++ b/Wpf_AiSportsMicrospace/MyUserControl/WxProgressBar.xaml @@ -4,22 +4,44 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" x:Name="root" - Height="30" Width="600"> - - - + Width="1206"> + + + + + + - - + + + + + + + + + + + + + + - - - diff --git a/Wpf_AiSportsMicrospace/MyUserControl/WxProgressBar.xaml.cs b/Wpf_AiSportsMicrospace/MyUserControl/WxProgressBar.xaml.cs index 81435d3..d780185 100644 --- a/Wpf_AiSportsMicrospace/MyUserControl/WxProgressBar.xaml.cs +++ b/Wpf_AiSportsMicrospace/MyUserControl/WxProgressBar.xaml.cs @@ -7,6 +7,7 @@ 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; @@ -18,6 +19,7 @@ namespace Wpf_AiSportsMicrospace.MyUserControl /// public partial class WxProgressBar : UserControl { + public WxProgressBar() { InitializeComponent(); @@ -57,39 +59,68 @@ namespace Wpf_AiSportsMicrospace.MyUserControl private void UpdateVisual() { - double totalWidth = ActualWidth; - double totalHeight = ActualHeight; - if (totalWidth <= 0 || totalHeight <= 0) return; + // 创建宽度动画 + double width = 1200 * LeftProgress; + DoubleAnimation animation = new DoubleAnimation + { + From = left.Width, + To = width, + Duration = TimeSpan.FromSeconds(0.2), + EasingFunction = new QuadraticEase { EasingMode = EasingMode.EaseOut }, + FillBehavior = FillBehavior.HoldEnd + }; - double barHeight = 30; // 进度条高度 - double middleLineHeight = MiddleLine.Height; + // 应用动画 - // 左侧红条 - LeftBar.Width = totalWidth * _leftProgress; - LeftBar.Height = barHeight; - Canvas.SetLeft(LeftBar, 0); - Canvas.SetTop(LeftBar, (totalHeight - barHeight) / 2); + ThicknessAnimation thick = new ThicknessAnimation + { + From = MiddleLine.Margin, // 起始值 + To = new Thickness(width - 16, 0, 0, 0), // 目标值 + Duration = TimeSpan.FromSeconds(0.2), // time秒持续时间 + EasingFunction = new QuadraticEase { EasingMode = EasingMode.EaseOut }, + FillBehavior = FillBehavior.HoldEnd // 动画完成后保持状态 + }; + MiddleLine.BeginAnimation(FrameworkElement.MarginProperty, thick); - // 右侧绿条 - RightBar.Width = totalWidth * _rightProgress; - RightBar.Height = barHeight; - Canvas.SetLeft(RightBar, totalWidth - RightBar.Width); - Canvas.SetTop(RightBar, (totalHeight - barHeight) / 2); + left.BeginAnimation(Grid.WidthProperty, animation); - // 分割线居中在红绿交界点 - 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 void UpdateVisual() + //{ + // double totalWidth = ActualWidth; + // double totalHeight = ActualHeight; + // if (totalWidth <= 0 || totalHeight <= 0) return; + + // double barHeight = 50; // 进度条高度 + // 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; } } diff --git a/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml b/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml index 1761c7c..5f99462 100644 --- a/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml +++ b/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml @@ -16,26 +16,27 @@ VerticalAlignment="Top" Width="905" Margin="0,70,0,0" + MouseDown="Image_MouseDown" /> - - + + - + @@ -55,6 +56,7 @@ --> - + + diff --git a/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml.cs b/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml.cs index 9c7911a..474cdaa 100644 --- a/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml.cs +++ b/Wpf_AiSportsMicrospace/Views/JumpRope/MusicJumpRope.xaml.cs @@ -481,7 +481,14 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope { _musicJumpRopeContext.UserBeatSyncList[indexCopy]++; _musicBeatTextBlock[indexCopy].Text = $"卡点 x{_musicJumpRopeContext.UserBeatSyncList[indexCopy]}"; - + if(indexCopy == 0) + { + popSilder1.IsMiss = false; + } + else + { + popSilder2.IsMiss = false; + } //if (indexCopy == 0) // LeftBeats.SetSelected(currentSecond, true); //else @@ -628,5 +635,11 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope return userItem; } + + private void Image_MouseDown(object sender, MouseButtonEventArgs e) + { + popSilder1.StartMarginAnimation(); + popSilder2.StartMarginAnimation(); + } } }