update:10.20合并版
This commit is contained in:
parent
290ba96aa2
commit
0dd3f4a0b0
@ -56,7 +56,7 @@ namespace Wpf_AiSportsMicrospace.Common
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_webcamClient = WebcamClient.CreateRTSP("172.17.30.64", "admin", "yd708090", 554u);
|
_webcamClient = WebcamClient.CreateRTSP("172.17.30.65", "admin", "yd708090", 554u);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -14,7 +14,7 @@ namespace Dto
|
|||||||
// 静态字段,保存排名列表
|
// 静态字段,保存排名列表
|
||||||
public static List<RankItem> RankList { get; set; } = new List<RankItem>();
|
public static List<RankItem> RankList { get; set; } = new List<RankItem>();
|
||||||
public List<(double XNorm, double YNorm)> CirclePositions { get; private set; }
|
public List<(double XNorm, double YNorm)> CirclePositions { get; private set; }
|
||||||
public List<SportUserItem> UserList { get; private set; }
|
public List<MusicUserItem> UserList { get; private set; }
|
||||||
public List<string> UserNumberList { get; private set; }
|
public List<string> UserNumberList { get; private set; }
|
||||||
public List<double> UserScoreList { get; private set; }
|
public List<double> UserScoreList { get; private set; }
|
||||||
public List<SportBase> Sports { get; private set; }
|
public List<SportBase> Sports { get; private set; }
|
||||||
@ -56,13 +56,13 @@ namespace Dto
|
|||||||
{
|
{
|
||||||
CirclePositions = new List<(double XNorm, double YNorm)>
|
CirclePositions = new List<(double XNorm, double YNorm)>
|
||||||
{
|
{
|
||||||
(0.78, 0.88),
|
|
||||||
(0.50, 0.88),
|
(0.50, 0.88),
|
||||||
|
(0.78, 0.88),
|
||||||
};
|
};
|
||||||
|
|
||||||
MusicBeatsDic = MusicBeats["1"].GroupBy(b => (int)Math.Ceiling(b) - 1).ToDictionary(g => g.Key, g => g.ToList());
|
MusicBeatsDic = MusicBeats["1"].GroupBy(b => (int)Math.Ceiling(b) - 1).ToDictionary(g => g.Key, g => g.ToList());
|
||||||
|
|
||||||
UserList = new List<SportUserItem>();
|
UserList = new List<MusicUserItem>();
|
||||||
UserNumberList = new List<string>();
|
UserNumberList = new List<string>();
|
||||||
Sports = new List<SportBase>();
|
Sports = new List<SportBase>();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
DisplayMemberPath="Name"
|
DisplayMemberPath="Name"
|
||||||
SelectedValuePath="Key"
|
SelectedValuePath="Key"
|
||||||
SelectionChanged="sportList_SelectionChanged" d:IsHidden="True"/>
|
SelectionChanged="sportList_SelectionChanged" d:IsHidden="True"/>
|
||||||
<TextBox x:Name="host" Margin="0,10,0,0" Text="192.168.3.64"/>
|
<TextBox x:Name="host" Margin="0,10,0,0" Text="172.17.30.65"/>
|
||||||
<TextBox x:Name="userName" Margin="0,10,0,0" Text="admin"/>
|
<TextBox x:Name="userName" Margin="0,10,0,0" Text="admin"/>
|
||||||
<TextBox x:Name="password" Margin="0,10,0,0" Text="yd708090"/>
|
<TextBox x:Name="password" Margin="0,10,0,0" Text="yd708090"/>
|
||||||
<TextBox x:Name="port" Margin="0,10,0,0" Text="554"/>
|
<TextBox x:Name="port" Margin="0,10,0,0" Text="554"/>
|
||||||
|
|||||||
25
Wpf_AiSportsMicrospace/MyUserControl/MusicUserItem.xaml
Normal file
25
Wpf_AiSportsMicrospace/MyUserControl/MusicUserItem.xaml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<UserControl x:Class="Wpf_AiSportsMicrospace.MyUserControl.MusicUserItem"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:local="clr-namespace:Wpf_AiSportsMicrospace.MyUserControl"
|
||||||
|
xmlns:system="clr-namespace:System;assembly=mscorlib"
|
||||||
|
xmlns:gif="http://wpfanimatedgif.codeplex.com"
|
||||||
|
>
|
||||||
|
<Grid>
|
||||||
|
<Image Source="/Resources/Img/play_img/music_rope/out_u.png" Width="420" HorizontalAlignment="Center" VerticalAlignment="Top"
|
||||||
|
x:Name="image3" Visibility="Hidden"/>
|
||||||
|
<Image Source="/Resources/Img/play_img/music_rope/jump_u.png" Width="420" HorizontalAlignment="Center" VerticalAlignment="Top"
|
||||||
|
x:Name="image1" Visibility="Collapsed" />
|
||||||
|
<Image gif:ImageBehavior.AnimatedSource="/Resources/Img/play_img/music_rope/jump_u.gif"
|
||||||
|
x:Name="image2"
|
||||||
|
gif:ImageBehavior.AutoStart="True"
|
||||||
|
gif:ImageBehavior.RepeatBehavior="Forever"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Width="420"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
144
Wpf_AiSportsMicrospace/MyUserControl/MusicUserItem.xaml.cs
Normal file
144
Wpf_AiSportsMicrospace/MyUserControl/MusicUserItem.xaml.cs
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
using HandyControl.Controls;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
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;
|
||||||
|
using System.Windows.Threading;
|
||||||
|
using WpfAnimatedGif;
|
||||||
|
|
||||||
|
namespace Wpf_AiSportsMicrospace.MyUserControl
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// CoverFlowControl.xaml 的交互逻辑
|
||||||
|
/// </summary>
|
||||||
|
/// ST
|
||||||
|
public partial class MusicUserItem : UserControl
|
||||||
|
{
|
||||||
|
public MusicUserItem()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
//InitGif();
|
||||||
|
}
|
||||||
|
|
||||||
|
public string DisplayText
|
||||||
|
{
|
||||||
|
get => (string)GetValue(DisplayTextProperty);
|
||||||
|
set => SetValue(DisplayTextProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static readonly DependencyProperty DisplayTextProperty =
|
||||||
|
DependencyProperty.Register(nameof(DisplayText), typeof(string), typeof(MusicUserItem), new PropertyMetadata("??"));
|
||||||
|
|
||||||
|
public string NumberText
|
||||||
|
{
|
||||||
|
get => (string)GetValue(NumberTextProperty);
|
||||||
|
set => SetValue(NumberTextProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static readonly DependencyProperty NumberTextProperty =
|
||||||
|
DependencyProperty.Register(nameof(NumberText), typeof(string), typeof(MusicUserItem), new PropertyMetadata("0"));
|
||||||
|
|
||||||
|
public string ImageState
|
||||||
|
//0 没有人 1 准备中 2 运动中 3 出圈了
|
||||||
|
{
|
||||||
|
get => (string)GetValue(ImageStateProperty);
|
||||||
|
set => SetValue(ImageStateProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static readonly DependencyProperty ImageStateProperty =
|
||||||
|
DependencyProperty.Register(nameof(ImageState), typeof(string), typeof(MusicUserItem), new PropertyMetadata("0", OnImageStateChanged));
|
||||||
|
|
||||||
|
private static void OnImageStateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
var control = (MusicUserItem)d;
|
||||||
|
control.ShowImage((string)e.NewValue);
|
||||||
|
}
|
||||||
|
private void ShowImage(string imageIndex)
|
||||||
|
{
|
||||||
|
// 隐藏所有图片
|
||||||
|
image1.Visibility = Visibility.Hidden;
|
||||||
|
image2.Visibility = Visibility.Hidden;
|
||||||
|
image3.Visibility = Visibility.Hidden;
|
||||||
|
|
||||||
|
// 显示指定的图片
|
||||||
|
switch (imageIndex)
|
||||||
|
{
|
||||||
|
case "1":
|
||||||
|
//image1.Visibility = Visibility.Visible;
|
||||||
|
//image1.Visibility = Visibility.Visible;
|
||||||
|
image1.Visibility = Visibility.Visible;
|
||||||
|
//Pause_Click();
|
||||||
|
break;
|
||||||
|
case "2":
|
||||||
|
//image2.Visibility = Visibility.Visible;
|
||||||
|
image2.Visibility = Visibility.Visible;
|
||||||
|
//Play_Click();
|
||||||
|
break;
|
||||||
|
case "3":
|
||||||
|
image3.Visibility = Visibility.Visible;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private BitmapImage _gifSource;
|
||||||
|
private BitmapFrame _firstFrame; // <- 改为 BitmapFrame
|
||||||
|
|
||||||
|
private void InitGif()
|
||||||
|
{
|
||||||
|
var uri = new Uri("pack://application:,,,/Resources/Img/test_img/one_rope/jump_rope.gif");
|
||||||
|
|
||||||
|
// 1) 加载用于播放的 BitmapImage(注意 OnLoad 防止被锁定)
|
||||||
|
_gifSource = new BitmapImage();
|
||||||
|
_gifSource.BeginInit();
|
||||||
|
_gifSource.UriSource = uri;
|
||||||
|
_gifSource.CacheOption = BitmapCacheOption.OnLoad;
|
||||||
|
_gifSource.EndInit();
|
||||||
|
|
||||||
|
// 2) 提取第一帧(使用 GifBitmapDecoder)
|
||||||
|
var sri = Application.GetResourceStream(uri);
|
||||||
|
if (sri != null)
|
||||||
|
{
|
||||||
|
using (var stream = sri.Stream)
|
||||||
|
{
|
||||||
|
var decoder = new GifBitmapDecoder(stream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.OnLoad);
|
||||||
|
if (decoder.Frames.Count > 0)
|
||||||
|
_firstFrame = decoder.Frames[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3) 默认显示第一帧(静态)
|
||||||
|
image2.Source = _firstFrame;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Play_Click()
|
||||||
|
{
|
||||||
|
// 重新设置动画源并播放
|
||||||
|
//ImageBehavior.SetAnimatedSource(image2, _gifSource);
|
||||||
|
//ImageBehavior.GetAnimationController(image2)?.Play();
|
||||||
|
var controller = ImageBehavior.GetAnimationController(image2);
|
||||||
|
controller?.Play();
|
||||||
|
}
|
||||||
|
private void Pause_Click()
|
||||||
|
{
|
||||||
|
var controller = ImageBehavior.GetAnimationController(image2);
|
||||||
|
if (controller != null)
|
||||||
|
{
|
||||||
|
controller.Pause(); // 暂停动画
|
||||||
|
//controller.GotoFrame(0); // 回到第一帧
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -16,7 +16,7 @@
|
|||||||
<Image x:Name="miss" Source="/Resources/Img/play_img/music_rope/miss.png" Visibility="Hidden" HorizontalAlignment="Left" Width="157" Height="85" VerticalAlignment="Bottom" Margin="0,0,0,86"/>
|
<Image x:Name="miss" Source="/Resources/Img/play_img/music_rope/miss.png" Visibility="Hidden" HorizontalAlignment="Left" Width="157" Height="85" VerticalAlignment="Bottom" Margin="0,0,0,86"/>
|
||||||
|
|
||||||
<Image x:Name="head_g" Source="/Resources/Img/play_img/music_rope/head_g.png" Visibility="Visible" HorizontalAlignment="Right" Width="152" Height="85" VerticalAlignment="Top" Margin="0,0,0,0"/>
|
<Image x:Name="head_g" Source="/Resources/Img/play_img/music_rope/head_g.png" Visibility="Visible" HorizontalAlignment="Right" Width="152" Height="85" VerticalAlignment="Top" Margin="0,0,0,0"/>
|
||||||
<Image x:Name="head_m" Source="/Resources/Img/play_img/music_rope/head_m.png" Visibility="Hidden" HorizontalAlignment="Right" Width="152" Height="85" VerticalAlignment="Top" Margin="0,0,0,0"/>
|
<Image x:Name="head_m" Source="/Resources/Img/play_img/music_rope/head_m.png" Visibility="Visible" HorizontalAlignment="Right" Width="152" Height="85" VerticalAlignment="Top" Margin="0,0,0,0"/>
|
||||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
||||||
<Grid Width="3" Height="140" Background="#fedd40" ClipToBounds="False" Margin="0,500,0,0"></Grid>
|
<Grid Width="3" Height="140" Background="#fedd40" ClipToBounds="False" Margin="0,500,0,0"></Grid>
|
||||||
<Grid Width="580" Height="87" Background="#25ffffff" ClipToBounds="False" Margin="0,500,0,0" HorizontalAlignment="Left">
|
<Grid Width="580" Height="87" Background="#25ffffff" ClipToBounds="False" Margin="0,500,0,0" HorizontalAlignment="Left">
|
||||||
|
|||||||
@ -122,7 +122,7 @@ namespace Wpf_AiSportsMicrospace.MyUserControl
|
|||||||
_marginAnimation = new ThicknessAnimation
|
_marginAnimation = new ThicknessAnimation
|
||||||
{
|
{
|
||||||
From = new Thickness(startMargin, 0, 0, 0), // 起始值
|
From = new Thickness(startMargin, 0, 0, 0), // 起始值
|
||||||
To = new Thickness(-time * (200 + 52) - 350, 0, 0, 0), // 目标值
|
To = new Thickness(-time * (200 + 52) - 650, 0, 0, 0), // 目标值
|
||||||
Duration = TimeSpan.FromSeconds(time), // time秒持续时间
|
Duration = TimeSpan.FromSeconds(time), // time秒持续时间
|
||||||
FillBehavior = FillBehavior.HoldEnd // 动画完成后保持状态
|
FillBehavior = FillBehavior.HoldEnd // 动画完成后保持状态
|
||||||
};
|
};
|
||||||
@ -167,27 +167,33 @@ namespace Wpf_AiSportsMicrospace.MyUserControl
|
|||||||
{
|
{
|
||||||
head_m.Visibility = Visibility.Visible;
|
head_m.Visibility = Visibility.Visible;
|
||||||
miss.Visibility = Visibility.Visible;
|
miss.Visibility = Visibility.Visible;
|
||||||
//200ms后隐藏
|
head_g.Visibility = Visibility.Hidden;
|
||||||
|
great.Visibility = Visibility.Hidden;
|
||||||
|
// 200ms 后隐藏
|
||||||
var hideTimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(200) };
|
var hideTimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(200) };
|
||||||
|
hideTimer.Start();
|
||||||
hideTimer.Tick += (s, e) =>
|
hideTimer.Tick += (s, e) =>
|
||||||
{
|
{
|
||||||
head_m.Visibility = Visibility.Hidden;
|
head_m.Visibility = Visibility.Hidden;
|
||||||
miss.Visibility = Visibility.Hidden;
|
miss.Visibility = Visibility.Hidden;
|
||||||
//_isMiss = true;
|
((DispatcherTimer)s).Stop();
|
||||||
hideTimer.Stop();
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
head_g.Visibility = Visibility.Visible;
|
head_g.Visibility = Visibility.Visible;
|
||||||
great.Visibility = Visibility.Visible;
|
great.Visibility = Visibility.Visible;
|
||||||
//200ms后隐藏
|
head_m.Visibility = Visibility.Hidden;
|
||||||
|
miss.Visibility = Visibility.Hidden;
|
||||||
|
// 200ms 后隐藏
|
||||||
var hideTimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(200) };
|
var hideTimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(200) };
|
||||||
|
hideTimer.Start();
|
||||||
hideTimer.Tick += (s, e) =>
|
hideTimer.Tick += (s, e) =>
|
||||||
{
|
{
|
||||||
|
_isMiss = true;
|
||||||
head_g.Visibility = Visibility.Hidden;
|
head_g.Visibility = Visibility.Hidden;
|
||||||
great.Visibility = Visibility.Hidden;
|
great.Visibility = Visibility.Hidden;
|
||||||
hideTimer.Stop();
|
((DispatcherTimer)s).Stop();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 136 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.4 MiB |
|
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 1.2 MiB |
@ -57,7 +57,7 @@
|
|||||||
gif:ImageBehavior.AnimatedSource="/Resources/Img/Album/1.gif"
|
gif:ImageBehavior.AnimatedSource="/Resources/Img/Album/1.gif"
|
||||||
gif:ImageBehavior.RepeatBehavior="Forever"
|
gif:ImageBehavior.RepeatBehavior="Forever"
|
||||||
HorizontalAlignment="right"
|
HorizontalAlignment="right"
|
||||||
VerticalAlignment="Top"
|
VerticalAlignment="Top"
|
||||||
Margin="50,10,200,20"
|
Margin="50,10,200,20"
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@ -19,11 +19,11 @@
|
|||||||
/>
|
/>
|
||||||
<Grid Height="1080" Width="1920" x:Name="userBox"/>
|
<Grid Height="1080" Width="1920" x:Name="userBox"/>
|
||||||
|
|
||||||
<Grid Width="220" Height="130" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="00,40,60,0" Visibility="Hidden" x:Name="countdownGrid">
|
<Grid Width="180" Height="90" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="00,20,40,0" Visibility="Hidden" x:Name="countdownGrid">
|
||||||
<Border Background="#005fff" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" CornerRadius="30" />
|
<Border Background="#005fff" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" CornerRadius="30" />
|
||||||
<TextBlock x:Name="countdownText"
|
<TextBlock x:Name="countdownText"
|
||||||
Text="60"
|
Text="60"
|
||||||
FontSize="120"
|
FontSize="80"
|
||||||
FontWeight="Bold"
|
FontWeight="Bold"
|
||||||
Foreground="#fff"
|
Foreground="#fff"
|
||||||
FontStyle="Italic"
|
FontStyle="Italic"
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
Height="1080" Width="1920" Loaded="UserControl_Loaded" Unloaded="UserControl_Unloaded">
|
Height="1080" Width="1920" Loaded="UserControl_Loaded" Unloaded="UserControl_Unloaded">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.Background>
|
<Grid.Background>
|
||||||
<ImageBrush ImageSource="/Resources/Img/play_img/music_rope/play_bg.png" Stretch="UniformToFill"/>
|
<ImageBrush ImageSource="/Resources/Img/play_img/music_rope/play_bg.jpg" Stretch="UniformToFill"/>
|
||||||
</Grid.Background>
|
</Grid.Background>
|
||||||
<Image
|
<Image
|
||||||
Source="/Resources/Img/play_img/music_rope/title.png"
|
Source="/Resources/Img/play_img/music_rope/title.png"
|
||||||
@ -19,9 +19,7 @@
|
|||||||
Margin="0,50,0,0"
|
Margin="0,50,0,0"
|
||||||
MouseDown="Image_MouseDown"
|
MouseDown="Image_MouseDown"
|
||||||
/>
|
/>
|
||||||
<Grid Height="1080" Width="1920" x:Name="userBox">
|
|
||||||
<Canvas x:Name="beatCanvas" />
|
|
||||||
</Grid>
|
|
||||||
|
|
||||||
<!--倒计时-->
|
<!--倒计时-->
|
||||||
<Grid Width="260" Height="130" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="00,830,00,0" Visibility="Visible" x:Name="countdownGrid">
|
<Grid Width="260" Height="130" VerticalAlignment="Top" HorizontalAlignment="Center" Margin="00,830,00,0" Visibility="Visible" x:Name="countdownGrid">
|
||||||
@ -57,9 +55,36 @@
|
|||||||
<!--滚动条-->
|
<!--滚动条-->
|
||||||
<local:PopSilder x:Name="popSilder1" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="154,0,0,60"/>
|
<local:PopSilder x:Name="popSilder1" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="154,0,0,60"/>
|
||||||
<local:PopSilder x:Name="popSilder2" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,154,60"/>
|
<local:PopSilder x:Name="popSilder2" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,154,60"/>
|
||||||
|
|
||||||
|
<Grid Opacity="0.5">
|
||||||
|
<Image
|
||||||
|
gif:ImageBehavior.AnimatedSource="/Resources/Img/play_img/music_rope/bg_mic.gif"
|
||||||
|
gif:ImageBehavior.AutoStart="False"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Width="600"
|
||||||
|
Margin="0,500,0,0"
|
||||||
|
x:Name="leftm"
|
||||||
|
/>
|
||||||
|
<Image
|
||||||
|
gif:ImageBehavior.AnimatedSource="/Resources/Img/play_img/music_rope/bg_mic.gif"
|
||||||
|
gif:ImageBehavior.AutoStart="False"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Width="600"
|
||||||
|
Margin="0,500,-565,0"
|
||||||
|
x:Name="rightm"
|
||||||
|
>
|
||||||
|
<Image.RenderTransform>
|
||||||
|
<ScaleTransform ScaleX="-1" ScaleY="1" CenterX="15" CenterY="25"/>
|
||||||
|
</Image.RenderTransform>
|
||||||
|
</Image>
|
||||||
|
</Grid>
|
||||||
|
<Grid Height="1080" Width="1920" x:Name="userBox">
|
||||||
|
|
||||||
|
</Grid>
|
||||||
<!--人物-->
|
<!--人物-->
|
||||||
<Grid>
|
<!--<Grid>
|
||||||
<Image x:Name="left1" Visibility="Visible" Source="/Resources/Img/play_img/music_rope/jump_u.png" HorizontalAlignment="Left" VerticalAlignment="Top" Width="420" Margin="226,345,0,0" />
|
<Image x:Name="left1" Visibility="Visible" Source="/Resources/Img/play_img/music_rope/jump_u.png" HorizontalAlignment="Left" VerticalAlignment="Top" Width="420" Margin="226,345,0,0" />
|
||||||
<Image x:Name="left3" Visibility="Hidden" Source="/Resources/Img/play_img/music_rope/out_u.png" HorizontalAlignment="Left" VerticalAlignment="Top" Width="420" Margin="226,345,0,0" />
|
<Image x:Name="left3" Visibility="Hidden" Source="/Resources/Img/play_img/music_rope/out_u.png" HorizontalAlignment="Left" VerticalAlignment="Top" Width="420" Margin="226,345,0,0" />
|
||||||
<Image
|
<Image
|
||||||
@ -89,6 +114,6 @@
|
|||||||
x:Name="right2"
|
x:Name="right2"
|
||||||
Visibility="Hidden"
|
Visibility="Hidden"
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>-->
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
@ -23,6 +23,7 @@ using Wpf_AiSportsMicrospace.Common;
|
|||||||
using Wpf_AiSportsMicrospace.Enum;
|
using Wpf_AiSportsMicrospace.Enum;
|
||||||
using Wpf_AiSportsMicrospace.MyUserControl;
|
using Wpf_AiSportsMicrospace.MyUserControl;
|
||||||
using Wpf_AiSportsMicrospace.Views;
|
using Wpf_AiSportsMicrospace.Views;
|
||||||
|
using WpfAnimatedGif;
|
||||||
using Yztob.AiSports.Inferences.Things;
|
using Yztob.AiSports.Inferences.Things;
|
||||||
using Yztob.AiSports.Postures.Sports;
|
using Yztob.AiSports.Postures.Sports;
|
||||||
|
|
||||||
@ -40,7 +41,6 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope
|
|||||||
private MusicJumpRopeContext _musicJumpRopeContext;
|
private MusicJumpRopeContext _musicJumpRopeContext;
|
||||||
private GameState _currentGameState = GameState.NotStarted;
|
private GameState _currentGameState = GameState.NotStarted;
|
||||||
|
|
||||||
private List<TextBlock> _musicBeatTextBlock = new List<TextBlock>();
|
|
||||||
|
|
||||||
// 容忍时间(节拍误差)
|
// 容忍时间(节拍误差)
|
||||||
public double _beatTolerance = 0.15; // ±150ms
|
public double _beatTolerance = 0.15; // ±150ms
|
||||||
@ -62,7 +62,7 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope
|
|||||||
DrawCirclesWithText();
|
DrawCirclesWithText();
|
||||||
// 播放音乐
|
// 播放音乐
|
||||||
PlayMusic("raisehand.mp3");
|
PlayMusic("raisehand.mp3");
|
||||||
PkBar.LeftProgress = 1;
|
PkBar.LeftProgress = 0.5;
|
||||||
|
|
||||||
popSilder1.MusicBeats = _musicJumpRopeContext.MusicBeats["1"];
|
popSilder1.MusicBeats = _musicJumpRopeContext.MusicBeats["1"];
|
||||||
popSilder2.MusicBeats = _musicJumpRopeContext.MusicBeats["1"];
|
popSilder2.MusicBeats = _musicJumpRopeContext.MusicBeats["1"];
|
||||||
@ -253,6 +253,7 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope
|
|||||||
countdownGrid.Visibility = Visibility.Hidden;
|
countdownGrid.Visibility = Visibility.Hidden;
|
||||||
// 启动60秒倒计时(独立任务)
|
// 启动60秒倒计时(独立任务)
|
||||||
StartGameCountdown(105);
|
StartGameCountdown(105);
|
||||||
|
ShowMusicAnimation();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void StartGameCountdown(int seconds)
|
private async void StartGameCountdown(int seconds)
|
||||||
@ -446,7 +447,6 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope
|
|||||||
_musicJumpRopeContext.UserList.Clear();
|
_musicJumpRopeContext.UserList.Clear();
|
||||||
_musicJumpRopeContext.UserNumberList.Clear();
|
_musicJumpRopeContext.UserNumberList.Clear();
|
||||||
_musicJumpRopeContext.UserBeatSyncList.Clear();
|
_musicJumpRopeContext.UserBeatSyncList.Clear();
|
||||||
_musicBeatTextBlock.Clear();
|
|
||||||
|
|
||||||
double imgWidth = userBox.ActualWidth;
|
double imgWidth = userBox.ActualWidth;
|
||||||
double imgHeight = userBox.ActualHeight;
|
double imgHeight = userBox.ActualHeight;
|
||||||
@ -462,11 +462,11 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope
|
|||||||
double y = pos.YNorm * imgHeight;
|
double y = pos.YNorm * imgHeight;
|
||||||
|
|
||||||
// 绘制发光圆
|
// 绘制发光圆
|
||||||
//var userItem = AddUserItem(x, y, i);
|
var userItem = AddUserItem(x, y, i);
|
||||||
// 绑定运动对象
|
// 绑定运动对象
|
||||||
var sport = SportBase.Create("rope-skipping");
|
var sport = SportBase.Create("rope-skipping");
|
||||||
int indexCopy = i;
|
int indexCopy = i;
|
||||||
//var currentItem = userItem;
|
var currentItem = userItem;
|
||||||
|
|
||||||
// 订阅事件
|
// 订阅事件
|
||||||
sport.OnTicked += (count, times) =>
|
sport.OnTicked += (count, times) =>
|
||||||
@ -476,9 +476,9 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope
|
|||||||
// 更新数字源
|
// 更新数字源
|
||||||
_musicJumpRopeContext.UserNumberList[indexCopy] = count.ToString();
|
_musicJumpRopeContext.UserNumberList[indexCopy] = count.ToString();
|
||||||
|
|
||||||
//if (userItem.ImageState != "2")
|
if (userItem.ImageState != "2")
|
||||||
// userItem.ImageState = "2";
|
userItem.ImageState = "2";
|
||||||
ChangeImgState(indexCopy, "2"); //改变当前图的状态
|
//ChangeImgState(indexCopy, "2"); //改变当前图的状态
|
||||||
|
|
||||||
|
|
||||||
var currentTime = Utils.GetMusicCurrentTime();
|
var currentTime = Utils.GetMusicCurrentTime();
|
||||||
@ -489,24 +489,26 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope
|
|||||||
bool hit = beats.Any(b => Math.Abs(b - currentTime) <= _beatTolerance);
|
bool hit = beats.Any(b => Math.Abs(b - currentTime) <= _beatTolerance);
|
||||||
if (hit)
|
if (hit)
|
||||||
{
|
{
|
||||||
_musicJumpRopeContext.UserBeatSyncList[indexCopy]++;
|
_musicJumpRopeContext.UserBeatSyncList[indexCopy] += 1;
|
||||||
_musicBeatTextBlock[indexCopy].Text = $"卡点 x{_musicJumpRopeContext.UserBeatSyncList[indexCopy]}";
|
|
||||||
double left = _musicJumpRopeContext.UserBeatSyncList[0];
|
double left = _musicJumpRopeContext.UserBeatSyncList[0];
|
||||||
double right = _musicJumpRopeContext.UserBeatSyncList[1];
|
double right = _musicJumpRopeContext.UserBeatSyncList[1];
|
||||||
double total = left + right;
|
double total = left + right;
|
||||||
|
|
||||||
PkBar.LeftProgress = total == 0 ? 0 : Math.Round(left / total, 2);
|
|
||||||
|
PkBar.LeftProgress = 1 - (total == 0 ? 0.5 : Math.Round(left / total, 2));
|
||||||
if (indexCopy == 0)
|
if (indexCopy == 0)
|
||||||
{
|
{
|
||||||
popSilder1.IsMiss = false;
|
popSilder2.IsMiss = false;
|
||||||
UpdateScore(left, score1);
|
//UpdateScore(left, score1);
|
||||||
|
score2.Text = (left * 10).ToString();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UpdateScore(right,score2);
|
popSilder1.IsMiss = false;
|
||||||
popSilder2.IsMiss = false;
|
//UpdateScore(right, score2);
|
||||||
|
score1.Text = (right * 10).ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -515,7 +517,7 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateScore(double to , TextBlock score)
|
private void UpdateScore(double to, TextBlock score)
|
||||||
{
|
{
|
||||||
DoubleAnimation animation = new DoubleAnimation
|
DoubleAnimation animation = new DoubleAnimation
|
||||||
{
|
{
|
||||||
@ -528,19 +530,27 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope
|
|||||||
score.BeginAnimation(TextBlock.TextProperty, animation);
|
score.BeginAnimation(TextBlock.TextProperty, animation);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ChangeImgState(int index , string state)
|
//private void ChangeImgState(int index , string state)
|
||||||
|
//{
|
||||||
|
// if(index== 0)
|
||||||
|
// {
|
||||||
|
// left1.Visibility = state == "1" ? Visibility.Visible : Visibility.Hidden;
|
||||||
|
// left2.Visibility = state == "2" ? Visibility.Visible : Visibility.Hidden;
|
||||||
|
// left3.Visibility = state == "3" ? Visibility.Visible : Visibility.Hidden;
|
||||||
|
// }else if (index == 1)
|
||||||
|
// {
|
||||||
|
// right1.Visibility = state == "1" ? Visibility.Visible : Visibility.Hidden;
|
||||||
|
// right2.Visibility = state == "1" ? Visibility.Visible : Visibility.Hidden;
|
||||||
|
// right3.Visibility = state == "1" ? Visibility.Visible : Visibility.Hidden;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
public void ShowMusicAnimation()
|
||||||
{
|
{
|
||||||
if(index== 0)
|
ImageBehavior.SetRepeatBehavior(leftm, RepeatBehavior.Forever);
|
||||||
{
|
ImageBehavior.SetRepeatBehavior(rightm, RepeatBehavior.Forever);
|
||||||
left1.Visibility = state == "1" ? Visibility.Visible : Visibility.Hidden;
|
ImageBehavior.GetAnimationController(leftm).Play();
|
||||||
left2.Visibility = state == "2" ? Visibility.Visible : Visibility.Hidden;
|
ImageBehavior.GetAnimationController(rightm).Play();
|
||||||
left3.Visibility = state == "3" ? Visibility.Visible : Visibility.Hidden;
|
|
||||||
}else if (index == 1)
|
|
||||||
{
|
|
||||||
right1.Visibility = state == "1" ? Visibility.Visible : Visibility.Hidden;
|
|
||||||
right2.Visibility = state == "1" ? Visibility.Visible : Visibility.Hidden;
|
|
||||||
right3.Visibility = state == "1" ? Visibility.Visible : Visibility.Hidden;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateCircleCounts(List<Human> humans)
|
private void UpdateCircleCounts(List<Human> humans)
|
||||||
@ -585,9 +595,9 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope
|
|||||||
bool hasHuman = humanInCircle != null;
|
bool hasHuman = humanInCircle != null;
|
||||||
lock (_updateLock)
|
lock (_updateLock)
|
||||||
{
|
{
|
||||||
//_musicJumpRopeContext.UserList[i].ImageState = GetJumpState(i, hasHuman);
|
_musicJumpRopeContext.UserList[i].ImageState = GetJumpState(i, hasHuman);
|
||||||
var state = GetJumpState(i, hasHuman);
|
//var state = GetJumpState(i, hasHuman);
|
||||||
ChangeImgState(i, state);
|
//ChangeImgState(i, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 推送计数
|
// 推送计数
|
||||||
@ -631,7 +641,19 @@ namespace Wpf_AiSportsMicrospace.Views.JumpRope
|
|||||||
return lastState;
|
return lastState;
|
||||||
}
|
}
|
||||||
|
|
||||||
userItem.Margin = new Thickness(centerX + 120, centerY - 700, 0, 0);
|
private MusicUserItem AddUserItem(double centerX, double centerY, int index)
|
||||||
|
{
|
||||||
|
var userItem = new MusicUserItem();
|
||||||
|
userItem.VerticalAlignment = VerticalAlignment.Top;
|
||||||
|
userItem.HorizontalAlignment = index == 1 ? HorizontalAlignment.Left : HorizontalAlignment.Right;
|
||||||
|
userItem.ImageState = "1";
|
||||||
|
userItem.Margin = index == 1 ? new Thickness(226, 345, 0, 0) : new Thickness(0, 345, 226, 0);
|
||||||
|
userBox.Children.Add(userItem);
|
||||||
|
_musicJumpRopeContext.UserList.Add(userItem);
|
||||||
|
_musicJumpRopeContext.UserNumberList.Add("0");
|
||||||
|
_musicJumpRopeContext.UserBeatSyncList.Add(0);
|
||||||
|
return userItem; //
|
||||||
|
}
|
||||||
|
|
||||||
private void Image_MouseDown(object sender, MouseButtonEventArgs e)
|
private void Image_MouseDown(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:local="clr-namespace:Wpf_AiSportsMicrospace.Views"
|
xmlns:local="clr-namespace:Wpf_AiSportsMicrospace.Views"
|
||||||
xmlns:gif="http://wpfanimatedgif.codeplex.com"
|
xmlns:gif="http://wpfanimatedgif.codeplex.com"
|
||||||
|
WindowStyle="None"
|
||||||
mc:Ignorable="d" WindowState="Maximized">
|
mc:Ignorable="d" WindowState="Maximized">
|
||||||
<Grid>
|
<Grid>
|
||||||
<!-- 过渡容器 -->
|
<!-- 过渡容器 -->
|
||||||
|
|||||||
@ -43,6 +43,7 @@
|
|||||||
<None Remove="Resources\Img\gif\bottom_animation_image.png" />
|
<None Remove="Resources\Img\gif\bottom_animation_image.png" />
|
||||||
<None Remove="Resources\Img\gif\time_3.gif" />
|
<None Remove="Resources\Img\gif\time_3.gif" />
|
||||||
<None Remove="Resources\Img\gif\top_animation_image.png" />
|
<None Remove="Resources\Img\gif\top_animation_image.png" />
|
||||||
|
<None Remove="Resources\Img\play_img\music_rope\bg_mic.gif" />
|
||||||
<None Remove="Resources\Img\play_img\music_rope\great-p.png" />
|
<None Remove="Resources\Img\play_img\music_rope\great-p.png" />
|
||||||
<None Remove="Resources\Img\play_img\music_rope\great.png" />
|
<None Remove="Resources\Img\play_img\music_rope\great.png" />
|
||||||
<None Remove="Resources\Img\play_img\music_rope\head_g.png" />
|
<None Remove="Resources\Img\play_img\music_rope\head_g.png" />
|
||||||
@ -51,7 +52,7 @@
|
|||||||
<None Remove="Resources\Img\play_img\music_rope\jump_u.png" />
|
<None Remove="Resources\Img\play_img\music_rope\jump_u.png" />
|
||||||
<None Remove="Resources\Img\play_img\music_rope\miss.png" />
|
<None Remove="Resources\Img\play_img\music_rope\miss.png" />
|
||||||
<None Remove="Resources\Img\play_img\music_rope\out_u.png" />
|
<None Remove="Resources\Img\play_img\music_rope\out_u.png" />
|
||||||
<None Remove="Resources\Img\play_img\music_rope\play_bg.png" />
|
<None Remove="Resources\Img\play_img\music_rope\play_bg.jpg" />
|
||||||
<None Remove="Resources\Img\play_img\music_rope\point.png" />
|
<None Remove="Resources\Img\play_img\music_rope\point.png" />
|
||||||
<None Remove="Resources\Img\play_img\music_rope\title.png" />
|
<None Remove="Resources\Img\play_img\music_rope\title.png" />
|
||||||
<None Remove="Resources\Img\play_img\music_rope\vs.png" />
|
<None Remove="Resources\Img\play_img\music_rope\vs.png" />
|
||||||
@ -93,6 +94,9 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Resource Include="Resources\Img\play_img\music_rope\bg_mic.gif">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Resource>
|
||||||
<Resource Include="Resources\Img\play_img\music_rope\great-p.png">
|
<Resource Include="Resources\Img\play_img\music_rope\great-p.png">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Resource>
|
</Resource>
|
||||||
@ -260,7 +264,7 @@
|
|||||||
<Resource Include="Resources\Img\play_img\music_rope\out_u.png">
|
<Resource Include="Resources\Img\play_img\music_rope\out_u.png">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Resource>
|
</Resource>
|
||||||
<Resource Include="Resources\Img\play_img\music_rope\play_bg.png">
|
<Resource Include="Resources\Img\play_img\music_rope\play_bg.jpg">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Resource>
|
</Resource>
|
||||||
<Resource Include="Resources\Img\play_img\music_rope\point.png">
|
<Resource Include="Resources\Img\play_img\music_rope\point.png">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user