/// <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 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; }