public static Extensions.EffectEntity AnimateBorder(this Extensions.EffectEntity Element, int Duration, Extensions.FadeDirection Direction) { if (Element.Element.GetType() != typeof(Border)) { return(Element); } Border Border = (Border)Element.Element; ColorAnimation Animation = new ColorAnimation { To = (Direction == Extensions.FadeDirection.FadeIn) ? Element.Data.Effects.Hover.ToColor(false) : "1e3c53".ToColor(false), From = (Direction == Extensions.FadeDirection.FadeIn) ? "1e3c53".ToColor(false) : Element.Data.Effects.Hover.ToColor(false), Duration = new Duration(TimeSpan.FromMilliseconds(Duration)), EasingFunction = Element.Has <EasingFunctionBase>("Easing") }; Storyboard sb = new Storyboard(); sb.Children.Add(Animation); Storyboard.SetTarget(Animation, Border); Storyboard.SetTargetProperty(Animation, new PropertyPath("(Border.BorderBrush).(SolidColorBrush.Color)")); sb.Begin(); return(Element); }
public static Extensions.EffectEntity Animate(this Extensions.EffectEntity Element, DependencyProperty Property, int Duration, Extensions.FadeDirection Direction) { SolidColorBrush bElement = Element.Get <SolidColorBrush>("Background"); ColorAnimation Animation; if (Element.Data != null) { Animation = ReturnAnimation(Element, Duration, Direction); } else { Animation = new ColorAnimation { From = Element.Has <string>("From").ToColor(false), To = Element.Has <string>("To").ToColor(false), Duration = new Duration(TimeSpan.FromMilliseconds(Duration)) } }; Element.If <ColorAnimation>(Animation); bElement.BeginAnimation(Property, Animation); return(Element); }
public static ColorAnimation ReturnAnimation(Extensions.EffectEntity Element, int Duration, Extensions.FadeDirection Direction) { return(new ColorAnimation { To = (Direction == Extensions.FadeDirection.FadeIn) ? Element.Data.Effects.Hover.ToColor(false) : Element.Data.Effects.Default.ToColor(false), From = (Direction == Extensions.FadeDirection.FadeIn) ? Element.Data.Effects.Default.ToColor(false) : Element.Data.Effects.Hover.ToColor(false), Duration = new Duration(TimeSpan.FromMilliseconds(Duration)), EasingFunction = Element.Has <EasingFunctionBase>("Easing") }); }