Exemplo n.º 1
0
 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; });
     }
 }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 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")
     });
 }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
 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);
 }
Exemplo n.º 11
0
 public static Extensions.EffectEntity Register(this Extensions.EffectEntity Element, string Property, object Value)
 {
     Element.Properties.Add(Property, Value);
     return(Element);
 }
Exemplo n.º 12
0
 public static Extensions.EffectEntity Event(this Extensions.EffectEntity Element, Action Invoke)
 {
     Element.Func = Invoke;
     return(Element);
 }
Exemplo n.º 13
0
 public static T Get <T>(this Extensions.EffectEntity Element, string Property) where T : class
 {
     return((T)Element.Element.GetType().GetProperty(Property).GetValue(Element.Element));
 }