/// <summary> /// 显示动弹对象 /// </summary> /// <param name="t">动弹对象</param> private void DisplayTweet(TweetUnit t) { this. currentTweet = t; //开始关闭动画 (建议 Fade) this. fadeOut. Begin( ); this. fadeOut. Completed += (s, e) => { //然后控件转变 this. lblName. Text = string. Format( "{0}:", t. author ); this. lblContent. Text = t. body; this. lblComment. Text = string. Format( "{0} {1}评", t. pubDateFormat, t. commentCount ); this. imgPortrait. Source = new BitmapImage( new Uri( t. portrait. IsNotNullOrWhitespace( ) ? t. portrait : "/Resource/avatar_noimg.jpg", UriKind. RelativeOrAbsolute ) ); //最后执行上移动画 this. fadeIn. Begin( ); }; }
/// <summary> /// 获取下一个动弹对象 /// </summary> /// <param name="tweets">动弹集合</param> private void GetNextTweetUnit(TweetUnit[ ] tweets) { if ( tweets != null && tweets. Length > 0 ) { TweetUnit t = tweets[ 0 ]; for ( int i = 0 ; i < tweets. Length ; i++ ) { if ( tweets[ i ]. id == tweetID ) { //返回下一项 t = i < tweets. Length - 1 ? tweets[ i + 1 ] : tweets[ 0 ]; break; } } //获取下一项 this. tweetID = t. id; this. DisplayTweet( t ); } }