Esempio n. 1
0
 private void button_MouseLeave(object sender, MouseEventArgs e)
 {
     if (BackgroundAnimation && backgroundTemp is SolidColorBrush)
     {
         ColorAnimation ca = new ColorAnimation();
         ca.To         = (backgroundTemp as SolidColorBrush).Color;
         ca.SpeedRatio = AnimationSpeed;
         Background.BeginAnimation(SolidColorBrush.ColorProperty, ca);
     }
     if (BorderAnimation && borderTemp is SolidColorBrush)
     {
         ColorAnimation ca2 = new ColorAnimation();
         ca2.To         = (borderTemp as SolidColorBrush).Color;
         ca2.SpeedRatio = AnimationSpeed;
         BorderBrush.BeginAnimation(SolidColorBrush.ColorProperty, ca2);
     }
     if (PaddingAnimation && paddingTemp != null)
     {
         ThicknessAnimation t = new ThicknessAnimation();
         t.To         = paddingTemp;
         t.SpeedRatio = AnimationSpeed / 2;
         PowerEase pe = new PowerEase();
         pe.Power         = Power;
         t.EasingFunction = new PowerEase();
         BeginAnimation(PaddingProperty, t);
     }
     if (MarginAnimation && marginTemp != null)
     {
         ThicknessAnimation t2 = new ThicknessAnimation();
         t2.To         = marginTemp;
         t2.SpeedRatio = AnimationSpeed / 2;
         PowerEase pe = new PowerEase();
         pe.Power          = Power;
         t2.EasingFunction = new PowerEase();
         BeginAnimation(MarginProperty, t2);
     }
 }
Esempio n. 2
0
        private void button_MouseEnter(object sender, MouseEventArgs e)
        {
            /*if(AutoColour)
             * {
             *  if(Background is SolidColorBrush)
             *  {
             *      //SolidColorBrush scb = Background as SolidColorBrush;
             *      //MouseOnBackground =new SolidColorBrush( Color.FromArgb(scb.Color.A, (byte)Math.Min(scb.Color.R*1, 255), (byte)Math.Min(scb.Color.G*1.1,255), (byte)Math.Min(scb.Color.B*0.9, 255)));
             *      //EllipseColor = new SolidColorBrush(Color.FromArgb(255, (byte)Math.Min(scb.Color.R*1, 255), (byte)Math.Min(scb.Color.G*1.1, 255), (byte)Math.Min(scb.Color.B*0.9, 255)));
             *  }
             *
             * }*/

            if (Background is SolidColorBrush && BackgroundAnimation)
            {
                ColorAnimation ca = new ColorAnimation();
                ca.SpeedRatio = AnimationSpeed;
                if (MouseOnBackground is SolidColorBrush)
                {
                    ca.To = (MouseOnBackground as SolidColorBrush).Color;
                    //backgroundTemp = Background == null ? null : Background.Clone();
                }
                else if (MouseOnBackground == null)
                {
                    Color c = (Background as SolidColorBrush).Color;
                    ca.To = new Color()
                    {
                        A = c.A, G = (byte)(c.G * 0.87), R = (byte)(c.R * 0.87), B = (byte)(c.B * 0.87)
                    };
                }
                Color c1 = (Background as SolidColorBrush).Clone().Color;
                Background = new SolidColorBrush(c1);//防止被冻结
                Background.BeginAnimation(SolidColorBrush.ColorProperty, ca);
            }
            if (BorderBrush is SolidColorBrush && BorderAnimation)
            {
                ColorAnimation ca = new ColorAnimation();
                ca.SpeedRatio = AnimationSpeed;
                if (MouseOnBorder is SolidColorBrush)
                {
                    ca.To = (MouseOnBorder as SolidColorBrush).Color;
                }
                else if (MouseOnBorder == null)
                {
                    Color c = (BorderBrush as SolidColorBrush).Color;
                    ca.To = new Color()
                    {
                        A = c.A, G = (byte)(c.G * 0.87), R = (byte)(c.R * 0.87), B = (byte)(c.B * 0.87)
                    };
                }
                BorderBrush.BeginAnimation(SolidColorBrush.ColorProperty, ca);
            }
            if (MouseOnPadding != null && PaddingAnimation)
            {
                ThicknessAnimation t = new ThicknessAnimation();
                t.To         = MouseOnPadding;
                t.SpeedRatio = AnimationSpeed / 2;
                PowerEase pe = new PowerEase();
                pe.Power         = Power;
                t.EasingFunction = new PowerEase();
                BeginAnimation(PaddingProperty, t);
            }
            if (MouseOnMargin != null && MarginAnimation)
            {
                ThicknessAnimation t = new ThicknessAnimation();
                t.To         = MouseOnMargin;
                t.SpeedRatio = AnimationSpeed / 2;
                PowerEase pe = new PowerEase();
                pe.Power         = Power;
                t.EasingFunction = new PowerEase();
                BeginAnimation(MarginProperty, t);
            }
        }