/// <summary> /// The on flipping completed. /// </summary> /// <param name="sender"> The sender. </param> /// <param name="e"> The e. </param> protected virtual void OnFlippingCompleted(object sender, EventArgs e) { try { ClockGroup clockGroup = (ClockGroup)sender; Storyboard storyboard = (Storyboard)clockGroup.Timeline; IsFlipping = false; if (storyboard != null) { storyboard.Stop(); storyboard.Remove(); if (ItemsSource != null) { int count = ItemsSource.Cast <object>().Count(); if (SelectedIndexProxy == count - 1) { SelectedIndex = SelectedIndexProxy; } else { SelectedIndexProxy = count - 1; } } } } catch { } }
void s_Completed(object sender, EventArgs e) { ClockGroup group = sender as ClockGroup; Storyboard sb = group.Timeline as Storyboard; Label lb = Storyboard.GetTarget((DoubleAnimation)sb.Children[0]) as Label; lb.Opacity = 1; sb.Remove(); }
void s1_Completed(object sender, EventArgs e) { ClockGroup group = sender as ClockGroup; Storyboard sb = group.Timeline as Storyboard; ComboBox cb = Storyboard.GetTarget((DoubleAnimation)sb.Children[0]) as ComboBox; string name = cb.Name; cb.Opacity = 1; sb.Remove(); }
private void storyboard1_Completed(object sender, EventArgs e) { // when the explosion animation is finished, clear the canvas from the blast icon ClockGroup clockGroup = (ClockGroup)sender; DoubleAnimation completedAnimation = (DoubleAnimation)clockGroup.Children[0].Timeline; Blast completedBlast = (Blast)Storyboard.GetTarget(completedAnimation); playground.Children.Remove(completedBlast); }
private void storyboard_Completed(object sender, EventArgs e) { ClockGroup clockGroup = (ClockGroup)sender; // Get the first animation in the storyboard, and use it to find the // bomb that's being animated. DoubleAnimation completedAnimation = (DoubleAnimation)clockGroup.Children[0].Timeline; Bomb completedBomb = (Bomb)Storyboard.GetTarget(completedAnimation); // Determine if a bomb fell or flew off the Canvas after being clicked. if (completedBomb.IsFalling) { droppedCount++; } else { savedCount++; } // Update the display. lblStatus.Text = String.Format("You have dropped {0} bombs and saved {1}.", droppedCount, savedCount); // Check if it's game over. if (droppedCount >= maxDropped) { bombTimer.Stop(); lblStatus.Text += "\r\n\r\nGame over."; // Find all the storyboards that are underway. foreach (KeyValuePair <Bomb, Storyboard> item in storyboards) { Storyboard storyboard = item.Value; Bomb bomb = item.Key; storyboard.Stop(); canvasBackground.Children.Remove(bomb); } // Empty the tracking collection. storyboards.Clear(); // Allow the user to start a new game. cmdStart.IsEnabled = true; } else { Storyboard storyboard = (Storyboard)clockGroup.Timeline; storyboard.Stop(); storyboards.Remove(completedBomb); canvasBackground.Children.Remove(completedBomb); } }
private void sb_Completed(object sender, EventArgs e) { ClockGroup clockGroup = sender as ClockGroup; if (clockGroup != null) { DanmakuTextControl danmakuTextControl = Storyboard.GetTarget(clockGroup.Children[2].Timeline) as DanmakuTextControl; if (danmakuTextControl != null) { this.overlay.LayoutRoot.Children.Remove(danmakuTextControl); } } }
private void s_Completed(object sender, EventArgs e) { ClockGroup clockGroup = sender as ClockGroup; if (clockGroup != null) { FullScreenDanmaku fullScreenDanmaku = Storyboard.GetTarget(clockGroup.Children[0].Timeline) as FullScreenDanmaku; if (fullScreenDanmaku != null) { this.fulloverlay.LayoutRoot.Children.Remove(fullScreenDanmaku); } } }
// Updates the position slider when the media time changes. private void Storyboard_Changed(object sender, EventArgs e) { ClockGroup clockGroup = sender as ClockGroup; MediaClock mediaClock = clockGroup.Children[0] as MediaClock; if (mediaClock.CurrentProgress.HasValue) { ignoreValueChanged = true; sldPosition.Value = meMediaElement.Position.TotalMilliseconds; ignoreValueChanged = false; } }
private void Storyboard_Changed(object sender, System.EventArgs e) { ClockGroup clockGroup = sender as ClockGroup; AnimationClock animationClock = clockGroup.Children[0] as AnimationClock; if (animationClock.CurrentProgress.HasValue) { ignoreValueChanged = true; Seeker.Value = animationClock.CurrentProgress.Value; ignoreValueChanged = false; } }
public void ApplySpriteClocks(ClockGroup clockGroup) { if (clockGroup == null) { SpriteClocks = null; return; } SpriteClocks = new AnimationClock[clockGroup.Children.Count]; int index = 0; foreach (Clock clock in clockGroup.Children) { SpriteClocks[index] = (AnimationClock)clock; index++; } }
private void OnAnimationCompleted(object sender, EventArgs e) { ClockGroup clockGroup = (ClockGroup)sender; clockGroup.Completed -= OnAnimationCompleted; ColorAnimation c1 = clockGroup.Timeline.Children[0] as ColorAnimation; ColorAnimation c2 = clockGroup.Timeline.Children[1] as ColorAnimation; GetColorAnimation( c1.To.GetValueOrDefault(), c2.To.GetValueOrDefault(), GetNextColorCombination()) .Begin(); }
private void storyboard_Completed(object sender, EventArgs e) { ClockGroup clockGroup = (ClockGroup)sender; DoubleAnimation completedAnimation = (DoubleAnimation)clockGroup.Children[0].Timeline; Balloon completedBalloon = (Balloon)Storyboard.GetTarget(completedAnimation); // suspend the storyboard of finished animation and // remove it from the dictionary Storyboard storyboard = (Storyboard)clockGroup.Timeline; storyboard.Stop(); storyboards.Remove(completedBalloon); // remove the balloon that flew away playground.Children.Remove(completedBalloon); }
///////////////////////////////////////////////////////////////////////////////////////////////////// // NON-PUBLIC PROCEDURES ///////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Occurs when the storyboard completes. /// </summary> /// <param name="sender">The sender of the event.</param> /// <param name="e">A <see cref="EventArgs"/> that contains the event data.</param> private void OnStoryboardCompleted(object sender, EventArgs e) { // This event assumes a ClockGroup is passed with the Storyboard as its Timeline ClockGroup cg = sender as ClockGroup; if (cg != null) { Storyboard sb = cg.Timeline as Storyboard; if (sb != null) { // Clean up and remove any adornments that are tagged with the storyboard's name this.AdornmentLayer.RemoveAdornments(AdornmentChangeReason.Other, this.AdornmentLayer.FindAdornments(sb.Name)); return; } } }
protected void OnCurrentFinished2(object sender, EventArgs e) { ClockGroup sender_cg = (ClockGroup)sender; Storyboard sender_sb = (Storyboard)sender_cg.Timeline; if (sender_sb == null) { return; } int nextPos = ElementIndexer.GetPos(sender_sb); if ((nextPos == -1) || (Animates.Count <= nextPos)) { return; } Animates[nextPos].Begin(_obj); }
public void ApplyAnimations(ClockGroup clockGroup) { if (Control == null) { return; } Control.VisibilityClock = (AnimationClock)clockGroup.Children[0]; SetEndVisibility(); Control.ApplyPositionAnimation((AnimationClock)clockGroup.Children[1], (AnimationClock)clockGroup.Children[2]); Control.OpacityClock = (AnimationClock)clockGroup.Children[3]; Control.ApplyScaleAnimation((AnimationClock)clockGroup.Children[4], (AnimationClock)clockGroup.Children[5]); Control.ApplyAngleAnimation((AnimationClock)clockGroup.Children[6]); if (Control is UISpriteCollectionModel spriteCollectionModel) { spriteCollectionModel.ApplySpriteClocks((ClockGroup)clockGroup.Children[7]); } }
/// Starts the next command on the queue. /// </summary> public void Begin() { // The original 'Completed' event for a ParallelTimeline appears to trigger before all the child clocks have finished. To work around this feature // (problem), each clock in this group is counted. A event will trigger at the completion of each of the component clocks that will decrement this // counter. Only when all the events have triggered will the new 'Completed' event be raised. InitializeTimeline(this); // The Timeline contains the logic to create a clock for itself and any children of that timeline. Note that a reference to the created clock is // required here so that the clock won't be garbage collected while the animation is running. This field has no other purpose. Without the // reference, the clock sometimes miss the 'Completed' event because it has been garbage collected while running. this.clockGroup = this.CreateClock(); // The clocks created above are abstract: they count, but don't really change anything. This will apply the output of the clocks to real // properties on real objects. The interface appears clumsy to this author; my guess is that Storyboards were meant to do most of the work of // animation. Storyboards, however, require names and a namescope, which implies a more-or-less static existence for the animated objects. The // more dynamic parts of an application require a more flexible approach. The timelines handled here use attached properties to make the // associations between the clocks and their target properties. for (int clockIndex = 0; clockIndex < clockGroup.Children.Count; clockIndex++) { // Each of the child clocks has a child timeline associated with it. Note that the child Timeline here is a frozen copy of the original // timeline. Clock childClock = clockGroup.Children[clockIndex]; Timeline childTimeline = this.Children[clockIndex]; // Child clocks that animate properties are associated with the target property here. if (childClock is AnimationClock) { // The Attached Properties of the Timeline are used to find the target for the animation clock. The 'Target' and 'Property' direct the // output of the clock to a specific property. AnimationClock animationClock = childClock as AnimationClock; IAnimatable iAnimatable = Storyline.GetTargetObject(childTimeline); DependencyProperty dependencyProperty = Storyline.GetTargetProperty(childTimeline); if (iAnimatable != null && dependencyProperty != null) { iAnimatable.ApplyAnimationClock(dependencyProperty, animationClock); } } } // This is essentially a bug workaround. The clocks should start up at a time determined by the 'BeginTime'. However, the NullTimelines, which // have a duration of zero, will not start spontaneously. This call is unnecessary for most clocks but serves to kick the NullTimelines into gear. this.clockGroup.Controller.Begin(); }
private void Storyboard_Changed(object sender, EventArgs e) { if (endAnimationTime == null) { return; } ClockGroup clockGroup = sender as ClockGroup; if (clockGroup != null) { MediaClock mediaClock = clockGroup.Children[0] as MediaClock; if (mediaClock.CurrentProgress.HasValue) { if (mediaClock.CurrentTime >= endAnimationTime) { PlayerStoryboard.Pause(mediaElement); } } } }
private void MarkerStoryboard_CurrentTimeInvalidated(object sender, EventArgs e) { if (endAnimationTime == null) { return; } ClockGroup clockGroup = sender as ClockGroup; if (clockGroup?.Children.Count > 0) { AnimationClock mediaClock = clockGroup.Children[0] as AnimationClock; if (mediaClock.CurrentProgress.HasValue) { if (mediaClock.CurrentTime >= endAnimationTime) { MarkerStoryboard.Pause(PositionBar); } } } }
private void Storyboard_Completed(object sender, EventArgs e) { ClockGroup clockGroup = (ClockGroup)sender; DoubleAnimation completedAnimation = (DoubleAnimation)clockGroup.Children[0].Timeline; Bomb completedBomb = (Bomb)Storyboard.GetTarget(completedAnimation); if (completedBomb.IsFalling) { droppedCount++; } else { savedCount++; } lblStatus.Text = string.Format("You have dropped {0} bombs and saved {1}", droppedCount, savedCount); if (droppedCount >= maxDropped) { bombTimer.Stop(); lblStatus.Text += "\r\n\r\nGame over."; foreach (KeyValuePair <Bomb, Storyboard> item in storyboards) { Storyboard storyboard = item.Value; Bomb bomb = item.Key; storyboard.Stop(); canvasBackground.Children.Remove(bomb); } storyboards.Clear(); cmdStart.IsEnabled = true; } else { Storyboard storyboard = (Storyboard)clockGroup.Timeline; storyboard.Stop(); storyboards.Remove(completedBomb); canvasBackground.Children.Remove(completedBomb); } }
/// <summary> /// 动画完成触发事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void storyboard_Completed(object sender, EventArgs e) { ClockGroup clockGroup = (ClockGroup)sender; DoubleAnimation completedAnimation = (DoubleAnimation)clockGroup.Children[0].Timeline; AnimalsTemplate completedAnimals = (AnimalsTemplate)Storyboard.GetTarget(completedAnimation); if (completedAnimals.IsMoving) { escapeCount++; } // 检查游戏是否结束 if ((escapeCount + killedCount) > maxReleasedAnimals) { animalsTimer.Stop(); // 找到所有正在进行的故事板 foreach (KeyValuePair <AnimalsTemplate, Storyboard> item in storyboards) { Storyboard storyboard = item.Value; AnimalsTemplate animalsTemplate = item.Key; storyboard.Stop(); canvasBackground.Children.Remove(animalsTemplate); } storyboards.Clear(); startGame.IsEnabled = true; //if (maxBloodPoints <= 0) //{ // MessageBox.Show("你已收到10000点伤害,去地狱忏悔吧!"); //} //else //{ // if (maxBloodPoints >= 9000) MessageBox.Show("骚年,你已获得三颗星奖励!"); // if (maxBloodPoints >= 6000 && maxBloodPoints < 9000) MessageBox.Show("骚年,你已获得两颗星奖励!"); // if (maxBloodPoints < 6000) MessageBox.Show("骚年,你已获得一颗星奖励!"); //} } else { tbEscapedAnimals.Text = String.Format("逃跑动物:{0}个.", escapeCount); switch (releasedAnimal) { case "Squab": if (animalsTimer.Interval.TotalSeconds < squabTimeInterval) { double duringSeconds = squabTimeInterval - animalsTimer.Interval.TotalSeconds; animalsTimer.Interval = TimeSpan.FromSeconds(duringSeconds); } else { double duringSeconds = animalsTimer.Interval.TotalSeconds - squabTimeInterval; animalsTimer.Interval = TimeSpan.FromSeconds(duringSeconds); } maxBloodPoints = maxBloodPoints - squabDamagePoints; if (maxBloodPoints < 0) { maxBloodPoints = 0; } tbBloodPoint.Text = String.Format("玩家血量:{0}点.", maxBloodPoints); break; case "Crab": if (animalsTimer.Interval.TotalSeconds < crabTimeInterval) { double duringSeconds = crabTimeInterval - animalsTimer.Interval.TotalSeconds; animalsTimer.Interval = TimeSpan.FromSeconds(duringSeconds); } else { double duringSeconds = animalsTimer.Interval.TotalSeconds - crabTimeInterval; animalsTimer.Interval = TimeSpan.FromSeconds(duringSeconds); } maxBloodPoints = maxBloodPoints - crabDamagePoints; if (maxBloodPoints < 0) { maxBloodPoints = 0; } tbBloodPoint.Text = String.Format("玩家血量:{0}点.", maxBloodPoints); break; case "Snake": if (animalsTimer.Interval.TotalSeconds < snakeTimeInterval) { double duringSeconds = snakeTimeInterval - animalsTimer.Interval.TotalSeconds; animalsTimer.Interval = TimeSpan.FromSeconds(duringSeconds); } else { double duringSeconds = animalsTimer.Interval.TotalSeconds - snakeTimeInterval; animalsTimer.Interval = TimeSpan.FromSeconds(duringSeconds); } maxBloodPoints = maxBloodPoints - snakeDamagePoints; if (maxBloodPoints < 0) { maxBloodPoints = 0; } tbBloodPoint.Text = String.Format("玩家血量:{0}点.", maxBloodPoints); break; case "Pig": if (animalsTimer.Interval.TotalSeconds < pigTimeInterval) { double duringSeconds = pigTimeInterval - animalsTimer.Interval.TotalSeconds; animalsTimer.Interval = TimeSpan.FromSeconds(duringSeconds); } else { double duringSeconds = animalsTimer.Interval.TotalSeconds - pigTimeInterval; animalsTimer.Interval = TimeSpan.FromSeconds(duringSeconds); } maxBloodPoints = maxBloodPoints - pigDamagePoints; if (maxBloodPoints < 0) { maxBloodPoints = 0; } tbBloodPoint.Text = String.Format("玩家血量:{0}点.", maxBloodPoints); break; } Storyboard storyboard = (Storyboard)clockGroup.Timeline; storyboard.Stop(); storyboards.Remove(completedAnimals); canvasBackground.Children.Remove(completedAnimals); } }