예제 #1
0
        private static void OnRenderDefaultedChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
        {
            ImageButtonChrome buttonChrome = (ImageButtonChrome)o;

            if (buttonChrome.Animates)
            {
                if (!buttonChrome.RenderPressed)
                {
                    if ((bool)e.NewValue)
                    {
                        if (buttonChrome._localResources == null)
                        {
                            buttonChrome._localResources = new ImageButtonChrome.LocalResources();
                            buttonChrome.InvalidateVisual();
                        }
                        Duration               duration      = new Duration(TimeSpan.FromSeconds(0.3));
                        ColorAnimation         animation     = new ColorAnimation(Color.FromArgb(249, 0, 204, 255), duration);
                        GradientStopCollection gradientStops = ((LinearGradientBrush)buttonChrome.InnerBorderPen.Brush).GradientStops;
                        gradientStops[0].BeginAnimation(GradientStop.ColorProperty, animation);
                        gradientStops[1].BeginAnimation(GradientStop.ColorProperty, animation);
                        DoubleAnimationUsingKeyFrames doubleAnimationUsingKeyFrames = new DoubleAnimationUsingKeyFrames();
                        doubleAnimationUsingKeyFrames.KeyFrames.Add(new LinearDoubleKeyFrame(1.0, TimeSpan.FromSeconds(0.5)));
                        doubleAnimationUsingKeyFrames.KeyFrames.Add(new DiscreteDoubleKeyFrame(1.0, TimeSpan.FromSeconds(0.75)));
                        doubleAnimationUsingKeyFrames.KeyFrames.Add(new LinearDoubleKeyFrame(0.0, TimeSpan.FromSeconds(2.0)));
                        doubleAnimationUsingKeyFrames.RepeatBehavior = RepeatBehavior.Forever;
                        Timeline.SetDesiredFrameRate(doubleAnimationUsingKeyFrames, new int?(10));
                        buttonChrome.BackgroundOverlay.BeginAnimation(Brush.OpacityProperty, doubleAnimationUsingKeyFrames);
                        buttonChrome.BorderOverlayPen.Brush.BeginAnimation(Brush.OpacityProperty, doubleAnimationUsingKeyFrames);
                        return;
                    }
                    if (buttonChrome._localResources == null)
                    {
                        buttonChrome.InvalidateVisual();
                        return;
                    }
                    Duration        duration2       = new Duration(TimeSpan.FromSeconds(0.2));
                    DoubleAnimation doubleAnimation = new DoubleAnimation
                    {
                        Duration = duration2
                    };
                    buttonChrome.BorderOverlayPen.Brush.BeginAnimation(Brush.OpacityProperty, doubleAnimation);
                    buttonChrome.BackgroundOverlay.BeginAnimation(Brush.OpacityProperty, doubleAnimation);
                    ColorAnimation colorAnimation = new ColorAnimation
                    {
                        Duration = duration2
                    };
                    GradientStopCollection gradientStops2 = ((LinearGradientBrush)buttonChrome.InnerBorderPen.Brush).GradientStops;
                    gradientStops2[0].BeginAnimation(GradientStop.ColorProperty, colorAnimation);
                    gradientStops2[1].BeginAnimation(GradientStop.ColorProperty, colorAnimation);
                    return;
                }
            }
            else
            {
                buttonChrome._localResources = null;
                buttonChrome.InvalidateVisual();
            }
        }
예제 #2
0
        private static void OnRenderMouseOverChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
        {
            ImageButtonChrome buttonChrome = (ImageButtonChrome)o;

            if (buttonChrome.Animates)
            {
                if (!buttonChrome.RenderPressed)
                {
                    if ((bool)e.NewValue)
                    {
                        if (buttonChrome._localResources == null)
                        {
                            buttonChrome._localResources = new ImageButtonChrome.LocalResources();
                            buttonChrome.InvalidateVisual();
                        }
                        Duration        duration  = new Duration(TimeSpan.FromSeconds(0.3));
                        DoubleAnimation animation = new DoubleAnimation(1.0, duration);
                        buttonChrome.BorderOverlayPen.Brush.BeginAnimation(Brush.OpacityProperty, animation);
                        buttonChrome.BackgroundOverlay.BeginAnimation(Brush.OpacityProperty, animation);
                        return;
                    }
                    if (buttonChrome._localResources == null)
                    {
                        buttonChrome.InvalidateVisual();
                        return;
                    }
                    if (buttonChrome.RenderDefaulted)
                    {
                        double opacity = buttonChrome.BackgroundOverlay.Opacity;
                        double num     = (1.0 - opacity) * 0.5;
                        DoubleAnimationUsingKeyFrames doubleAnimationUsingKeyFrames = new DoubleAnimationUsingKeyFrames();
                        doubleAnimationUsingKeyFrames.KeyFrames.Add(new LinearDoubleKeyFrame(1.0, TimeSpan.FromSeconds(num)));
                        doubleAnimationUsingKeyFrames.KeyFrames.Add(new DiscreteDoubleKeyFrame(1.0, TimeSpan.FromSeconds(num + 0.25)));
                        doubleAnimationUsingKeyFrames.KeyFrames.Add(new LinearDoubleKeyFrame(0.0, TimeSpan.FromSeconds(num + 1.5)));
                        doubleAnimationUsingKeyFrames.KeyFrames.Add(new LinearDoubleKeyFrame(opacity, TimeSpan.FromSeconds(2.0)));
                        doubleAnimationUsingKeyFrames.RepeatBehavior = RepeatBehavior.Forever;
                        Timeline.SetDesiredFrameRate(doubleAnimationUsingKeyFrames, new int?(10));
                        buttonChrome.BackgroundOverlay.BeginAnimation(Brush.OpacityProperty, doubleAnimationUsingKeyFrames);
                        buttonChrome.BorderOverlayPen.Brush.BeginAnimation(Brush.OpacityProperty, doubleAnimationUsingKeyFrames);
                        return;
                    }
                    Duration        duration2       = new Duration(TimeSpan.FromSeconds(0.2));
                    DoubleAnimation doubleAnimation = new DoubleAnimation
                    {
                        Duration = duration2
                    };
                    buttonChrome.BackgroundOverlay.BeginAnimation(Brush.OpacityProperty, doubleAnimation);
                    buttonChrome.BorderOverlayPen.Brush.BeginAnimation(Brush.OpacityProperty, doubleAnimation);
                    return;
                }
            }
            else
            {
                buttonChrome._localResources = null;
                buttonChrome.InvalidateVisual();
            }
        }
예제 #3
0
        private static void OnRenderPressedChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
        {
            ImageButtonChrome buttonChrome = (ImageButtonChrome)o;

            if (!buttonChrome.Animates)
            {
                buttonChrome._localResources = null;
                buttonChrome.InvalidateVisual();
                return;
            }
            if ((bool)e.NewValue)
            {
                if (buttonChrome._localResources == null)
                {
                    buttonChrome._localResources = new ImageButtonChrome.LocalResources();
                    buttonChrome.InvalidateVisual();
                }
                Duration        duration  = new Duration(TimeSpan.FromSeconds(0.1));
                DoubleAnimation animation = new DoubleAnimation(1.0, duration);
                buttonChrome.BackgroundOverlay.BeginAnimation(Brush.OpacityProperty, animation);
                buttonChrome.BorderOverlayPen.Brush.BeginAnimation(Brush.OpacityProperty, animation);
                buttonChrome.LeftDropShadowBrush.BeginAnimation(Brush.OpacityProperty, animation);
                buttonChrome.TopDropShadowBrush.BeginAnimation(Brush.OpacityProperty, animation);
                animation = new DoubleAnimation(0.0, duration);
                buttonChrome.InnerBorderPen.Brush.BeginAnimation(Brush.OpacityProperty, animation);
                ColorAnimation         animation2    = new ColorAnimation(Color.FromRgb(194, 228, 246), duration);
                GradientStopCollection gradientStops = ((LinearGradientBrush)buttonChrome.BackgroundOverlay).GradientStops;
                gradientStops[0].BeginAnimation(GradientStop.ColorProperty, animation2);
                gradientStops[1].BeginAnimation(GradientStop.ColorProperty, animation2);
                animation2 = new ColorAnimation(Color.FromRgb(171, 218, 243), duration);
                gradientStops[2].BeginAnimation(GradientStop.ColorProperty, animation2);
                animation2 = new ColorAnimation(Color.FromRgb(144, 203, 235), duration);
                gradientStops[3].BeginAnimation(GradientStop.ColorProperty, animation2);
                animation2 = new ColorAnimation(Color.FromRgb(44, 98, 139), duration);
                buttonChrome.BorderOverlayPen.Brush.BeginAnimation(SolidColorBrush.ColorProperty, animation2);
                return;
            }
            if (buttonChrome._localResources == null)
            {
                buttonChrome.InvalidateVisual();
                return;
            }
            bool            renderMouseOver = buttonChrome.RenderMouseOver;
            Duration        duration2       = new Duration(TimeSpan.FromSeconds(0.1));
            DoubleAnimation doubleAnimation = new DoubleAnimation
            {
                Duration = duration2
            };

            buttonChrome.LeftDropShadowBrush.BeginAnimation(Brush.OpacityProperty, doubleAnimation);
            buttonChrome.TopDropShadowBrush.BeginAnimation(Brush.OpacityProperty, doubleAnimation);
            buttonChrome.InnerBorderPen.Brush.BeginAnimation(Brush.OpacityProperty, doubleAnimation);
            if (!renderMouseOver)
            {
                buttonChrome.BorderOverlayPen.Brush.BeginAnimation(Brush.OpacityProperty, doubleAnimation);
                buttonChrome.BackgroundOverlay.BeginAnimation(Brush.OpacityProperty, doubleAnimation);
            }
            ColorAnimation colorAnimation = new ColorAnimation
            {
                Duration = duration2
            };

            buttonChrome.BorderOverlayPen.Brush.BeginAnimation(SolidColorBrush.ColorProperty, colorAnimation);
            GradientStopCollection gradientStops2 = ((LinearGradientBrush)buttonChrome.BackgroundOverlay).GradientStops;

            gradientStops2[0].BeginAnimation(GradientStop.ColorProperty, colorAnimation);
            gradientStops2[1].BeginAnimation(GradientStop.ColorProperty, colorAnimation);
            gradientStops2[2].BeginAnimation(GradientStop.ColorProperty, colorAnimation);
            gradientStops2[3].BeginAnimation(GradientStop.ColorProperty, colorAnimation);
        }