private void MainWindow_MouseLeave(object sender, MouseEventArgs e) { if (!WelcomePageON) { ColorAnimation anim = new ColorAnimation((Color)mainWindow.TryFindResource("OverflowColor"), new Duration(new TimeSpan(0, 0, 0, 0, 500))); windowNeon.BeginAnimation(DropShadowEffect.ColorProperty, anim); } }
public void animateButton(Button button, string upDown) { //Setting the duration of the animation in milliseconds TimeSpan duration = TimeSpan.FromMilliseconds(500); //Animates over 2 values, from and to over a timeframe DoubleAnimation animateOpacity; if (upDown == "UP") { animateOpacity = new DoubleAnimation() { From = 0, To = 1, Duration = duration, }; } else { animateOpacity = new DoubleAnimation() { From = 1, To = 0, Duration = duration, }; } DropShadowEffect dropShadowEffect = new DropShadowEffect(); //Animates the chosen effect with the animation properties set above dropShadowEffect.BeginAnimation(DropShadowEffect.OpacityProperty, animateOpacity); //Execute the effect. button.Effect = dropShadowEffect; }
private void UpdateGlowEffect(UIElement element, Boolean addGlow, int glowSize, Color color1, Color color2) { if (addGlow) { DropShadowEffect dse = Caching.DropShadowRepository.GetDSE(glowSize, color1, 0.85, false); ColorAnimation ca = new ColorAnimation() { From = color1, To = color2, Duration = TimeSpan.FromSeconds(1), AutoReverse = true, RepeatBehavior = RepeatBehavior.Forever, AccelerationRatio = 0.4, }; DoubleAnimation da = new DoubleAnimation() { From = glowSize * 2 / 3, To = glowSize * 1.5, Duration = TimeSpan.FromSeconds(1), AutoReverse = true, RepeatBehavior = RepeatBehavior.Forever, AccelerationRatio = 0.4, }; dse.BeginAnimation(DropShadowEffect.ColorProperty, ca); dse.BeginAnimation(DropShadowEffect.BlurRadiusProperty, da); element.Effect = dse; this.IsClickable = true; bImages.Cursor = bName.Cursor = Cursors.Hand; } else { element.Effect = null; this.IsClickable = false; bImages.Cursor = bName.Cursor = null; } }
public void animateTextBox(Control textBox, string upDown) { //Setting the duration of the animation in milliseconds TimeSpan duration = TimeSpan.FromMilliseconds(500); //Animates over 2 values, from and to over a timeframe DoubleAnimation animateOpacity; if (upDown == "UP") { animateOpacity = new DoubleAnimation() { From = 0, To = 1, Duration = duration, }; } else { animateOpacity = new DoubleAnimation() { From = 1, To = 0, Duration = duration, }; } //Pulses /* DoubleAnimation animateOpacity = new DoubleAnimation() * { * From = 0, * To = 1, * Duration = duration, * AutoReverse = true * }; */ DropShadowEffect dropShadowEffect = new DropShadowEffect(); //Animates the chosen effect with the animation properties set above dropShadowEffect.BeginAnimation(DropShadowEffect.OpacityProperty, animateOpacity); //Execute the effect. textBox.Effect = dropShadowEffect; }
/// <summary> /// 变更精灵的投影效果动画 /// <para>这是一个特效互斥动画,多个特效互斥动画之间不叠加</para> /// </summary> /// <param name="sprite">精灵对象</param> /// <param name="duration">动画时长</param> /// <param name="shadColor">投影颜色</param> /// <param name="shadOpacity">投影不透明度</param> /// <param name="fromRadius">起始模糊半径</param> /// <param name="toRadius">目标模糊半径</param> public static void ShadowingMutexAnimation(YuriSprite sprite, Duration duration, Color shadColor, double shadOpacity, double fromRadius, double toRadius) { if (duration.TimeSpan.TotalMilliseconds == 0 || GlobalConfigContext.GAME_PERFORMANCE_TYPE == GlobalConfigContext.PerformanceType.NoEffect) { DropShadowEffect m_DSEffect = new DropShadowEffect(); sprite.AnimationElement.Effect = m_DSEffect; m_DSEffect.RenderingBias = GlobalConfigContext.GAME_PERFORMANCE_TYPE == GlobalConfigContext.PerformanceType.HighQuality ? RenderingBias.Quality : RenderingBias.Performance; m_DSEffect.BlurRadius = toRadius; m_DSEffect.Color = shadColor; m_DSEffect.Opacity = shadOpacity; sprite.Descriptor.ShadowRadius = toRadius; } else { DropShadowEffect m_DSEffect = new DropShadowEffect(); sprite.AnimationElement.Effect = m_DSEffect; m_DSEffect.RenderingBias = GlobalConfigContext.GAME_PERFORMANCE_TYPE == GlobalConfigContext.PerformanceType.HighQuality ? RenderingBias.Quality : RenderingBias.Performance; m_DSEffect.Color = shadColor; m_DSEffect.Opacity = shadOpacity; DoubleAnimation m_DA = new DoubleAnimation { From = fromRadius, To = toRadius, Duration = duration, EasingFunction = new CubicEase(), }; sprite.AnimateCount++; var flagSb = new Storyboard { Name = "FlagSb_" + Guid.NewGuid() }; SpriteAnimation.aniDict[flagSb] = sprite; m_DA.Completed += (sender, args) => { sprite.Descriptor.BlurRadius = sprite.Descriptor.ToBlurRadius; m_DSEffect.BlurRadius = toRadius; sprite.AnimateCount--; aniDict.Remove(flagSb); }; m_DSEffect.BeginAnimation(BlurEffect.RadiusProperty, m_DA); } }
public void MoveTo(double newX, double newY, bool bIsLadder = false) { if (_parentWindow != null) { _parentWindow.ResizeMode = ResizeMode.NoResize; } double prevMainCircleTop = MainCircleTop, prevMainCircleLeft = MainCircleLeft, prevOuterRingTop = OuterRingTop, prevOuterRingLeft = OuterRingLeft, prevInnerRingTop = InnerRingTop, prevInnerRingLeft = InnerRingLeft; _centerPoint.X = newX; _centerPoint.Y = newY; double duration = Math.Max(Math.Abs(MainCircleTop - prevMainCircleTop) / durationfactor, Math.Abs(MainCircleLeft - prevMainCircleLeft) / durationfactor); tokenAnimation.Duration = TimeSpan.FromSeconds(duration > 0.0 ? duration : 0.1); tokenAnimation.From = prevMainCircleTop; tokenAnimation.To = MainCircleTop; this.BeginAnimation(Canvas.TopProperty, tokenAnimation); tokenAnimation.From = prevMainCircleLeft; tokenAnimation.To = MainCircleLeft; this.BeginAnimation(Canvas.LeftProperty, tokenAnimation); tokenAnimation.From = prevOuterRingTop; tokenAnimation.To = OuterRingTop; _outerRing.BeginAnimation(Canvas.TopProperty, tokenAnimation); tokenAnimation.From = prevOuterRingLeft; tokenAnimation.To = OuterRingLeft; _outerRing.BeginAnimation(Canvas.LeftProperty, tokenAnimation); tokenAnimation.From = prevInnerRingTop; tokenAnimation.To = InnerRingTop; _innerRing.BeginAnimation(Canvas.TopProperty, tokenAnimation); tokenAnimation.From = prevInnerRingLeft; tokenAnimation.To = InnerRingLeft; _innerRing.BeginAnimation(Canvas.LeftProperty, tokenAnimation); DropShadowEffect shadowEffect = new DropShadowEffect(); shadowEffect.ShadowDepth = 0; shadowEffect.Color = System.Windows.Media.Colors.LightGoldenrodYellow;// (System.Windows.Media.Color)(_color.GetValue(SolidColorBrush.ColorProperty)); shadowEffect.BlurRadius = MainCircleWidth; MainCircle.Effect = shadowEffect; DoubleAnimation shadowAnimation = new DoubleAnimation(); shadowAnimation.From = MainCircleWidth; shadowAnimation.To = 0; shadowAnimation.Duration = TimeSpan.FromSeconds(duration / 4.0 > 0.0 ? duration / 4.0 : 0.1); shadowAnimation.RepeatBehavior = new RepeatBehavior(2); shadowAnimation.AutoReverse = true; shadowAnimation.Completed += Animation_Completed; shadowAnimation.FillBehavior = FillBehavior.Stop; shadowEffect.BeginAnimation(DropShadowEffect.BlurRadiusProperty, shadowAnimation); if (bIsLadder) { _tokenLadderMoveSound.Play(); } else { _tokenMoveSound.PlayLooping(); } //_tokenMoveSound.Play(); }
/*public void MoveTo(Point newPos) * { * Storyboard story = new Storyboard(); * DoubleAnimation dbWidth = new DoubleAnimation(); * dbWidth.From = mediaElement1.Width; * dbWidth.To = 600; * dbWidth.Duration = new Duration(TimeSpan.FromSeconds(.25)); * * DoubleAnimation dbHeight = new DoubleAnimation(); * dbHeight.From = mediaElement1.Height; * dbHeight.To = 400; * dbHeight.Duration = dbWidth.Duration; * * story.Children.Add(dbWidth); * Storyboard.SetTargetName(dbWidth, mediaElement1.Name); * Storyboard.SetTargetProperty(dbWidth, new PropertyPath(MediaElement.WidthProperty)); * * story.Children.Add(dbHeight); * Storyboard.SetTargetName(dbHeight, mediaElement1.Name); * Storyboard.SetTargetProperty(dbHeight, new PropertyPath(MediaElement.HeightProperty)); * * DoubleAnimation dbCanvasX = new DoubleAnimation(); * dbCanvasX.From = 0; * dbCanvasX.To = 5; * dbCanvasX.Duration = new Duration(TimeSpan.FromSeconds(.25)); * * DoubleAnimation dbCanvasY = new DoubleAnimation(); * dbCanvasY.From = 0; * dbCanvasY.To = 5; * dbCanvasY.Duration = dbCanvasX.Duration; * * story.Children.Add(dbCanvasX); * Storyboard.SetTargetName(dbCanvasX, mediaElement1.Name); * Storyboard.SetTargetProperty(dbCanvasX, new PropertyPath(Canvas.LeftProperty)); * * story.Children.Add(dbCanvasY); * Storyboard.SetTargetName(dbCanvasY, mediaElement1.Name); * Storyboard.SetTargetProperty(dbCanvasY, new PropertyPath(Canvas.TopProperty)); * * story.Begin(this); * }*/ public void MoveToAlongPath(Point newPos, ref Path snakePath) { if (_parentWindow != null) { _parentWindow.ResizeMode = ResizeMode.NoResize; } double prevMainCircleTop = MainCircleTop, prevMainCircleLeft = MainCircleLeft; _centerPoint.X = newPos.X; _centerPoint.Y = newPos.Y; double duration = Math.Max(Math.Abs(MainCircleTop - prevMainCircleTop) / durationfactor, Math.Abs(MainCircleLeft - prevMainCircleLeft) / durationfactor); DoubleAnimationUsingPath anim = new DoubleAnimationUsingPath(); anim.PathGeometry = snakePath.Data as PathGeometry; anim.Duration = TimeSpan.FromSeconds(duration > 0.0 ? duration : 0.1); anim.Source = PathAnimationSource.X; anim.FillBehavior = FillBehavior.Stop; this.BeginAnimation(Canvas.LeftProperty, anim); anim.Source = PathAnimationSource.Y; this.BeginAnimation(Canvas.TopProperty, anim); double marginVal = (_mainCircleDiameter - (_mainCircleDiameter * (2.0 / 3.0))) / 2; Path outerRingPath = snakePath.Clone(marginVal, marginVal); anim.PathGeometry = outerRingPath.Data as PathGeometry; anim.Source = PathAnimationSource.X; _outerRing.BeginAnimation(Canvas.LeftProperty, anim); anim.Source = PathAnimationSource.Y; _outerRing.BeginAnimation(Canvas.TopProperty, anim); marginVal = (_mainCircleDiameter - (_mainCircleDiameter * (1.0 / 3.0))) / 2; Path innerRingPath = snakePath.Clone(marginVal, marginVal); anim.PathGeometry = innerRingPath.Data as PathGeometry; anim.Source = PathAnimationSource.X; _innerRing.BeginAnimation(Canvas.LeftProperty, anim); anim.Source = PathAnimationSource.Y; _innerRing.BeginAnimation(Canvas.TopProperty, anim); DropShadowEffect shadowEffect = new DropShadowEffect(); shadowEffect.ShadowDepth = 0; shadowEffect.Color = System.Windows.Media.Colors.OrangeRed;// (System.Windows.Media.Color)(_color.GetValue(SolidColorBrush.ColorProperty)); shadowEffect.BlurRadius = MainCircleWidth; MainCircle.Effect = shadowEffect; DoubleAnimation shadowAnimation = new DoubleAnimation(); shadowAnimation.From = MainCircleWidth; shadowAnimation.To = 0; shadowAnimation.Duration = TimeSpan.FromSeconds(duration / 4.0 > 0.0 ? duration / 4.0 : 0.1); shadowAnimation.RepeatBehavior = new RepeatBehavior(2); shadowAnimation.AutoReverse = true; shadowAnimation.Completed += Animation_Completed; shadowAnimation.FillBehavior = FillBehavior.Stop; shadowEffect.BeginAnimation(DropShadowEffect.BlurRadiusProperty, shadowAnimation); _tokenSnakeMoveSound.Play(); }
/// <summary> /// This method is used to move the token to a new position defined by newX and newY on the canvas. /// </summary> /// <param name="newX">New x value of center point of the token.</param> /// <param name="newY">New y value of center point of the token.</param> /// <param name="bIsLadder">Identifier to tell if we are moving through the ladder or its a simple move.</param> public void MoveTo(double newX, double newY, bool bIsLadder = false) { //Disable the resizing of mainwindow while the animation is in progress. if (_parentWindow != null) { _parentWindow.ResizeMode = ResizeMode.NoResize; } //Get the previous canvas top and left values. double prevMainCircleTop = MainCircleTop, prevMainCircleLeft = MainCircleLeft, prevOuterRingTop = OuterRingTop, prevOuterRingLeft = OuterRingLeft, prevInnerRingTop = InnerRingTop, prevInnerRingLeft = InnerRingLeft; //Update the new values. _centerPoint.X = newX; _centerPoint.Y = newY; //Calculate the duration based on the distance. double duration = Math.Max(Math.Abs(MainCircleTop - prevMainCircleTop) / durationfactor, Math.Abs(MainCircleLeft - prevMainCircleLeft) / durationfactor); //Create an animation to change the canvas.Left and canvas.top values of token. tokenAnimation.Duration = TimeSpan.FromSeconds(duration > 0.0 ? duration : 0.1); tokenAnimation.From = prevMainCircleTop; tokenAnimation.To = MainCircleTop; this.BeginAnimation(Canvas.TopProperty, tokenAnimation); tokenAnimation.From = prevMainCircleLeft; tokenAnimation.To = MainCircleLeft; this.BeginAnimation(Canvas.LeftProperty, tokenAnimation); tokenAnimation.From = prevOuterRingTop; tokenAnimation.To = OuterRingTop; _outerRing.BeginAnimation(Canvas.TopProperty, tokenAnimation); tokenAnimation.From = prevOuterRingLeft; tokenAnimation.To = OuterRingLeft; _outerRing.BeginAnimation(Canvas.LeftProperty, tokenAnimation); tokenAnimation.From = prevInnerRingTop; tokenAnimation.To = InnerRingTop; _innerRing.BeginAnimation(Canvas.TopProperty, tokenAnimation); tokenAnimation.From = prevInnerRingLeft; tokenAnimation.To = InnerRingLeft; _innerRing.BeginAnimation(Canvas.LeftProperty, tokenAnimation); //Create one effect so that token looks like its glowing while moving. DropShadowEffect shadowEffect = new DropShadowEffect(); shadowEffect.ShadowDepth = 0; shadowEffect.Color = System.Windows.Media.Colors.LightGoldenrodYellow;// (System.Windows.Media.Color)(_color.GetValue(SolidColorBrush.ColorProperty)); shadowEffect.BlurRadius = MainCircleWidth; MainCircle.Effect = shadowEffect; //Create animation for the glowing effect. DoubleAnimation shadowAnimation = new DoubleAnimation(); shadowAnimation.From = MainCircleWidth; shadowAnimation.To = 0; shadowAnimation.Duration = TimeSpan.FromSeconds(duration / 4.0 > 0.0 ? duration / 4.0 : 0.1); shadowAnimation.RepeatBehavior = new RepeatBehavior(2); shadowAnimation.AutoReverse = true; shadowAnimation.Completed += Animation_Completed; shadowAnimation.FillBehavior = FillBehavior.Stop; shadowEffect.BeginAnimation(DropShadowEffect.BlurRadiusProperty, shadowAnimation); //Play the sound for the movement. if (bIsLadder) { _tokenLadderMoveSound.Play(); } else { _tokenMoveSound.PlayLooping(); } //_tokenMoveSound.Play(); }
/*public void MoveTo(Point newPos) * { * Storyboard story = new Storyboard(); * DoubleAnimation dbWidth = new DoubleAnimation(); * dbWidth.From = mediaElement1.Width; * dbWidth.To = 600; * dbWidth.Duration = new Duration(TimeSpan.FromSeconds(.25)); * * DoubleAnimation dbHeight = new DoubleAnimation(); * dbHeight.From = mediaElement1.Height; * dbHeight.To = 400; * dbHeight.Duration = dbWidth.Duration; * * story.Children.Add(dbWidth); * Storyboard.SetTargetName(dbWidth, mediaElement1.Name); * Storyboard.SetTargetProperty(dbWidth, new PropertyPath(MediaElement.WidthProperty)); * * story.Children.Add(dbHeight); * Storyboard.SetTargetName(dbHeight, mediaElement1.Name); * Storyboard.SetTargetProperty(dbHeight, new PropertyPath(MediaElement.HeightProperty)); * * DoubleAnimation dbCanvasX = new DoubleAnimation(); * dbCanvasX.From = 0; * dbCanvasX.To = 5; * dbCanvasX.Duration = new Duration(TimeSpan.FromSeconds(.25)); * * DoubleAnimation dbCanvasY = new DoubleAnimation(); * dbCanvasY.From = 0; * dbCanvasY.To = 5; * dbCanvasY.Duration = dbCanvasX.Duration; * * story.Children.Add(dbCanvasX); * Storyboard.SetTargetName(dbCanvasX, mediaElement1.Name); * Storyboard.SetTargetProperty(dbCanvasX, new PropertyPath(Canvas.LeftProperty)); * * story.Children.Add(dbCanvasY); * Storyboard.SetTargetName(dbCanvasY, mediaElement1.Name); * Storyboard.SetTargetProperty(dbCanvasY, new PropertyPath(Canvas.TopProperty)); * * story.Begin(this); * }*/ #endregion /// <summary> /// This method is used to move the token to a new position along a specific path defined by the object of System.Windows.Shapes.Path class. /// </summary> /// <param name="newPos">New poisition of the token on the canvas.</param> /// <param name="snakePath">The path through which the token will follow.</param> public void MoveToAlongPath(Point newPos, ref Path snakePath) { //Disable the resizing of mainwindow while the animation is in progress. if (_parentWindow != null) { _parentWindow.ResizeMode = ResizeMode.NoResize; } //Get the previous canvas top and left values. double prevMainCircleTop = MainCircleTop, prevMainCircleLeft = MainCircleLeft; //Update the new values. _centerPoint.X = newPos.X; _centerPoint.Y = newPos.Y; //Calculate the duration based on the distance. double duration = Math.Max(Math.Abs(MainCircleTop - prevMainCircleTop) / durationfactor, Math.Abs(MainCircleLeft - prevMainCircleLeft) / durationfactor); //Create an animation to change the canvas.Left and canvas.top values of token. DoubleAnimationUsingPath anim = new DoubleAnimationUsingPath(); anim.PathGeometry = snakePath.Data as PathGeometry; anim.Duration = TimeSpan.FromSeconds(duration > 0.0 ? duration : 0.1); anim.Source = PathAnimationSource.X; anim.FillBehavior = FillBehavior.Stop; this.BeginAnimation(Canvas.LeftProperty, anim); anim.Source = PathAnimationSource.Y; this.BeginAnimation(Canvas.TopProperty, anim); double marginVal = (_mainCircleDiameter - (_mainCircleDiameter * (2.0 / 3.0))) / 2; Path outerRingPath = snakePath.Clone(marginVal, marginVal); anim.PathGeometry = outerRingPath.Data as PathGeometry; anim.Source = PathAnimationSource.X; _outerRing.BeginAnimation(Canvas.LeftProperty, anim); anim.Source = PathAnimationSource.Y; _outerRing.BeginAnimation(Canvas.TopProperty, anim); marginVal = (_mainCircleDiameter - (_mainCircleDiameter * (1.0 / 3.0))) / 2; Path innerRingPath = snakePath.Clone(marginVal, marginVal); anim.PathGeometry = innerRingPath.Data as PathGeometry; anim.Source = PathAnimationSource.X; _innerRing.BeginAnimation(Canvas.LeftProperty, anim); anim.Source = PathAnimationSource.Y; _innerRing.BeginAnimation(Canvas.TopProperty, anim); //Create one effect so that token looks like its glowing while moving. DropShadowEffect shadowEffect = new DropShadowEffect(); shadowEffect.ShadowDepth = 0; shadowEffect.Color = System.Windows.Media.Colors.OrangeRed;// (System.Windows.Media.Color)(_color.GetValue(SolidColorBrush.ColorProperty)); shadowEffect.BlurRadius = MainCircleWidth; MainCircle.Effect = shadowEffect; //Create animation for the glowing effect. DoubleAnimation shadowAnimation = new DoubleAnimation(); shadowAnimation.From = MainCircleWidth; shadowAnimation.To = 0; shadowAnimation.Duration = TimeSpan.FromSeconds(duration / 4.0 > 0.0 ? duration / 4.0 : 0.1); shadowAnimation.RepeatBehavior = new RepeatBehavior(2); shadowAnimation.AutoReverse = true; shadowAnimation.Completed += Animation_Completed; shadowAnimation.FillBehavior = FillBehavior.Stop; shadowEffect.BeginAnimation(DropShadowEffect.BlurRadiusProperty, shadowAnimation); //Play the sound for the movement. _tokenSnakeMoveSound.Play(); }
private void MainButton_MouseLeave(object sender, MouseEventArgs e) { buttonDownAnimation.From = efT.BlurRadius; efC.BeginAnimation(DropShadowEffect.BlurRadiusProperty, buttonDownAnimation); efT.BeginAnimation(DropShadowEffect.BlurRadiusProperty, buttonDownAnimation); }