protected override void OnMouseLeave(MouseEventArgs e)
        {
            base.OnMouseLeave(e);

            Background.BeginAnimation(Brush.OpacityProperty, new DoubleAnimation(Background.Opacity, 0.1,
                                                                                 new Duration(TimeSpan.FromMilliseconds(100))));
        }
Exemple #2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            timer.Interval = 90;
            timer.Elapsed += new ElapsedEventHandler(DoAnimationStep);
            timer.Enabled  = true;

            ColorAnimation backgroundAnimation = new ColorAnimation();

            backgroundAnimation.From     = Color.FromArgb(0, 0, 0, 0);
            backgroundAnimation.To       = Color.FromArgb(200, 0, 0, 0);
            backgroundAnimation.Duration = new Duration(TimeSpan.FromSeconds(5));
            Background.BeginAnimation(SolidColorBrush.ColorProperty, backgroundAnimation, HandoffBehavior.SnapshotAndReplace);

            xMax = ActualWidth - gruzImage.ActualWidth;
            yMax = ActualHeight - gruzImage.ActualHeight;

            GruzTransformAbsolute(-400, rng.NextDouble() * yMax / 2 + yMax / 4);

            xSpeed = 300;
            ySpeed = gruzImage.Margin.Top < yMax
                ? rng.NextDouble() * -75
                : rng.NextDouble() * 75;

            CompositionTarget.Rendering += ProcessGruzMother;
        }
Exemple #3
0
        private void HideScreenSaver()
        {
            if (stopped)
            {
                return;
            }
            stopped = true;
            caged   = false;
            ColorAnimation backgroundAnimation = new ColorAnimation();

            backgroundAnimation.From     = ((SolidColorBrush)this.Background).Color;
            backgroundAnimation.To       = Color.FromArgb(0, 0, 0, 0);
            backgroundAnimation.Duration = new Duration(TimeSpan.FromSeconds(0.5));
            Background.BeginAnimation(SolidColorBrush.ColorProperty, backgroundAnimation, HandoffBehavior.SnapshotAndReplace);
        }
 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);
     }
 }