XML学习
代码说明:
public Turntable() { InitializeComponent(); int angle = 5029; for (int i = 0; i < 16; i ) { angle = 22; _ListAngle.Add(angle); } } /// /// 保存八个角度 /// List _ListAngle = new List(); /// /// 产生随机数 /// Random _Random = new Random(); int _Index = 0; int _OldAngle = 0; private void btnStartTurntable_Click(object sender, RoutedEventArgs e) { btnStartTurntable.IsEnabled = false; _Index = _Random.Next(0, 16); //_Index = 2; Storyboard sb = (Storyboard)this.FindResource("zhuandong"); sb.Completed -= this.sb_Completed; sb.Completed = new EventHandler(sb_Completed); ((SplineDoubleKeyFrame)((DoubleAnimationUsingKeyFrames)sb.Children[0]).KeyFrames[0]).Value = _OldAngle; ((SplineDoubleKeyFrame)((DoubleAnimationUsingKeyFrames)sb.Children[0]).KeyFrames[3]).Value = _ListAngle[_Index]; //((SplineDoubleKeyFrame)((DoubleAnimationUsingKeyFrames)sb.Children[0]).KeyFrames[3]).Value = 5218; sb.Begin(); } void sb_Completed(object sender, EventArgs e) { DispatcherTimer dt = new DispatcherTimer(); dt.Interval = TimeSpan.FromSeconds(0.3); dt.Tick = delegate { dt.Stop(); _OldAngle = (_ListAngle[_Index] % 360); btnStartTurntable.IsEnabled = true; AwardProcess(GetAward(_ListAngle[_Index])); }; dt.Start(); } public delegate void AwardDelegate(Award award); /// /// 返回转到的奖项信息 /// public event AwardDelegate AwardProcess; private Award GetAward(int angle) {
下载说明:请别用迅雷下载,失败请重下,重下不扣分!