public static void If <T>(this Extensions.EffectEntity Element, T Animation) where T : Timeline { if (Element.Func != null) { Animation.Completed += ((s, e) => { Element.Func.Invoke(); Element.Func = null; }); } }
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 Opacity(this Extensions.EffectEntity Element, double Value) { Brush Background = Element.Get <Brush>("Background"); Background.GetType().GetProperty("Opacity").SetValue(Background, Value); 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") }); }
public static T Has <T>(this Extensions.EffectEntity Element, string property) where T : class { if (Element.Properties.ContainsKey(property)) { return((T)Element.Properties[property]); } return(null); }
public static Extensions.EffectEntity AnimateOpacity(this Extensions.EffectEntity Element, double FromValue, double ToValue, int Duration) { DoubleAnimation Animation = new DoubleAnimation(FromValue, ToValue, new Duration(TimeSpan.FromMilliseconds(Duration)), FillBehavior.Stop); Element.If <DoubleAnimation>(Animation); Brush bElement = Element.Get <SolidColorBrush>("Background"); bElement.BeginAnimation(SolidColorBrush.OpacityProperty, Animation); return(Element); }
private void AnimateFadeOut(object sender, MouseEventArgs e) { Extensions.EffectEntity Entity = (sender as FrameworkElement).Create(); if ((Entity.Data as MenuContainer).IsActive) { return; } Entity.Animate(SolidColorBrush.ColorProperty, 200, Extensions.FadeDirection.FadeOut); Extensions.FindVisualChildren <Border>(Entity.Element).FirstOrDefault().AnimateBorder(Entity, 200, Extensions.FadeDirection.FadeOut); }
private void AnimateFadeIn(object sender, MouseEventArgs e) { Extensions.EffectEntity Entity = (sender as FrameworkElement).Create(); if ((Entity.Data as MenuContainer).IsActive) { return; } if (Entity.Get <Brush>("Background").Opacity != 0.6) { Entity.Opacity(0.6); } Entity.Animate(SolidColorBrush.ColorProperty, 700, Extensions.FadeDirection.FadeIn); Extensions.FindVisualChildren <Border>(Entity.Element).FirstOrDefault().AnimateBorder(Entity, 700, Extensions.FadeDirection.FadeIn); }
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 Extensions.EffectEntity Set <T>(this Extensions.EffectEntity Element, string Property, T Value) { Element.Element.GetType().GetProperty(Property).SetValue(Element.Element, Value); return(Element); }
public static Extensions.EffectEntity Register(this Extensions.EffectEntity Element, string Property, object Value) { Element.Properties.Add(Property, Value); return(Element); }
public static Extensions.EffectEntity Event(this Extensions.EffectEntity Element, Action Invoke) { Element.Func = Invoke; return(Element); }
public static T Get <T>(this Extensions.EffectEntity Element, string Property) where T : class { return((T)Element.Element.GetType().GetProperty(Property).GetValue(Element.Element)); }