Exemple #1
0
        private void initializeLine()
        {
            /// Build 2 lines to visual list for foreground and background represents ArcLine length animation
            visualList = new List <Visual>();
            var backLine = new Line();

            backLine.X2 = 1;
            backLine.StrokeThickness = 1;
            backLine.Stroke          = this.Background;
            var foreLine = new Line();

            foreLine.X2 = 1;
            foreLine.StrokeThickness = 1;
            foreLine.Stroke          = this.Foreground;

            /// Background must be ordering before foreground
            visualList.Add(backLine);
            visualList.Add(foreLine);

            lineLengthAnimation                = new DoubleAnimation(0, 0, new Duration(TimeSpan.FromMilliseconds(this.AnimationTime)));
            lineLengthAnimation.AutoReverse    = false;
            lineLengthAnimation.RepeatBehavior = new RepeatBehavior(1);
            /// Binding animation's target property to this
            lineLengthAnimation.SetValue(Storyboard.TargetProperty, this);
            /// Binding target property's property to LineLengthProperty
            lineLengthAnimation.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath(ArcLine.AnimatedLineLengthProperty));
            storyBoard = new Storyboard();
            storyBoard.Children.Add(lineLengthAnimation);
        }
        /// <summary>
        /// 使用位移创建一个动画
        /// </summary>
        /// <param name="element">要执行的控件</param>
        /// <param name="duration">持续时间</param>
        /// <param name="xTo">X的最终值</param>
        /// <param name="yTO">Y的最终值</param>
        /// <param name="completed">执行完成后的行为</param>
        public static void BeginTranslateTransform(this DependencyObject element, TimeSpan duration, double xTo, double yTO, Action completed, IEasingFunction functionX, IEasingFunction functionY)
        {
            Storyboard sb = new Storyboard();

            DoubleAnimation da_x = new DoubleAnimation(xTo, duration);

            da_x.SetValue(Storyboard.TargetProperty, element);
            da_x.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)"));
            if (functionX != null)
            {
                da_x.EasingFunction = functionX;
            }
            DoubleAnimation da_y = new DoubleAnimation(yTO, duration);

            da_y.SetValue(Storyboard.TargetProperty, element);
            da_y.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)"));
            if (functionY != null)
            {
                da_y.EasingFunction = functionY;
            }
            sb.Children.Add(da_x);
            sb.Children.Add(da_y);

            sb.Completed += (s, e) =>
            {
                if (completed != null)
                {
                    completed();
                }
            };

            sb.Begin();
        }
Exemple #3
0
        public NinjaCard(ScanInData inData)
        {
            // save ref to scan in
            ScanInData = inData;
            ScanInData.PropertyChanged += ScanInTick;

            // create shake animation
            _shakeAnim = new Storyboard();
            var doubleAnimation = new DoubleAnimation
            {
                From           = -10.0,
                To             = 10.0,
                Duration       = new Duration(TimeSpan.FromSeconds(1)),
                AutoReverse    = true,
                RepeatBehavior = RepeatBehavior.Forever
            };

            doubleAnimation.SetValue(Storyboard.TargetNameProperty, nameof(MainGridTransform));
            doubleAnimation.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath(TranslateTransform.XProperty));
            var bounceEase = new BounceEase
            {
                Bounces    = 1,
                Bounciness = 2.0,
                EasingMode = EasingMode.EaseOut
            };

            doubleAnimation.EasingFunction = bounceEase;
            _shakeAnim.Children.Add(doubleAnimation);

            // set data context
            InitializeComponent();
            MainGrid.DataContext = this;
        }
Exemple #4
0
        private void SetupIndicationArc()
        {
            var indicationArcRadius = Radius - OuterArcThickness - IndicationArcDistanceFromEdge;

            IndicationArc.Size = new Size(indicationArcRadius, indicationArcRadius);
            double startAngle = (StartAngle + .10 * Angle) * (Math.PI / 180),
                   endAngle   = (StartAngle + .90 * Angle) * (Math.PI / 180);
            double startX     = Radius + indicationArcRadius * Math.Sin(startAngle),
                   startY     = Radius - indicationArcRadius * Math.Cos(startAngle),
                   endX       = Radius + indicationArcRadius * Math.Sin(endAngle),
                   endY       = Radius - indicationArcRadius * Math.Cos(endAngle);

            IndicationArcPathFigure.StartPoint = new Point(startX, startY);
            IndicationArc.Point = new Point(endX, endY);
            IndicationArcPath.StrokeThickness = IndicationArcStrokeThickness;
            IndicationArcPath.Stroke          = new SolidColorBrush(IndicationArcColor);
            // make all arcs initiall invisibile
            IndicationArcPath.Opacity = 0.0;

            var appearAnimation = new DoubleAnimation()
            {
                From = 0.0,
                To   = 1.0,
            };

            appearAnimation.SetValue(Storyboard.TargetNameProperty, "IndicationArcPath");
            appearAnimation.SetValue(Storyboard.TargetPropertyProperty, "Opacity");
            InnerReleasedStoryBoard.Stop();
            InnerReleasedStoryBoard.Children.Add(appearAnimation);
        }
        void ShowComment(bool show)
        {
            if (show && BorderComment.Height != 0)
            {
                return;
            }
            if (!show && BorderComment.Height != 40)
            {
                return;
            }

            DoubleAnimation animation = new DoubleAnimation();

            animation.From = show ? 0 : 40;
            animation.To   = show ? 40 : 0;

            animation.Duration = new Duration(TimeSpan.FromMilliseconds(300));
            animation.SetValue(Storyboard.TargetProperty, BorderComment);
            animation.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath(Border.HeightProperty));

            Storyboard board = new Storyboard();

            board.Children.Add(animation);
            board.Begin(this);
        }
        public void ContextShrinkAnimation()
        {
            Border contextCircle = stickyWindow.sContextCircle;

            DoubleAnimation animationsContextGrowX = new DoubleAnimation(10, TimeSpan.FromMilliseconds(250));

            animationsContextGrowX.SetValue(Storyboard.TargetNameProperty, contextCircle.Name);
            animationsContextGrowX.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath(Border.WidthProperty));

            DoubleAnimation animationsContextGrowY = new DoubleAnimation(10, TimeSpan.FromMilliseconds(250));

            animationsContextGrowY.SetValue(Storyboard.TargetNameProperty, contextCircle.Name);
            animationsContextGrowY.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath(Border.HeightProperty));

            DoubleAnimation animationsContextMoveX = new DoubleAnimation(1.5, TimeSpan.FromMilliseconds(250));

            animationsContextMoveX.SetValue(Storyboard.TargetNameProperty, contextCircle.Name);
            animationsContextMoveX.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath(Canvas.LeftProperty));

            DoubleAnimation animationsContextMoveY = new DoubleAnimation(1.5, TimeSpan.FromMilliseconds(250));

            animationsContextMoveY.SetValue(Storyboard.TargetNameProperty, contextCircle.Name);
            animationsContextMoveY.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath(Canvas.TopProperty));

            Storyboard storyContextShrink = new Storyboard();

            storyContextShrink.Children.Add(animationsContextGrowX);
            storyContextShrink.Children.Add(animationsContextGrowY);
            storyContextShrink.Children.Add(animationsContextMoveX);
            storyContextShrink.Children.Add(animationsContextMoveY);

            storyContextShrink.Begin(stickyWindow.sContextCircle);
        }
Exemple #7
0
        private DoubleAnimation CreateAnim(DependencyObject target, double from, double to, string path, Duration dura, IEasingFunction easing)
        {
            DoubleAnimation daL = new DoubleAnimation(from, to, dura);

            daL.SetValue(Storyboard.TargetProperty, target);
            daL.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath(path));
            daL.EasingFunction = easing;
            return(daL);
        }
Exemple #8
0
        private DoubleAnimation CreateSlidingAnim(string elementName, double toValue)
        {
            DoubleAnimation animation = new DoubleAnimation();

            animation.SetValue(Storyboard.TargetNameProperty, elementName);
            animation.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)"));
            animation.Duration = new Duration(TimeSpan.FromSeconds(0.5));
            animation.To       = toValue;
            return(animation);
        }
        protected override void OnAttached()
        {
            base.OnAttached();

            var doubleAnimation = new DoubleAnimation(0, new Duration(TimeSpan.FromSeconds(3)));

            doubleAnimation.SetValue(Storyboard.TargetProperty, this.AssociatedObject);
            doubleAnimation.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("Opacity"));
            this.NotifyStoryboard.Children.Add(doubleAnimation);

            this.AssociatedObject.IsVisibleChanged += AssociatedObject_IsVisibleChanged;
        }
        private Storyboard createFadeStoryboard(Rectangle obj)
        {
            DoubleAnimation fade = new DoubleAnimation();

            fade.To       = 0;
            fade.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 500));
            fade.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("Opacity"));
            fade.SetValue(Storyboard.TargetProperty, obj);

            Storyboard sb = new Storyboard();

            sb.Children.Add(fade);
            return(sb);
        }
Exemple #11
0
        private static void OnElementPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (e.NewValue != null)
            {
                DoubleAnimation doubleAnimation = (DoubleAnimation)d;

                doubleAnimation.SetValue(TargetProperty, e.NewValue);
                doubleAnimation.From = 0;
                doubleAnimation.To   = 1;
                doubleAnimation.SetValue(TargetPropertyProperty, FrameworkElement.MarginProperty);
                Storyboard.SetTargetProperty(doubleAnimation, new PropertyPath("(ThicknessAnimationX.Time)"));
                Storyboard.SetTarget(doubleAnimation, doubleAnimation);
            }
        }
Exemple #12
0
        private void CreateGridAnimation()
        {
            int maxwitdh, minWitdh;

            maxwitdh            = _myMap.Count * ITEM_WIDTH + ITEM_MARGIN_BACK * 2;
            this.mapItems.Width = minWitdh = ITEM_WIDTH + _myMap.Count * ITEM_MARGIN_BACK * 2;

            //移入特效
            DoubleAnimation danima = new DoubleAnimation();

            danima.SetValue(Storyboard.TargetNameProperty, "mapItems");
            danima.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("UIElement.Width"));
            danima.From     = minWitdh;
            danima.To       = maxwitdh;
            danima.Duration = new Duration(TimeSpan.FromSeconds(0.2));
            sboardEnter.Children.Add(danima);

            ColorAnimation danima01 = new ColorAnimation();

            danima01.SetValue(Storyboard.TargetNameProperty, "mapItems");
            danima01.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(UIElement.Background).(SolidColorBrush.Color)"));
            danima01.From     = Color.FromArgb(20, 9, 49, 73);
            danima01.To       = Color.FromArgb(140, 9, 49, 73);
            danima01.Duration = new Duration(TimeSpan.FromSeconds(0.2));
            sboardEnter.Children.Add(danima01);

            //移出特效
            DoubleAnimation danima1 = new DoubleAnimation();

            danima1.SetValue(Storyboard.TargetNameProperty, "mapItems");
            danima1.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("UIElement.Width"));
            danima1.From     = maxwitdh;
            danima1.To       = minWitdh;
            danima1.Duration = new Duration(TimeSpan.FromSeconds(0.2));
            sboardLeave.Children.Add(danima1);

            ColorAnimation danima02 = new ColorAnimation();

            danima02.SetValue(Storyboard.TargetNameProperty, "mapItems");
            danima02.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(UIElement.Background).(SolidColorBrush.Color)"));
            danima02.From     = Color.FromArgb(140, 9, 49, 73);
            danima02.To       = Color.FromArgb(20, 9, 49, 73);
            danima02.Duration = new Duration(TimeSpan.FromSeconds(0.2));
            sboardLeave.Children.Add(danima02);

            this.mapItems.Resources.Add("Storyboard", sboardEnter);
            this.mapItems.Resources.Add("Storyboard1", sboardLeave);
        }
Exemple #13
0
        private void RunAnimation()
        {
            if (AssociatedObject == null)
            {
                return;
            }

            // Zielelement für die Animation im Storyboard festlegen
            animation.SetValue(Storyboard.TargetProperty, AssociatedObject);

            // Strichlänge berechnen
            var dashLength = AssociatedObject.StrokeDashArray.Sum() * (AssociatedObject.StrokeDashArray.Count % 2 + 1);

            switch (AnimationDirection)
            {
            case AnimationDirection.Stopped:
                storyboard.Stop();
                break;

            case AnimationDirection.Forward:
                animation.From = dashLength;
                animation.To   = 0;
                storyboard.Begin();
                break;

            case AnimationDirection.Reverse:
                animation.From = 0;
                animation.To   = dashLength;
                storyboard.Begin();
                break;
            }
        }
        /// <summary>
        /// Creates a Timeline used to animate the thickness of an object
        /// </summary>
        /// <param name="target">The object to animate</param>
        /// <param name="targetProperty">The property on the object to animate</param>
        /// <param name="duration">The length of the animation</param>
        /// <param name="from">The begining thickness</param>
        /// <param name="to">The final thickness</param>
        /// <returns>A timeline object that can be added to a storyboard</returns>
        public static Timeline Create(DependencyObject target, DependencyProperty targetProperty, Duration duration, Thickness from, Thickness to)
        {
            DoubleAnimation timeAnimation = new DoubleAnimation()
            {
                From = 0, To = 1, Duration = duration
            };

            timeAnimation.AutoReverse = false;
            timeAnimation.SetValue(TargetProperty, target);
            timeAnimation.SetValue(TargetPropertyProperty, targetProperty);
            timeAnimation.SetValue(FromProperty, from);
            timeAnimation.SetValue(ToProperty, to);
            Storyboard.SetTargetProperty(timeAnimation, new PropertyPath("(ThicknessAnimation.Time)"));
            Storyboard.SetTarget(timeAnimation, timeAnimation);
            return(timeAnimation);
        }
        Storyboard CreateStoryboard(double opacity)
        {
            Storyboard sb = new Storyboard();

            DoubleAnimation daOpa = new DoubleAnimation(opacity, ConstDuration);

            daOpa.SetValue(Storyboard.TargetProperty, SplitAdorner.VisualBlur);
            daOpa.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("Opacity"));
            sb.Children.Add(daOpa);

            sb.AccelerationRatio = 0.5;
            sb.DecelerationRatio = 0.5;

            _lastSB = sb;
            return(sb);
        }
Exemple #16
0
            private void Show()
            {
                DoubleAnimation animation = new DoubleAnimation();

                animation.From = 1;
                animation.To   = 0;

                animation.Duration = new Duration(TimeSpan.FromSeconds(2));
                animation.SetValue(Storyboard.TargetProperty, this);
                animation.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath(Rectangle.OpacityProperty));

                Storyboard board = new Storyboard();

                board.Children.Add(animation);

                board.Begin(this);
            }
Exemple #17
0
 private void SetTransformationDirection()
 {
     if (_openAnimation == null || _closeAnimation == null)
     {
         return;
     }
     if (this.Alignment == FlyoutAlignmentType.Left || this.Alignment == FlyoutAlignmentType.Right)
     {
         _openAnimation.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("RenderTransform.X"));
         _closeAnimation.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("RenderTransform.X"));
     }
     else
     {
         _openAnimation.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("RenderTransform.Y"));
         _closeAnimation.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("RenderTransform.Y"));
     }
 }
        void AnimateCloseControl(bool show)
        {
            DoubleAnimation animation = new DoubleAnimation();

            animation.From      = show ? 0 : 1;
            animation.To        = show ? 1 : 0;
            animation.BeginTime = new TimeSpan(0, 0, show ? 0 : 1);
            animation.Duration  = new Duration(TimeSpan.FromMilliseconds(500));
            animation.SetValue(Storyboard.TargetProperty, this.PinCloseControl);
            animation.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath(Rectangle.OpacityProperty));

            Storyboard board = new Storyboard();

            board.Children.Add(animation);

            board.Begin(this);
        }
        private void StartTimer()
        {
            DoubleAnimation daValueProperty = new DoubleAnimation
            {
                From     = 200,
                To       = 0,
                Duration = TimeSpan.FromSeconds(200)
            };

            daValueProperty.SetValue(Storyboard.TargetNameProperty, "progressBarTimeLeft");
            daValueProperty.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("Value"));

            ColorAnimation caForegroundProperty = new ColorAnimation
            {
                To        = Colors.Red,
                BeginTime = TimeSpan.FromSeconds(170)
            };

            caForegroundProperty.SetValue(Storyboard.TargetNameProperty, "progressBarTimeLeft");
            caForegroundProperty.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("Foreground.Color"));

            DoubleAnimation daOpacityProperty = new DoubleAnimation
            {
                From           = 1,
                To             = 0,
                Duration       = TimeSpan.FromMilliseconds(900),
                AutoReverse    = true,
                RepeatBehavior = RepeatBehavior.Forever,
                BeginTime      = TimeSpan.FromSeconds(185)
            };

            daOpacityProperty.SetValue(Storyboard.TargetNameProperty, "progressBarTimeLeft");
            daOpacityProperty.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("Opacity"));


            App.TimerStoryboard = new Storyboard();
            App.TimerStoryboard.Children.Add(daValueProperty);
            App.TimerStoryboard.Children.Add(caForegroundProperty);
            App.TimerStoryboard.Children.Add(daOpacityProperty);
            App.TimerStoryboard.Duration = TimeSpan.FromSeconds(200);

            //sb.Completed += new EventHandler(GameOver);

            App.TimerStoryboard.Begin(gameGrid, true);
        }
Exemple #20
0
        Storyboard CreateStoryboard(Point toPnt, double scaleX, double scaleY, double opacity)
        {
            Storyboard      sb     = new Storyboard();
            ExponentialEase easing = new ExponentialEase()
            {
                Exponent = 4, EasingMode = EasingMode.EaseInOut
            };

            DoubleAnimation daX = new DoubleAnimation(toPnt.X, ConstDuration);

            daX.SetValue(Storyboard.TargetProperty, DropAdorner.VisualCover);
            daX.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("DataContext.TransParam.TranslateX"));
            daX.EasingFunction = easing;
            sb.Children.Add(daX);

            DoubleAnimation daY = new DoubleAnimation(toPnt.Y, ConstDuration);

            daY.SetValue(Storyboard.TargetProperty, DropAdorner.VisualCover);
            daY.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("DataContext.TransParam.TranslateY"));
            daY.EasingFunction = easing;
            sb.Children.Add(daY);

            DoubleAnimation daSX = new DoubleAnimation(scaleX, ConstDuration);

            daSX.SetValue(Storyboard.TargetProperty, DropAdorner.VisualCover);
            daSX.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("DataContext.TransParam.ScaleX"));
            daSX.EasingFunction = easing;
            sb.Children.Add(daSX);

            DoubleAnimation daSY = new DoubleAnimation(scaleY, ConstDuration);

            daSY.SetValue(Storyboard.TargetProperty, DropAdorner.VisualCover);
            daSY.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("DataContext.TransParam.ScaleY"));
            daSY.EasingFunction = easing;
            sb.Children.Add(daSY);

            DoubleAnimation daOpa = new DoubleAnimation(opacity, ConstDuration);

            daOpa.SetValue(Storyboard.TargetProperty, DropAdorner.VisualBlur);
            daOpa.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("Opacity"));
            sb.Children.Add(daOpa);

            _lastSB = sb;
            return(sb);
        }
 private void SetTransformationDirection()
 {
     if (_openAnimation == null || _closeAnimation == null)
     {
         return;
     }
     _openAnimation.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("RenderTransform.Y"));
     _closeAnimation.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("RenderTransform.Y"));
 }
Exemple #22
0
        public Storyboard FadeInAndAnimateHeight(UIElement control, bool setOpacityToZero, double oldHeight, double newHeight)
        {
            Storyboard sb = new Storyboard();
            // Opacity
            DoubleAnimation daOpacity = new DoubleAnimation()
            {
                Duration       = TimeSpan.FromMilliseconds(150),
                To             = 1,
                EasingFunction = new CircleEase {
                    EasingMode = EasingMode.EaseInOut
                }
            };

            if (setOpacityToZero)
            {
                daOpacity.From = 0;
            }

            daOpacity.SetValue(Storyboard.TargetPropertyProperty, "UIElement.Opacity");
            Storyboard.SetTarget(daOpacity, control);

            sb.Children.Add(daOpacity);


            // Height
            DoubleAnimationUsingKeyFrames da = new DoubleAnimationUsingKeyFrames()
            {
                EnableDependentAnimation = true
            };

            da.SetValue(Storyboard.TargetPropertyProperty, "FrameworkElement.Height");

            EasingDoubleKeyFrame oldHeightKeyFrame = new EasingDoubleKeyFrame()
            {
                KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)),
                Value   = oldHeight
            };

            EasingDoubleKeyFrame heightKeyFrame = new EasingDoubleKeyFrame()
            {
                KeyTime        = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(200)),
                Value          = newHeight,
                EasingFunction = new CircleEase {
                    EasingMode = EasingMode.EaseInOut
                }
            };

            da.KeyFrames.Add(oldHeightKeyFrame);
            da.KeyFrames.Add(heightKeyFrame);

            Storyboard.SetTarget(da, control);

            sb.Children.Add(da);

            return(sb);
        }
Exemple #23
0
        public Storyboard IncreaseScale(UIElement control, bool fadeIn = false)
        {
            int        time       = 1200;
            Storyboard storyboard = new Storyboard();

            ScaleTransform scale = new ScaleTransform();

            control.RenderTransformOrigin = new Point(0.5, 0.5);
            control.RenderTransform       = scale;

            DoubleAnimation growAnimation = new DoubleAnimation();

            growAnimation.Duration       = TimeSpan.FromMilliseconds(time);
            growAnimation.From           = 1;
            growAnimation.To             = 1.3;
            growAnimation.EasingFunction = new CircleEase {
                EasingMode = EasingMode.EaseOut
            };
            storyboard.Children.Add(growAnimation);

            DoubleAnimation growAnimationY = new DoubleAnimation();

            growAnimationY.Duration       = TimeSpan.FromMilliseconds(time);
            growAnimationY.From           = 1;
            growAnimationY.To             = 1.3;
            growAnimationY.EasingFunction = new CircleEase {
                EasingMode = EasingMode.EaseOut
            };
            storyboard.Children.Add(growAnimationY);

            if (fadeIn)
            {
                DoubleAnimation da = new DoubleAnimation()
                {
                    Duration       = TimeSpan.FromMilliseconds(Convert.ToInt32(time / 2)),
                    From           = 0,
                    To             = 1,
                    EasingFunction = new CircleEase {
                        EasingMode = EasingMode.EaseInOut
                    }
                };

                da.SetValue(Storyboard.TargetPropertyProperty, "UIElement.Opacity");
                Storyboard.SetTarget(da, control);

                storyboard.Children.Add(da);
            }

            Storyboard.SetTargetProperty(growAnimation, "(UIElement.RenderTransform).(ScaleTransform.ScaleX)");
            Storyboard.SetTargetProperty(growAnimationY, "(UIElement.RenderTransform).(ScaleTransform.ScaleY)");

            Storyboard.SetTarget(growAnimation, control);
            Storyboard.SetTarget(growAnimationY, control);

            return(storyboard);
        }
        private Storyboard CreateAnimation(IEnumerable <ExpandableWrapper> controls, bool visible)
        {
            Storyboard sb = new Storyboard();

            sb.FillBehavior = FillBehavior.HoldEnd;

            var ease = new PowerEase()
            {
                Power = 5
            };
            var duration = TimeSpan.FromMilliseconds(700);

            foreach (var c in controls)
            {
                DoubleAnimation opacity = new DoubleAnimation(visible ? 1 : 0, duration);
                opacity.EasingFunction = ease;
                opacity.SetValue(Storyboard.TargetProperty, c);
                opacity.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath(ExpandableWrapper.OpacityProperty));
                sb.Children.Add(opacity);

                // replace the current transform with one that's not currently locked by an old animation.
                ScaleTransform st = new ScaleTransform(c.Scale.ScaleX, c.Scale.ScaleY);
                if (Orientation == Orientation.Horizontal)
                {
                    st.ScaleY = 1;
                }
                else
                {
                    st.ScaleX = 1;
                }
                c.Scale = st;

                DoubleAnimation size = new DoubleAnimation(visible ? 1 : 0, duration);
                size.EasingFunction = ease;
                size.SetValue(Storyboard.TargetProperty, c);
                size.SetValue(Storyboard.TargetPropertyProperty,
                              new PropertyPath(Orientation == Orientation.Horizontal ? "LayoutTransform.ScaleX" : "LayoutTransform.ScaleY"));
                sb.Children.Add(size);

                c.Child.Focusable = visible && c.ChildFocusableDefault;
            }
            return(sb);
        }
Exemple #25
0
            private void SetActionTriggers()
            {
                var width = _slidingPage.ActualWidth;


                EnterActions.Clear();
                ExitActions.Clear();

                var enterStoryboard = new Storyboard();

                var enterMarginAnimation = new ThicknessAnimation(new Thickness(width, 0, -width, 0), new Thickness(0), new Duration(TimeSpan.FromSeconds(.75)))
                {
                    DecelerationRatio = .9
                };

                enterMarginAnimation.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(FrameworkElement.Margin)"));
                enterStoryboard.Children.Add(enterMarginAnimation);

                var enterOpacityAnimation = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(.25)));

                enterOpacityAnimation.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(UIElement.Opacity)"));
                enterStoryboard.Children.Add(enterOpacityAnimation);

                var enterVisibilityAnimation = new EnterVisibilityAnimation();

                enterStoryboard.Children.Add(enterVisibilityAnimation);

                EnterActions.Add(new BeginStoryboard {
                    Storyboard = enterStoryboard
                });


                var exitStoryboard = new Storyboard();

                var exitMarginAnimation = new ThicknessAnimation(new Thickness(-width, 0, width, 0), new Duration(TimeSpan.FromSeconds(.5)))
                {
                    AccelerationRatio = .9
                };

                exitMarginAnimation.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(FrameworkElement.Margin)"));
                exitStoryboard.Children.Add(exitMarginAnimation);

                var exitOpacityAnimation = new DoubleAnimation(0, new Duration(TimeSpan.FromSeconds(.5)));

                exitOpacityAnimation.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(UIElement.Opacity)"));
                exitStoryboard.Children.Add(exitOpacityAnimation);

                var exitVisibilityAnimation = new ExitVisibilityAnimation();

                exitStoryboard.Children.Add(exitVisibilityAnimation);

                ExitActions.Add(new BeginStoryboard {
                    Storyboard = exitStoryboard
                });
            }
Exemple #26
0
        /// <summary>
        /// Medhod to create new Double Animation object
        /// </summary>
        /// <param name="to"></param>
        /// <param name="duration"></param>
        /// <param name="targetProperty"></param>
        /// <param name="propertyPath"></param>
        /// <param name="easingFunction"></param>
        /// <returns></returns>
        private DoubleAnimation CreateDoubleAnimation(double to, TimeSpan duration,
                                                      string targetProperty, string propertyPath, IEasingFunction easingFunction)
        {
            DoubleAnimation da = new DoubleAnimation(to, duration);

            da.SetValue(Storyboard.TargetNameProperty, targetProperty);
            Storyboard.SetTargetProperty(da, new PropertyPath(propertyPath));
            da.EasingFunction = easingFunction;

            return(da);
        }
        private static DoubleAnimation GetOpac(bool isInanimation, int animationTime)
        {
            double from = isInanimation ? 0 : 1;
            double to   = from == 1 ? 0 : 1;

            var opac = new DoubleAnimation(from, to, new Duration(new TimeSpan(0, 0, 0, 0, animationTime)));

            opac.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("Opacity"));


            return(opac);
        }
Exemple #28
0
 private void OnCloseButtonClicked(object sender, RoutedEventArgs e)
 {
     if (_popup != null && _border != null)
     {
         if (_popup.PopupAnimation == PopupAnimation.Slide)
         {
             _border.RenderTransform = new TranslateTransform(0, 0);
             var closeAnimation = new DoubleAnimation(this.RenderSize.Height * -1, new Duration(new System.TimeSpan(0, 0, 0, 0, 200)));
             closeAnimation.SetValue(Storyboard.TargetProperty, _border);
             closeAnimation.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("RenderTransform.Y"));
             var storyboard = new Storyboard();
             storyboard.Children.Add(closeAnimation);
             storyboard.Completed += this.OnCloseStoryboardCompleted;
             storyboard.Begin();
         }
         else
         {
             _popup.IsOpen = false;
         }
     }
 }
Exemple #29
0
        public static Timeline Create(DependencyObject target, DependencyProperty targetProperty,
                                      Duration duration, Thickness from, Thickness to)
        {
            DoubleAnimation timeAnimation = new DoubleAnimation()
            {
                From = 0, To = 1, Duration = duration
            };

            timeAnimation.EasingFunction = new ExponentialEase()
            {
                Exponent   = 9,
                EasingMode = System.Windows.Media.Animation.EasingMode.EaseOut
            };
            timeAnimation.SetValue(TargetProperty, target);
            timeAnimation.SetValue(TargetPropertyProperty, targetProperty);
            timeAnimation.SetValue(FromProperty, from);
            timeAnimation.SetValue(ToProperty, to);
            Storyboard.SetTargetProperty(timeAnimation, new PropertyPath("(ThicknessAnimation.Time)"));
            Storyboard.SetTarget(timeAnimation, timeAnimation);
            return(timeAnimation);
        }
Exemple #30
0
        private Storyboard CreateStoryboard(ToggleButton tb)
        {
            DoubleAnimation scaleAnimX = new DoubleAnimation()
            {
                AutoReverse    = true,
                Duration       = new Duration(new TimeSpan(0, 0, 0, 0, 250)),
                RepeatBehavior = RepeatBehavior.Forever,
                To             = 0.8
            }, scaleAnimY = new DoubleAnimation()
            {
                AutoReverse    = true,
                Duration       = new Duration(new TimeSpan(0, 0, 0, 0, 250)),
                RepeatBehavior = RepeatBehavior.Forever,
                To             = 0.8
            }, translateAnimX = new DoubleAnimation()
            {
                AutoReverse    = true,
                Duration       = new Duration(new TimeSpan(0, 0, 0, 0, 250)),
                RepeatBehavior = RepeatBehavior.Forever,
                To             = 3
            }, translateAnimY = new DoubleAnimation()
            {
                AutoReverse    = true,
                Duration       = new Duration(new TimeSpan(0, 0, 0, 0, 250)),
                RepeatBehavior = RepeatBehavior.Forever,
                To             = 3
            };

            // Set targets
            Storyboard.SetTarget(scaleAnimX, tb);
            Storyboard.SetTarget(translateAnimX, tb);
            Storyboard.SetTarget(translateAnimY, tb);
            Storyboard.SetTarget(scaleAnimY, tb);

            // Set properties
            scaleAnimX.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(ToggleButton.RenderTransform).(CompositeTransform.ScaleX)"));
            scaleAnimY.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(ToggleButton.RenderTransform).(CompositeTransform.ScaleY)"));
            translateAnimX.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(ToggleButton.RenderTransform).(CompositeTransform.TranslateX)"));
            translateAnimY.SetValue(Storyboard.TargetPropertyProperty, new PropertyPath("(ToggleButton.RenderTransform).(CompositeTransform.TranslateY)"));

            // Add to storyboard
            return(new Storyboard()
            {
                Children =
                {
                    scaleAnimX,
                    scaleAnimY,
                    translateAnimX,
                    translateAnimY
                }
            });
        }