private void AssociatedObject_Loaded(object sender, RoutedEventArgs e)
        {
            SlideshowButton.Click += (s, e1) =>
            {
                var brushAnimation = new BrushAnimation();
                brushAnimation.To       = Brushes.Black;
                brushAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(800));

                GridLengthAnimation heightAnimation = new GridLengthAnimation();
                heightAnimation.To       = new GridLength(0);
                heightAnimation.From     = new GridLength(120.0);
                heightAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(500));

                GridLengthAnimation heightAnimation2 = new GridLengthAnimation();
                heightAnimation2.To       = new GridLength(0);
                heightAnimation2.From     = new GridLength(35.0);
                heightAnimation2.Duration = new Duration(TimeSpan.FromMilliseconds(500));

                heightAnimation.DecelerationRatio  = 0.5;
                heightAnimation2.DecelerationRatio = 0.5;

                MainGrid.RowDefinitions[MainGrid.RowDefinitions.Count - 1].BeginAnimation(RowDefinition.HeightProperty, heightAnimation);
                MainGrid.RowDefinitions[0].BeginAnimation(RowDefinition.HeightProperty, heightAnimation2);

                MainGrid.BeginAnimation(Grid.BackgroundProperty, brushAnimation);

                RotateButton.Visibility    = Visibility.Collapsed;
                SlideshowButton.Visibility = Visibility.Collapsed;
            };
        }
Esempio n. 2
0
        private void ChangeChecked()
        {
            var sb = new Storyboard();

            DoubleAnimation doubleAnimation = new DoubleAnimation(Canvas.GetLeft(Ellipse), GetEllipseMargin(IsChecked), new Duration(TimeSpan.FromMilliseconds(200)), FillBehavior.Stop);

            Storyboard.SetTarget(doubleAnimation, Ellipse);
            Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("(Canvas.Left)"));
            sb.Children.Add(doubleAnimation);
            sb.Completed += (sender, args) => Canvas.SetLeft(Ellipse, GetEllipseMargin(IsChecked));
            sb.Begin();

            var animation = new BrushAnimation {
                From         = GetBackgroundColor(!IsChecked),
                To           = GetBackgroundColor(IsChecked),
                Duration     = new Duration(TimeSpan.FromMilliseconds(200)),
                FillBehavior = FillBehavior.Stop,
            };

            Storyboard.SetTarget(animation, Rectangle);
            Storyboard.SetTargetProperty(animation, new PropertyPath("Fill"));
            sb = new Storyboard();
            sb.Children.Add(animation);
            sb.Completed += (sender, args) => { Rectangle.Fill = GetBackgroundColor(IsChecked); };
            sb.Begin();
        }
Esempio n. 3
0
        private Storyboard CreateConspicuousStoryboard()
        {
            var storyboard      = new Storyboard();
            var animaBackground = new BrushAnimation()
            {
                From     = Brushes.Transparent,
                To       = Background,
                Duration = Duration,
            };

            Storyboard.SetTarget(animaBackground, this);
            Storyboard.SetTargetProperty(animaBackground, new PropertyPath("Background"));

            var animaForeground = new BrushAnimation()
            {
                From     = Foreground,
                To       = Brushes.White,
                Duration = TimeSpan.FromMilliseconds(Duration.TotalMilliseconds * 0.7),
            };

            Storyboard.SetTarget(animaForeground, this);
            Storyboard.SetTargetProperty(animaForeground, new PropertyPath("Foreground"));

            var totalMs = Duration.TotalMilliseconds;

            if (Interval != null)
            {
                totalMs += ((TimeSpan)Interval).TotalMilliseconds;
            }

            var animaBackgroundReverse = new BrushAnimation()
            {
                To        = Brushes.Transparent,
                Duration  = Duration,
                BeginTime = TimeSpan.FromMilliseconds(totalMs),
            };

            Storyboard.SetTarget(animaBackgroundReverse, this);
            Storyboard.SetTargetProperty(animaBackgroundReverse, new PropertyPath("Background"));

            var animaForegroundReverse = new BrushAnimation()
            {
                To        = Foreground,
                Duration  = Duration,
                BeginTime = TimeSpan.FromMilliseconds(totalMs),
            };

            Storyboard.SetTarget(animaForegroundReverse, this);
            Storyboard.SetTargetProperty(animaForegroundReverse, new PropertyPath("Foreground"));

            storyboard.Children.Add(animaBackground);
            storyboard.Children.Add(animaForeground);
            storyboard.Children.Add(animaBackgroundReverse);
            storyboard.Children.Add(animaForegroundReverse);

            return(storyboard);
        }
Esempio n. 4
0
        public void SetChecked(bool Vischecked, bool IgnoreAnimation = false)
        {
            if (Vischecked)
            {
                if (DoAnimation && !IgnoreAnimation)
                {
                    BrushAnimation animation = new BrushAnimation
                    {
                        From     = UncheckedBrush,
                        To       = CheckedBrush,
                        Duration = new Duration(TimeSpan.FromMilliseconds(300)),
                    };

                    Storyboard.SetTarget(animation, CBorder);
                    Storyboard.SetTargetProperty(animation, new PropertyPath("Background"));

                    var sb = new Storyboard();
                    sb.Children.Add(animation);
                    sb.Begin();
                }

                CBorder.Background = CheckedBrush;
                Ccontent.Content   = contentCreatorChecked.Create(data);
                IsChecked          = true;
            }
            else
            {
                if (DoAnimation && !IgnoreAnimation)
                {
                    if (UncheckedBrush is ImageBrush)
                    {
                        ((ImageBrush)UncheckedBrush).Stretch = stretchN;
                    }

                    BrushAnimation animation = new BrushAnimation
                    {
                        From     = CheckedBrush,
                        To       = UncheckedBrush,
                        Duration = new Duration(TimeSpan.FromMilliseconds(300)),
                    };

                    Storyboard.SetTarget(animation, CBorder);
                    Storyboard.SetTargetProperty(animation, new PropertyPath("Background"));

                    var sb = new Storyboard();
                    sb.Children.Add(animation);
                    sb.Begin();
                }

                CBorder.Background = UncheckedBrush;
                Ccontent.Content   = contentCreatorUnchecked.Create(data);
                IsChecked          = false;
            }
        }
Esempio n. 5
0
        public static void BeginBrushStoryboard(DependencyObject dependencyObj, IList <DependencyProperty> dpList)
        {
            var storyboard = new Storyboard();

            foreach (var dp in dpList)
            {
                var anima = new BrushAnimation()
                {
                    Duration = TimeSpan.FromSeconds(0.4),
                };
                Storyboard.SetTarget(anima, dependencyObj);
                Storyboard.SetTargetProperty(anima, new PropertyPath(dp));
                storyboard.Children.Add(anima);
            }
            storyboard.Begin();
        }
Esempio n. 6
0
        public static void BeginBrushAnimationStoryboard(DependencyObject obj, List <DependencyProperty> properties, TimeSpan?duration = null)
        {
            var storyboard = new Storyboard();

            foreach (var dp in properties)
            {
                var anima = new BrushAnimation()
                {
                    Duration = duration ?? GlobalSettings.Setting.AnimationDuration,
                };
                Storyboard.SetTarget(anima, obj);
                Storyboard.SetTargetProperty(anima, new PropertyPath(dp));
                storyboard.Children.Add(anima);
            }
            storyboard.Begin();
        }
Esempio n. 7
0
        public static void BeginBrushStoryboard(DependencyObject dependencyObj, IDictionary <DependencyProperty, Brush> toDictionary)
        {
            var storyboard = new Storyboard();

            foreach (var keyValue in toDictionary)
            {
                var anima = new BrushAnimation()
                {
                    To       = keyValue.Value,
                    Duration = TimeSpan.FromSeconds(0.4),
                };
                Storyboard.SetTarget(anima, dependencyObj);
                Storyboard.SetTargetProperty(anima, new PropertyPath(keyValue.Key));
                storyboard.Children.Add(anima);
            }
            storyboard.Begin();
        }
Esempio n. 8
0
        //********************* EVENTS *********************//
        public void btnAnimation(Button b)
        {
            var animation = new BrushAnimation
            {
                From     = Brushes.IndianRed,
                To       = Brushes.Transparent,
                Duration = new Duration(TimeSpan.FromSeconds(0.1)),
            };

            Storyboard.SetTarget(animation, b);
            Storyboard.SetTargetProperty(animation, new PropertyPath("Background"));

            var sb = new Storyboard();

            sb.Children.Add(animation);
            sb.Begin();
        }
Esempio n. 9
0
        public static void BeginBrushAnimationStoryboard(DependencyObject obj, Dictionary <DependencyProperty, Brush> propertyValues, TimeSpan?duration = null)
        {
            var storyboard = new Storyboard();

            foreach (var propertyValue in propertyValues)
            {
                if (!propertyValue.Value.CanFreeze)
                {
                    continue;
                }
                var anima = new BrushAnimation()
                {
                    To       = propertyValue.Value,
                    Duration = duration ?? GlobalSettings.Setting.AnimationDuration,
                };
                Storyboard.SetTarget(anima, obj);
                Storyboard.SetTargetProperty(anima, new PropertyPath(propertyValue.Key));
                storyboard.Children.Add(anima);
            }
            storyboard.Begin();
        }