/// <summary> /// 播放[同步图标]的动画 /// </summary> private void PlaySyncIconAnimation() { //先停止动画 StopSyncIconAnimation(); /* 动画 */ syncIconAnimation = new DoubleAnimation(); syncIconAnimation.From = 0; syncIconAnimation.To = 360; syncIconAnimation.Duration = TimeSpan.FromSeconds(1f); //1秒 syncIconAnimation.RepeatBehavior = new RepeatBehavior(SyncIconAnimationTime); //循环3次(3秒) syncIconAnimation.Completed += (sender, args) => { SyncIconAnimationStateType = AnimationStateType.End; }; //动画完成后,关闭动画 //播放动画 (让按钮的尺寸(Scale) 变小/变大) SyncIconBorderRotateTransform.BeginAnimation(RotateTransform.AngleProperty, syncIconAnimation, HandoffBehavior.SnapshotAndReplace); }
/// <summary> /// 停止[同步图标]的动画 /// </summary> private void StopSyncIconAnimation() { //停止动画 SyncIconBorderRotateTransform.BeginAnimation(RotateTransform.AngleProperty, null, HandoffBehavior.SnapshotAndReplace); }