/// <internalonly /> protected override ProceduralAnimation CreateTransitionAnimation(Panel container, EffectDirection direction) { if (_scaleTransform == null) { _scaleTransform = new ScaleTransform(); container.RenderTransform = _scaleTransform; container.RenderTransformOrigin = new Point(0.5, 0.5); } TweenInterpolation interpolation = GetEffectiveInterpolation(); TimeSpan shortDuration = TimeSpan.FromMilliseconds(Duration.TotalMilliseconds / 3); FlipScaleAnimation scaleAnimation = new FlipScaleAnimation(Duration, _scaleTransform, (direction == EffectDirection.Forward ? 180 : -180)); scaleAnimation.Interpolation = interpolation; DoubleAnimation frontAnimation = new DoubleAnimation(container.Children[1], UIElement.OpacityProperty, shortDuration, (direction == EffectDirection.Forward ? 0 : 1)); frontAnimation.Interpolation = interpolation; frontAnimation.StartDelay = shortDuration; DoubleAnimation backAnimation = new DoubleAnimation(container.Children[0], UIElement.OpacityProperty, shortDuration, (direction == EffectDirection.Forward ? 1 : 0)); backAnimation.Interpolation = interpolation; backAnimation.StartDelay = shortDuration; return new ProceduralAnimationSet(scaleAnimation, frontAnimation, backAnimation); }
/// <summary> /// Plays the effect in the specified direction. /// </summary> /// <param name="direction">The direction to play the effect in.</param> protected void PlayEffect(EffectDirection direction) { if (_effect != null) { _effect.PlayEffect(direction); } }
private void OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { Effect effect = Effect; if (effect != null) { if (effect.IsActive) { return; } IAttachedObject attachedObject = (IAttachedObject)effect; if (attachedObject.AssociatedObject != this) { attachedObject.Detach(); attachedObject.Attach(this); effect.Target = (Image)GetTemplateChild("ImagePresenter"); } EffectDirection direction = _direction; _direction = _direction == EffectDirection.Forward ? EffectDirection.Reverse : EffectDirection.Forward; effect.PlayEffect(direction); } }
/// <internalonly /> protected internal override ProceduralAnimation CreateEffectAnimation(EffectDirection direction) { FrameworkElement target = GetTarget(); if (_initialOpacity == -1) { _initialOpacity = target.Opacity; } DoubleAnimation animation; if (direction == EffectDirection.Forward) { animation = new DoubleAnimation(target, UIElement.OpacityProperty, Duration, _fadeOpacity); } else { animation = new DoubleAnimation(target, UIElement.OpacityProperty, Duration, _initialOpacity); } animation.AutoReverse = AutoReverse; animation.Interpolation = GetEffectiveInterpolation(); return(animation); }
/// <summary> /// Indicates that the effect should start playing. /// </summary> /// <param name="direction">Indicates whether to play the direction in forward direction or reverse direction.</param> public void PlayEffect(EffectDirection direction) { if (_animation != null) { _animation.Stopped -= OnAnimationStopped; if (_animation.IsPlaying) { _animation.Stop(ProceduralAnimationStopState.Complete); } _animation = null; } if ((direction == EffectDirection.Reverse) && (AutoReverse || (Reversible == false))) { direction = EffectDirection.Forward; } if (_reversed) { direction = (direction == EffectDirection.Forward) ? EffectDirection.Reverse : EffectDirection.Forward; } _animation = CreateEffectAnimation(direction); if (_animation != null) { _direction = direction; _animation.Stopped += OnAnimationStopped; OnStarting(); _animation.Play(AssociatedObject); } }
/// <internalonly /> protected internal override ProceduralAnimation CreateEffectAnimation(EffectDirection direction) { SolidColorBrush brush; FrameworkElement target = GetTarget(); Border border = target as Border; Panel panel = target as Panel; Control control = target as Control; if ((border == null) && (panel == null) && (control == null)) { throw new InvalidOperationException("The target of the effect must be a Panel, Border or Control."); } brush = new SolidColorBrush(_highlightColor); if (border != null) { border.Background = brush; } else if (panel != null) { panel.Background = brush; } else if (control != null) { control.Background = brush; } HighlightAnimation animation = new HighlightAnimation(Duration, brush, _highlightColor); animation.AutoReverse = AutoReverse; animation.Interpolation = GetEffectiveInterpolation(); return animation; }
public News(Industry industry, string headline, EffectDirection direction, EffectStrength strength) { Industry = industry; Headline = headline; PriceEffectDirection = direction; PriceEffectStrength = strength; }
/// <internalonly /> protected internal override ProceduralAnimation CreateEffectAnimation(EffectDirection direction) { FrameworkElement target = GetTarget(); if (_translateTransform == null) { Transform existingTransform = target.RenderTransform; if (existingTransform != null) { _translateTransform = existingTransform as TranslateTransform; if (_translateTransform == null) { TransformGroup transformGroup = existingTransform as TransformGroup; if (transformGroup != null) { foreach (Transform transform in transformGroup.Children) { _translateTransform = transform as TranslateTransform; if (_translateTransform != null) { break; } } } } } } if (_translateTransform == null) { throw new InvalidOperationException("The element does not have a translate transform associated with it."); } ShakeAnimation animation = new ShakeAnimation(_translateTransform, Duration, _shakeDistance); animation.Interpolation = GetEffectiveInterpolation(); return animation; }
/// <internalonly /> protected internal override ProceduralAnimation CreateEffectAnimation(EffectDirection direction) { FrameworkElement target = GetTarget(); PulsateAnimation animation = new PulsateAnimation(target, Duration, _fadeOpacity); animation.Interpolation = GetEffectiveInterpolation(); return animation; }
/// <internalonly /> protected internal override ProceduralAnimation CreateEffectAnimation(EffectDirection direction) { if (_effects.Count == 0) { throw new InvalidOperationException("A CompositeEffect must have more than 1 nested child effect."); } if (_childrenInitialized == false) { foreach (Effect childEffect in _effects) { ((IAttachedObject)childEffect).Attach(AssociatedObject); } _childrenInitialized = true; } List <ProceduralAnimation> animations = new List <ProceduralAnimation>(_effects.Count); foreach (Effect childEffect in _effects) { EffectDirection childDirection = direction; if (childEffect.AutoReverse) { childDirection = EffectDirection.Forward; } ProceduralAnimation childAnimation = childEffect.CreateEffectAnimation(childDirection); if (childAnimation != null) { animations.Add(childAnimation); } } if (animations.Count != 0) { ProceduralAnimation[] animationItems = animations.ToArray(); if (_composition == EffectComposition.Parallel) { ProceduralAnimationSet animation = new ProceduralAnimationSet(animationItems); animation.AutoReverse = AutoReverse; return(animation); } else { ProceduralAnimationSequence animation = new ProceduralAnimationSequence(animationItems); animation.AutoReverse = AutoReverse; return(animation); } } return(null); }
/// <internalonly /> protected override ProceduralAnimation CreateTransitionAnimation(Panel container, EffectDirection direction) { FrameworkElement topContent = (FrameworkElement)container.Children[1]; FrameworkElement bottomContent = (FrameworkElement)container.Children[0]; BlindsAnimation animation = new BlindsAnimation(topContent, bottomContent, Duration, _mode, direction == EffectDirection.Forward); animation.Interpolation = GetEffectiveInterpolation(); return animation; }
/// <internalonly /> protected internal override ProceduralAnimation CreateEffectAnimation(EffectDirection direction) { FrameworkElement target = GetTarget(); PulsateAnimation animation = new PulsateAnimation(target, Duration, _fadeOpacity); animation.Interpolation = GetEffectiveInterpolation(); return(animation); }
/// <internalonly /> protected internal override ProceduralAnimation CreateEffectAnimation(EffectDirection direction) { if (_brush == null) { FrameworkElement target = GetTarget(); Border border = target as Border; Panel panel = target as Panel; Control control = target as Control; if ((border == null) && (panel == null) && (control == null)) { throw new InvalidOperationException("The target of the ColorFillEffect must be a Panel, Border or Control."); } if (border != null) { _brush = border.Background as SolidColorBrush; } else if (panel != null) { _brush = panel.Background as SolidColorBrush; } else if (control != null) { _brush = control.Background as SolidColorBrush; } if (_brush == null) { _brush = new SolidColorBrush(Color.FromArgb(0, _fillColor.R, _fillColor.G, _fillColor.B)); if (border != null) { border.Background = _brush; } else if (panel != null) { panel.Background = _brush; } else if (control != null) { control.Background = _brush; } } _initialColor = _brush.Color; } ColorFillAnimation animation; if (direction == EffectDirection.Forward) { animation = new ColorFillAnimation(Duration, _brush, _initialColor, _fillColor); } else { animation = new ColorFillAnimation(Duration, _brush, _fillColor, _initialColor); } animation.AutoReverse = AutoReverse; animation.Interpolation = GetEffectiveInterpolation(); return animation; }
/// <internalonly /> protected internal override sealed ProceduralAnimation CreateEffectAnimation(EffectDirection direction) { Panel container = GetTarget() as Panel; if (container == null) { throw new InvalidOperationException("A FlipEffect's target must be a Panel."); } if (container.Children.Count != 2) { throw new InvalidOperationException("A FlipEffect's target Panel must have 2 children."); } return CreateTransitionAnimation(container, direction); }
/// <internalonly /> protected internal override ProceduralAnimation CreateEffectAnimation(EffectDirection direction) { if (_rotateTransform == null) { Transform existingTransform = GetTarget().RenderTransform; if (existingTransform != null) { _rotateTransform = existingTransform as RotateTransform; if (_rotateTransform == null) { TransformGroup transformGroup = existingTransform as TransformGroup; if (transformGroup != null) { foreach (Transform transform in transformGroup.Children) { _rotateTransform = transform as RotateTransform; if (_rotateTransform != null) { break; } } } } } if (_rotateTransform == null) { throw new InvalidOperationException("The element does not have a rotate transform associated with it."); } _initialAngle = _rotateTransform.Angle; } if (_spinAngle != 0) { double targetValue = direction == EffectDirection.Forward ? _initialAngle + _spinAngle : _initialAngle; DoubleAnimation animation = new DoubleAnimation(_rotateTransform, RotateTransform.AngleProperty, Duration, targetValue); animation.Interpolation = GetEffectiveInterpolation(); animation.AutoReverse = AutoReverse; return(animation); } return(null); }
/// <internalonly /> protected internal sealed override ProceduralAnimation CreateEffectAnimation(EffectDirection direction) { Panel container = GetTarget() as Panel; if (container == null) { throw new InvalidOperationException("A FlipEffect's target must be a Panel."); } if (container.Children.Count != 2) { throw new InvalidOperationException("A FlipEffect's target Panel must have 2 children."); } return(CreateTransitionAnimation(container, direction)); }
/// <internalonly /> protected internal override ProceduralAnimation CreateEffectAnimation(EffectDirection direction) { if (_effects.Count == 0) { throw new InvalidOperationException("A CompositeEffect must have more than 1 nested child effect."); } if (_childrenInitialized == false) { foreach (Effect childEffect in _effects) { ((IAttachedObject)childEffect).Attach(AssociatedObject); } _childrenInitialized = true; } List<ProceduralAnimation> animations = new List<ProceduralAnimation>(_effects.Count); foreach (Effect childEffect in _effects) { EffectDirection childDirection = direction; if (childEffect.AutoReverse) { childDirection = EffectDirection.Forward; } ProceduralAnimation childAnimation = childEffect.CreateEffectAnimation(childDirection); if (childAnimation != null) { animations.Add(childAnimation); } } if (animations.Count != 0) { ProceduralAnimation[] animationItems = animations.ToArray(); if (_composition == EffectComposition.Parallel) { ProceduralAnimationSet animation = new ProceduralAnimationSet(animationItems); animation.AutoReverse = AutoReverse; return animation; } else { ProceduralAnimationSequence animation = new ProceduralAnimationSequence(animationItems); animation.AutoReverse = AutoReverse; return animation; } } return null; }
/// <internalonly /> protected internal override ProceduralAnimation CreateEffectAnimation(EffectDirection direction) { FrameworkElement target = GetTarget(); if (_translateTransform == null) { Transform existingTransform = target.RenderTransform; if (existingTransform != null) { _translateTransform = existingTransform as TranslateTransform; if (_translateTransform == null) { TransformGroup transformGroup = existingTransform as TransformGroup; if (transformGroup != null) { foreach (Transform transform in transformGroup.Children) { _translateTransform = transform as TranslateTransform; if (_translateTransform != null) { break; } } } } } } if (_translateTransform == null) { throw new InvalidOperationException("The element does not have a translate transform associated with it."); } ShakeAnimation animation = new ShakeAnimation(_translateTransform, Duration, _shakeDistance); animation.Interpolation = GetEffectiveInterpolation(); return(animation); }
/// <internalonly /> protected internal override ProceduralAnimation CreateEffectAnimation(EffectDirection direction) { FrameworkElement target = GetTarget(); if (_initialOpacity == -1) { _initialOpacity = target.Opacity; } DoubleAnimation animation; if (direction == EffectDirection.Forward) { animation = new DoubleAnimation(target, UIElement.OpacityProperty, Duration, _fadeOpacity); } else { animation = new DoubleAnimation(target, UIElement.OpacityProperty, Duration, _initialOpacity); } animation.AutoReverse = AutoReverse; animation.Interpolation = GetEffectiveInterpolation(); return animation; }
protected override ProceduralAnimation CreateEffectAnimation(EffectDirection direction) { FrameworkElement target = GetTarget(); ScaleTransform scaleTransform = target.RenderTransform as ScaleTransform; if (scaleTransform == null) { scaleTransform = new ScaleTransform(); target.RenderTransform = scaleTransform; target.RenderTransformOrigin = new Point(0.5, 0.5); } TimeSpan halfDuration = TimeSpan.FromMilliseconds(Duration.TotalMilliseconds / 2); TweenInterpolation interpolation = GetEffectiveInterpolation(); // A FlashBulb effect basically grows the element and makes it transparent // half way and then restores the element to its initial state during the // 2nd half of the animation. // This is accomplished with three animations that auto-reverse. // As a result the animations are the same regardless of effect direction. DoubleAnimation opacityAnimation = new DoubleAnimation(target, UIElement.OpacityProperty, halfDuration, 0.25); DoubleAnimation scaleXAnimation = new DoubleAnimation(scaleTransform, ScaleTransform.ScaleXProperty, halfDuration, 1.1); DoubleAnimation scaleYAnimation = new DoubleAnimation(scaleTransform, ScaleTransform.ScaleYProperty, halfDuration, 1.1); opacityAnimation.Interpolation = interpolation; scaleXAnimation.Interpolation = interpolation; scaleYAnimation.Interpolation = interpolation; // Create a composite animation that plays all three in parallel ProceduralAnimation animation = new ProceduralAnimationSet(opacityAnimation, scaleXAnimation, scaleYAnimation); animation.AutoReverse = true; return(animation); }
/// <internalonly /> protected internal override ProceduralAnimation CreateEffectAnimation(EffectDirection direction) { if (_rotateTransform == null) { Transform existingTransform = GetTarget().RenderTransform; if (existingTransform != null) { _rotateTransform = existingTransform as RotateTransform; if (_rotateTransform == null) { TransformGroup transformGroup = existingTransform as TransformGroup; if (transformGroup != null) { foreach (Transform transform in transformGroup.Children) { _rotateTransform = transform as RotateTransform; if (_rotateTransform != null) { break; } } } } } if (_rotateTransform == null) { throw new InvalidOperationException("The element does not have a rotate transform associated with it."); } _initialAngle = _rotateTransform.Angle; } if (_spinAngle != 0) { double targetValue = direction == EffectDirection.Forward ? _initialAngle + _spinAngle : _initialAngle; DoubleAnimation animation = new DoubleAnimation(_rotateTransform, RotateTransform.AngleProperty, Duration, targetValue); animation.Interpolation = GetEffectiveInterpolation(); animation.AutoReverse = AutoReverse; return animation; } return null; }
protected override ProceduralAnimation CreateEffectAnimation(EffectDirection direction) { FrameworkElement target = GetTarget(); ScaleTransform scaleTransform = target.RenderTransform as ScaleTransform; if (scaleTransform == null) { scaleTransform = new ScaleTransform(); target.RenderTransform = scaleTransform; target.RenderTransformOrigin = new Point(0.5, 0.5); } TimeSpan halfDuration = TimeSpan.FromMilliseconds(Duration.TotalMilliseconds / 2); TweenInterpolation interpolation = GetEffectiveInterpolation(); // A FlashBulb effect basically grows the element and makes it transparent // half way and then restores the element to its initial state during the // 2nd half of the animation. // This is accomplished with three animations that auto-reverse. // As a result the animations are the same regardless of effect direction. DoubleAnimation opacityAnimation = new DoubleAnimation(target, UIElement.OpacityProperty, halfDuration, 0.25); DoubleAnimation scaleXAnimation = new DoubleAnimation(scaleTransform, ScaleTransform.ScaleXProperty, halfDuration, 1.1); DoubleAnimation scaleYAnimation = new DoubleAnimation(scaleTransform, ScaleTransform.ScaleYProperty, halfDuration, 1.1); opacityAnimation.Interpolation = interpolation; scaleXAnimation.Interpolation = interpolation; scaleYAnimation.Interpolation = interpolation; // Create a composite animation that plays all three in parallel ProceduralAnimation animation = new ProceduralAnimationSet(opacityAnimation, scaleXAnimation, scaleYAnimation); animation.AutoReverse = true; return animation; }
/// <internalonly /> protected internal override ProceduralAnimation CreateEffectAnimation(EffectDirection direction) { SolidColorBrush brush; FrameworkElement target = GetTarget(); Border border = target as Border; Panel panel = target as Panel; Control control = target as Control; if ((border == null) && (panel == null) && (control == null)) { throw new InvalidOperationException("The target of the effect must be a Panel, Border or Control."); } brush = new SolidColorBrush(_highlightColor); if (border != null) { border.Background = brush; } else if (panel != null) { panel.Background = brush; } else if (control != null) { control.Background = brush; } HighlightAnimation animation = new HighlightAnimation(Duration, brush, _highlightColor); animation.AutoReverse = AutoReverse; animation.Interpolation = GetEffectiveInterpolation(); return(animation); }
public SlideOut(int duration, EffectDirection direction) : base(duration, direction) { }
public Erase(int duration, EffectDirection direction) : base(duration, direction) { }
/// <internalonly /> protected override ProceduralAnimation CreateTransitionAnimation(Panel container, EffectDirection direction) { bool forward = direction == EffectDirection.Forward; double width = container.ActualWidth; double height = container.ActualHeight; TranslateTransform topTransform = null; TranslateTransform bottomTransform = null; Transform existingTransform = null; FrameworkElement topContent = (FrameworkElement)container.Children[1]; FrameworkElement bottomContent = (FrameworkElement)container.Children[0]; existingTransform = topContent.RenderTransform; if (existingTransform != null) { topTransform = existingTransform as TranslateTransform; if (topTransform == null) { TransformGroup transformGroup = existingTransform as TransformGroup; if (transformGroup != null) { foreach (Transform transform in transformGroup.Children) { topTransform = transform as TranslateTransform; if (topTransform != null) { break; } } if (topTransform == null) { topTransform = new TranslateTransform(); transformGroup.Children.Add(topTransform); } } } } existingTransform = bottomContent.RenderTransform; if (existingTransform != null) { bottomTransform = existingTransform as TranslateTransform; if (bottomTransform == null) { TransformGroup transformGroup = existingTransform as TransformGroup; if (transformGroup != null) { foreach (Transform transform in transformGroup.Children) { bottomTransform = transform as TranslateTransform; if (bottomTransform != null) { break; } } if (bottomTransform == null) { bottomTransform = new TranslateTransform(); transformGroup.Children.Add(bottomTransform); } } } } if (topTransform == null) { topTransform = new TranslateTransform(); topContent.RenderTransform = topTransform; } if (bottomTransform == null) { bottomTransform = new TranslateTransform(); bottomContent.RenderTransform = bottomTransform; } SlideAnimation slideAnimation = new SlideAnimation(container, Duration, forward); DoubleAnimation topAnimation = null; DoubleAnimation bottomAnimation = null; switch (_mode) { case SlideMode.Left: if (forward) { bottomTransform.X = width; topAnimation = new DoubleAnimation(topTransform, TranslateTransform.XProperty, Duration, -width); bottomAnimation = new DoubleAnimation(bottomTransform, TranslateTransform.XProperty, Duration, 0); } else { topTransform.X = -width; topAnimation = new DoubleAnimation(topTransform, TranslateTransform.XProperty, Duration, 0); bottomAnimation = new DoubleAnimation(bottomTransform, TranslateTransform.XProperty, Duration, width); } break; case SlideMode.Right: if (forward) { bottomTransform.X = -width; topAnimation = new DoubleAnimation(topTransform, TranslateTransform.XProperty, Duration, width); bottomAnimation = new DoubleAnimation(bottomTransform, TranslateTransform.XProperty, Duration, 0); } else { topTransform.X = width; topAnimation = new DoubleAnimation(topTransform, TranslateTransform.XProperty, Duration, 0); bottomAnimation = new DoubleAnimation(bottomTransform, TranslateTransform.XProperty, Duration, -width); } break; case SlideMode.Up: if (forward) { bottomTransform.Y = height; topAnimation = new DoubleAnimation(topTransform, TranslateTransform.YProperty, Duration, -height); bottomAnimation = new DoubleAnimation(bottomTransform, TranslateTransform.YProperty, Duration, 0); } else { topTransform.Y = -height; topAnimation = new DoubleAnimation(topTransform, TranslateTransform.YProperty, Duration, 0); bottomAnimation = new DoubleAnimation(bottomTransform, TranslateTransform.YProperty, Duration, height); } break; case SlideMode.Down: if (forward) { bottomTransform.Y = -height; topAnimation = new DoubleAnimation(topTransform, TranslateTransform.YProperty, Duration, height); bottomAnimation = new DoubleAnimation(bottomTransform, TranslateTransform.YProperty, Duration, 0); } else { topTransform.Y = height; topAnimation = new DoubleAnimation(topTransform, TranslateTransform.YProperty, Duration, 0); bottomAnimation = new DoubleAnimation(bottomTransform, TranslateTransform.YProperty, Duration, -height); } break; } TweenInterpolation interpolation = GetEffectiveInterpolation(); topAnimation.Interpolation = interpolation; bottomAnimation.Interpolation = interpolation; return(new ProceduralAnimationSet(slideAnimation, topAnimation, bottomAnimation)); }
public SlideIn(int duration, EffectDirection direction) : base(duration, direction) { }
/// <summary> /// Starts this effect. /// </summary> /// <param name="length">How many frames this effect should last.</param> /// <param name="direction"> /// The direction in which to run the effect (forward is iris in, /// backwards is iris out). /// </param> /// <param name="position"> /// The position at which the iris should close/open. /// </param> /// <param name="color">The color of the background after the iris-in.</param> public void Start(int length, EffectDirection direction, Vector2 position, Color color) { if ((direction == EffectDirection.Backward && currentFadeLevel == 1f) || (direction == EffectDirection.Forward && currentFadeLevel == 0f)) { return; } isRunning = true; fadeDelta = 1.0f / length; dir = direction; this.color = color; if (dir == EffectDirection.Forward) { currentFadeLevel = 1.0f; } }
/// <internalonly /> protected override ProceduralAnimation CreateTransitionAnimation(Panel container, EffectDirection direction) { TweenInterpolation interpolation = GetEffectiveInterpolation(); DoubleAnimation frontAnimation = new DoubleAnimation(container.Children[1], UIElement.OpacityProperty, Duration, (direction == EffectDirection.Forward ? 0 : 1)); frontAnimation.Interpolation = interpolation; DoubleAnimation backAnimation = new DoubleAnimation(container.Children[0], UIElement.OpacityProperty, Duration, (direction == EffectDirection.Forward ? 1 : 0)); backAnimation.Interpolation = interpolation; return(new ProceduralAnimationSet(frontAnimation, backAnimation)); }
/// <internalonly /> protected internal override ProceduralAnimation CreateEffectAnimation(EffectDirection direction) { if (_brush == null) { FrameworkElement target = GetTarget(); Border border = target as Border; Panel panel = target as Panel; Control control = target as Control; if ((border == null) && (panel == null) && (control == null)) { throw new InvalidOperationException("The target of the ColorFillEffect must be a Panel, Border or Control."); } if (border != null) { _brush = border.Background as SolidColorBrush; } else if (panel != null) { _brush = panel.Background as SolidColorBrush; } else if (control != null) { _brush = control.Background as SolidColorBrush; } if (_brush == null) { _brush = new SolidColorBrush(Color.FromArgb(0, _fillColor.R, _fillColor.G, _fillColor.B)); if (border != null) { border.Background = _brush; } else if (panel != null) { panel.Background = _brush; } else if (control != null) { control.Background = _brush; } } _initialColor = _brush.Color; } ColorFillAnimation animation; if (direction == EffectDirection.Forward) { animation = new ColorFillAnimation(Duration, _brush, _initialColor, _fillColor); } else { animation = new ColorFillAnimation(Duration, _brush, _fillColor, _initialColor); } animation.AutoReverse = AutoReverse; animation.Interpolation = GetEffectiveInterpolation(); return(animation); }
public Fill(int duration, EffectDirection direction) : base(duration, direction) { }
public PriceEffect(Industry industry, EffectDirection direction, EffectStrength strength) { AffectedIndustry = industry; Direction = direction; Strength = strength; }
/// <internalonly /> protected override ProceduralAnimation CreateTransitionAnimation(Panel container, EffectDirection direction) { FrameworkElement topElement = (FrameworkElement)container.Children[1]; FrameworkElement bottomElement = (FrameworkElement)container.Children[0]; ScaleTransform scaleTransform = null; Transform existingTransform = topElement.RenderTransform; if (existingTransform != null) { scaleTransform = existingTransform as ScaleTransform; if (scaleTransform == null) { TransformGroup transformGroup = existingTransform as TransformGroup; if (transformGroup != null) { foreach (Transform transform in transformGroup.Children) { scaleTransform = transform as ScaleTransform; if (transform != null) { break; } } if (scaleTransform == null) { scaleTransform = new ScaleTransform(); transformGroup.Children.Add(scaleTransform); } } } } if (scaleTransform == null) { scaleTransform = new ScaleTransform(); topElement.RenderTransform = scaleTransform; } if (_initialScaleX == 0) { _initialScaleX = scaleTransform.ScaleX; _initialScaleY = scaleTransform.ScaleY; } scaleTransform.CenterX = container.ActualWidth / 2; scaleTransform.CenterY = container.ActualHeight / 2; TweenInterpolation interpolation = GetEffectiveInterpolation(); DoubleAnimation scaleXAnimation; DoubleAnimation scaleYAnimation; DoubleAnimation fadeAnimation; if (direction == EffectDirection.Forward) { fadeAnimation = new DoubleAnimation(topElement, UIElement.OpacityProperty, Duration, 0); scaleXAnimation = new DoubleAnimation(scaleTransform, ScaleTransform.ScaleXProperty, Duration, _initialScaleX * _scaleRatio); scaleYAnimation = new DoubleAnimation(scaleTransform, ScaleTransform.ScaleYProperty, Duration, _initialScaleY * _scaleRatio); } else { fadeAnimation = new DoubleAnimation(topElement, UIElement.OpacityProperty, Duration, 1); scaleXAnimation = new DoubleAnimation(scaleTransform, ScaleTransform.ScaleXProperty, Duration, _initialScaleX); scaleYAnimation = new DoubleAnimation(scaleTransform, ScaleTransform.ScaleYProperty, Duration, _initialScaleY); } scaleXAnimation.Interpolation = interpolation; scaleYAnimation.Interpolation = interpolation; fadeAnimation.Interpolation = interpolation; return(new ProceduralAnimationSet(scaleXAnimation, scaleYAnimation, fadeAnimation)); }
/// <internalonly /> protected override ProceduralAnimation CreateTransitionAnimation(Panel container, EffectDirection direction) { bool forward = direction == EffectDirection.Forward; double width = container.ActualWidth; double height = container.ActualHeight; TranslateTransform topTransform = null; TranslateTransform bottomTransform = null; Transform existingTransform = null; FrameworkElement topContent = (FrameworkElement)container.Children[1]; FrameworkElement bottomContent = (FrameworkElement)container.Children[0]; existingTransform = topContent.RenderTransform; if (existingTransform != null) { topTransform = existingTransform as TranslateTransform; if (topTransform == null) { TransformGroup transformGroup = existingTransform as TransformGroup; if (transformGroup != null) { foreach (Transform transform in transformGroup.Children) { topTransform = transform as TranslateTransform; if (topTransform != null) { break; } } if (topTransform == null) { topTransform = new TranslateTransform(); transformGroup.Children.Add(topTransform); } } } } existingTransform = bottomContent.RenderTransform; if (existingTransform != null) { bottomTransform = existingTransform as TranslateTransform; if (bottomTransform == null) { TransformGroup transformGroup = existingTransform as TransformGroup; if (transformGroup != null) { foreach (Transform transform in transformGroup.Children) { bottomTransform = transform as TranslateTransform; if (bottomTransform != null) { break; } } if (bottomTransform == null) { bottomTransform = new TranslateTransform(); transformGroup.Children.Add(bottomTransform); } } } } if (topTransform == null) { topTransform = new TranslateTransform(); topContent.RenderTransform = topTransform; } if (bottomTransform == null) { bottomTransform = new TranslateTransform(); bottomContent.RenderTransform = bottomTransform; } SlideAnimation slideAnimation = new SlideAnimation(container, Duration, forward); DoubleAnimation topAnimation = null; DoubleAnimation bottomAnimation = null; switch (_mode) { case SlideMode.Left: if (forward) { bottomTransform.X = width; topAnimation = new DoubleAnimation(topTransform, TranslateTransform.XProperty, Duration, -width); bottomAnimation = new DoubleAnimation(bottomTransform, TranslateTransform.XProperty, Duration, 0); } else { topTransform.X = -width; topAnimation = new DoubleAnimation(topTransform, TranslateTransform.XProperty, Duration, 0); bottomAnimation = new DoubleAnimation(bottomTransform, TranslateTransform.XProperty, Duration, width); } break; case SlideMode.Right: if (forward) { bottomTransform.X = -width; topAnimation = new DoubleAnimation(topTransform, TranslateTransform.XProperty, Duration, width); bottomAnimation = new DoubleAnimation(bottomTransform, TranslateTransform.XProperty, Duration, 0); } else { topTransform.X = width; topAnimation = new DoubleAnimation(topTransform, TranslateTransform.XProperty, Duration, 0); bottomAnimation = new DoubleAnimation(bottomTransform, TranslateTransform.XProperty, Duration, -width); } break; case SlideMode.Up: if (forward) { bottomTransform.Y = height; topAnimation = new DoubleAnimation(topTransform, TranslateTransform.YProperty, Duration, -height); bottomAnimation = new DoubleAnimation(bottomTransform, TranslateTransform.YProperty, Duration, 0); } else { topTransform.Y = -height; topAnimation = new DoubleAnimation(topTransform, TranslateTransform.YProperty, Duration, 0); bottomAnimation = new DoubleAnimation(bottomTransform, TranslateTransform.YProperty, Duration, height); } break; case SlideMode.Down: if (forward) { bottomTransform.Y = -height; topAnimation = new DoubleAnimation(topTransform, TranslateTransform.YProperty, Duration, height); bottomAnimation = new DoubleAnimation(bottomTransform, TranslateTransform.YProperty, Duration, 0); } else { topTransform.Y = height; topAnimation = new DoubleAnimation(topTransform, TranslateTransform.YProperty, Duration, 0); bottomAnimation = new DoubleAnimation(bottomTransform, TranslateTransform.YProperty, Duration, -height); } break; } TweenInterpolation interpolation = GetEffectiveInterpolation(); topAnimation.Interpolation = interpolation; bottomAnimation.Interpolation = interpolation; return new ProceduralAnimationSet(slideAnimation, topAnimation, bottomAnimation); }
/// <summary> /// Initializes a new instance of the <see /// cref="EffectCompletedEventArgs" /> class. /// </summary> /// <param name="direction"> /// The <see cref="EffectDirection" /> for the effect that had completed. /// </param> public EffectCompletedEventArgs(EffectDirection direction) { Direction = direction; }
/// <internalonly /> protected override ProceduralAnimation CreateTransitionAnimation(Panel container, EffectDirection direction) { FrameworkElement topContent = (FrameworkElement)container.Children[1]; FrameworkElement bottomContent = (FrameworkElement)container.Children[0]; BlindsAnimation animation = new BlindsAnimation(topContent, bottomContent, Duration, _mode, direction == EffectDirection.Forward); animation.Interpolation = GetEffectiveInterpolation(); return(animation); }
/// <summary> /// Creates the animation associated with the transition for the specified direction. /// Forward implies going from the first child to the second child in the container. /// Reverse implies second to the first. /// </summary> /// <param name="container">The container that contains the controls to transition.</param> /// <param name="direction">The direction of the transition.</param> /// <returns>The animation representing the transition.</returns> protected abstract ProceduralAnimation CreateTransitionAnimation(Panel container, EffectDirection direction);
/// <summary> /// Sets this effect to be completed in any direction. /// </summary> /// <param name="direction">The direction to be set to.</param> /// <param name="color">The color of the effect.</param> public void Set(EffectDirection direction, Color color) { this.color = color; if (direction == EffectDirection.Forward) { currentFadeLevel = 0f; } else { currentFadeLevel = 1f; } }
/// <summary> /// Creates the animation representing the effect. /// </summary> /// <param name="direction">The direction of the animation.</param> /// <returns>The animation to be played to play the effect.</returns> protected internal abstract ProceduralAnimation CreateEffectAnimation(EffectDirection direction);
/// <internalonly /> protected override ProceduralAnimation CreateTransitionAnimation(Panel container, EffectDirection direction) { FrameworkElement topElement = (FrameworkElement)container.Children[1]; FrameworkElement bottomElement = (FrameworkElement)container.Children[0]; ScaleTransform scaleTransform = null; Transform existingTransform = topElement.RenderTransform; if (existingTransform != null) { scaleTransform = existingTransform as ScaleTransform; if (scaleTransform == null) { TransformGroup transformGroup = existingTransform as TransformGroup; if (transformGroup != null) { foreach (Transform transform in transformGroup.Children) { scaleTransform = transform as ScaleTransform; if (transform != null) { break; } } if (scaleTransform == null) { scaleTransform = new ScaleTransform(); transformGroup.Children.Add(scaleTransform); } } } } if (scaleTransform == null) { scaleTransform = new ScaleTransform(); topElement.RenderTransform = scaleTransform; } if (_initialScaleX == 0) { _initialScaleX = scaleTransform.ScaleX; _initialScaleY = scaleTransform.ScaleY; } scaleTransform.CenterX = container.ActualWidth / 2; scaleTransform.CenterY = container.ActualHeight / 2; TweenInterpolation interpolation = GetEffectiveInterpolation(); DoubleAnimation scaleXAnimation; DoubleAnimation scaleYAnimation; DoubleAnimation fadeAnimation; if (direction == EffectDirection.Forward) { fadeAnimation = new DoubleAnimation(topElement, UIElement.OpacityProperty, Duration, 0); scaleXAnimation = new DoubleAnimation(scaleTransform, ScaleTransform.ScaleXProperty, Duration, _initialScaleX * _scaleRatio); scaleYAnimation = new DoubleAnimation(scaleTransform, ScaleTransform.ScaleYProperty, Duration, _initialScaleY * _scaleRatio); } else { fadeAnimation = new DoubleAnimation(topElement, UIElement.OpacityProperty, Duration, 1); scaleXAnimation = new DoubleAnimation(scaleTransform, ScaleTransform.ScaleXProperty, Duration, _initialScaleX); scaleYAnimation = new DoubleAnimation(scaleTransform, ScaleTransform.ScaleYProperty, Duration, _initialScaleY); } scaleXAnimation.Interpolation = interpolation; scaleYAnimation.Interpolation = interpolation; fadeAnimation.Interpolation = interpolation; return new ProceduralAnimationSet(scaleXAnimation, scaleYAnimation, fadeAnimation); }
/// <internalonly /> protected internal override ProceduralAnimation CreateEffectAnimation(EffectDirection direction) { if (_scaleTransform == null) { Transform existingTransform = GetTarget().RenderTransform; if (existingTransform != null) { _scaleTransform = existingTransform as ScaleTransform; if (_scaleTransform == null) { TransformGroup transformGroup = existingTransform as TransformGroup; if (transformGroup != null) { foreach (Transform transform in transformGroup.Children) { _scaleTransform = transform as ScaleTransform; if (_scaleTransform != null) { break; } } } } } if (_scaleTransform == null) { throw new InvalidOperationException("The element does not have a scale transform associated with it."); } _initialX = _scaleTransform.ScaleX; _initialY = _scaleTransform.ScaleY; } TweenInterpolation interpolation = GetEffectiveInterpolation(); DoubleAnimation xAnimation = null; DoubleAnimation yAnimation = null; if (_scaleXRatio != 1) { double targetValue = direction == EffectDirection.Forward ? _initialX * _scaleXRatio : _initialX; xAnimation = new DoubleAnimation(_scaleTransform, ScaleTransform.ScaleXProperty, Duration, targetValue); xAnimation.Interpolation = interpolation; } if (_scaleYRatio != 1) { double targetValue = direction == EffectDirection.Forward ? _initialY * _scaleYRatio : _initialY; yAnimation = new DoubleAnimation(_scaleTransform, ScaleTransform.ScaleYProperty, Duration, targetValue); yAnimation.Interpolation = interpolation; } if ((xAnimation != null) && (yAnimation != null)) { ProceduralAnimationSet animation = new ProceduralAnimationSet(xAnimation, yAnimation); animation.AutoReverse = AutoReverse; return animation; } else if (xAnimation != null) { xAnimation.AutoReverse = AutoReverse; return xAnimation; } else if (yAnimation != null) { yAnimation.AutoReverse = AutoReverse; return yAnimation; } return null; }
/// <internalonly /> protected override ProceduralAnimation CreateTransitionAnimation(Panel container, EffectDirection direction) { if (_scaleTransform == null) { _scaleTransform = new ScaleTransform(); container.RenderTransform = _scaleTransform; container.RenderTransformOrigin = new Point(0.5, 0.5); } TweenInterpolation interpolation = GetEffectiveInterpolation(); TimeSpan shortDuration = TimeSpan.FromMilliseconds(Duration.TotalMilliseconds / 3); FlipScaleAnimation scaleAnimation = new FlipScaleAnimation(Duration, _scaleTransform, (direction == EffectDirection.Forward ? 180 : -180)); scaleAnimation.Interpolation = interpolation; DoubleAnimation frontAnimation = new DoubleAnimation(container.Children[1], UIElement.OpacityProperty, shortDuration, (direction == EffectDirection.Forward ? 0 : 1)); frontAnimation.Interpolation = interpolation; frontAnimation.StartDelay = shortDuration; DoubleAnimation backAnimation = new DoubleAnimation(container.Children[0], UIElement.OpacityProperty, shortDuration, (direction == EffectDirection.Forward ? 1 : 0)); backAnimation.Interpolation = interpolation; backAnimation.StartDelay = shortDuration; return(new ProceduralAnimationSet(scaleAnimation, frontAnimation, backAnimation)); }
/// <internalonly /> protected internal override ProceduralAnimation CreateEffectAnimation(EffectDirection direction) { if (_translateTransform == null) { Transform existingTransform = GetTarget().RenderTransform; if (existingTransform != null) { _translateTransform = existingTransform as TranslateTransform; if (_translateTransform == null) { TransformGroup transformGroup = existingTransform as TransformGroup; if (transformGroup != null) { foreach (Transform transform in transformGroup.Children) { _translateTransform = transform as TranslateTransform; if (_translateTransform != null) { break; } } } } } if (_translateTransform == null) { throw new InvalidOperationException("The element does not have a translate transform associated with it."); } _initialX = _translateTransform.X; _initialY = _translateTransform.Y; } TweenInterpolation interpolation = GetEffectiveInterpolation(); DoubleAnimation xAnimation = null; DoubleAnimation yAnimation = null; if (_horizontalMovement != 0) { double targetValue = direction == EffectDirection.Forward ? _horizontalMovement : _initialX; xAnimation = new DoubleAnimation(_translateTransform, TranslateTransform.XProperty, Duration, targetValue); xAnimation.Interpolation = interpolation; } if (_verticalMovement != 0) { double targetValue = direction == EffectDirection.Forward ? _verticalMovement : _initialY; yAnimation = new DoubleAnimation(_translateTransform, TranslateTransform.YProperty, Duration, targetValue); yAnimation.Interpolation = interpolation; } if ((xAnimation != null) && (yAnimation != null)) { ProceduralAnimationSet animation = new ProceduralAnimationSet(xAnimation, yAnimation); animation.AutoReverse = AutoReverse; return(animation); } else if (xAnimation != null) { xAnimation.AutoReverse = AutoReverse; return(xAnimation); } else if (yAnimation != null) { yAnimation.AutoReverse = AutoReverse; return(yAnimation); } return(null); }