コード例 #1
0
        public void ResetTopMenu(object sender)
        {
            FKMethods.TagHelper s = (FKMethods.TagHelper)((Border)sender).Tag;

            foreach (UIElement x in IconMenu.Children.OfType <UIElement>())
            {
                if (x is Border)
                {
                    if (((Border)x).Name != "DropDown")
                    {
                        ((Border)x).Background = Extensions.HexToBrush(s.Transition.Reset.Color.ToString(), false);
                    }
                }
            }

            ((Border)sender).Background = Extensions.HexToBrush(s.Transition.Active.Color.ToString(), false);
        }
コード例 #2
0
        public static void AnimateBackground(this Border Element, object Transition, bool Leaving = false, bool Skip = false)
        {
            try
            {
                if (Transition is FKMethods.TagHelper)
                {
                    SolidColorBrush     ElementBackground = (SolidColorBrush)Element.GetType().GetProperty("Background").GetValue(Element);
                    FKMethods.TagHelper TagHelper         = (FKMethods.TagHelper)Transition;

                    if (ElementBackground.ToString() == TagHelper.Transition.Active.ToString().ToString() && !Skip)
                    {
                        return;
                    }

                    if (Element.Child is Border)
                    {
                        SolidColorBrush ResetBorder = (TagHelper.Transition.ResetBorder == default(SolidColorBrush)) ? Extensions.HexToColor("#475966") : TagHelper.Transition.ResetBorder;

                        Border         BorderChild     = (Border)Element.Child;
                        ColorAnimation BorderAnimation = new ColorAnimation();
                        BorderAnimation.From     = (Leaving) ? TagHelper.Transition.Hover.Color : ResetBorder.Color;
                        BorderAnimation.To       = (Leaving) ? ResetBorder.Color : TagHelper.Transition.Hover.Color;
                        BorderAnimation.Duration = new Duration(TimeSpan.FromMilliseconds((Leaving) ? TagHelper.Transition.FadeOut : TagHelper.Transition.FadeIn));
                        Storyboard sb = new Storyboard();
                        sb.Children.Add(BorderAnimation);
                        Storyboard.SetTarget(BorderAnimation, BorderChild);
                        Storyboard.SetTargetProperty(BorderAnimation, new PropertyPath("(Border.BorderBrush).(SolidColorBrush.Color)"));
                        sb.Begin();
                    }

                    ElementBackground.Opacity = 0.6;

                    ColorAnimation Animation = new ColorAnimation();
                    Animation.From     = (Leaving) ? TagHelper.Transition.Hover.Color : TagHelper.Transition.Reset.Color;
                    Animation.To       = (Leaving) ? TagHelper.Transition.Reset.Color : TagHelper.Transition.Hover.Color;
                    Animation.Duration = new Duration(TimeSpan.FromMilliseconds((Leaving) ? TagHelper.Transition.FadeOut : TagHelper.Transition.FadeIn));
                    ElementBackground.BeginAnimation(SolidColorBrush.ColorProperty, Animation);
                }
            }

            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }
コード例 #3
0
        public static void AnimateForeground(this UIElement Element, object Transition, bool Leaving = false, bool Skip = false)
        {
            try
            {
                SolidColorBrush     ElementBackground = (SolidColorBrush)Element.GetType().GetProperty("Foreground").GetValue(Element);
                FKMethods.TagHelper TagHelper         = (FKMethods.TagHelper)Transition;

                ColorAnimation Animation = new ColorAnimation();
                Animation.From     = (Leaving) ? TagHelper.Transition.Hover.Color : TagHelper.Transition.Reset.Color;
                Animation.To       = (Leaving) ? TagHelper.Transition.Reset.Color : TagHelper.Transition.Hover.Color;
                Animation.Duration = new Duration(TimeSpan.FromMilliseconds((Leaving) ? TagHelper.Transition.FadeOut : TagHelper.Transition.FadeIn));
                ElementBackground.BeginAnimation(SolidColorBrush.ColorProperty, Animation);
            }

            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }