void TransitionCompleted(object sender, EventArgs e) { VideoStoryCreator.Transitions.ITransition transition = (VideoStoryCreator.Transitions.ITransition)sender; // 如果没有被transition修改,则修改z-index. if (!transition.ImageZIndexModified) { this.backgroundImage.SetValue(Canvas.ZIndexProperty, 2); this.foregroundImage.SetValue(Canvas.ZIndexProperty, 0); } transition.Stop(); this.GoToNext(); }
void DispatcherTimer_Tick(object sender, EventArgs e) { this.backgroundImage.Opacity = 1; VideoStoryCreator.Transitions.ITransition transition = App.MediaCollection[this._currentImageIndex - 1].Transition; // 显示transition若它不为空. // 这个task被委托到transition类. if (transition != null) { transition.ForegroundElement = this.foregroundImage; transition.BackgroundElement = this.backgroundImage; transition.TransitionCompleted += new EventHandler(TransitionCompleted); transition.Begin(); this._dispatcherTimer.Stop(); } // 没有transition,从下张图片开始. else { this._dispatcherTimer.Stop(); this.backgroundImage.SetValue(Canvas.ZIndexProperty, 2); this.foregroundImage.SetValue(Canvas.ZIndexProperty, 0); this.GoToNext(); } }