Inheritance: Timeline, IDoubleAnimation
        private void StartAnimation(EasingFunctionBase easingFunction)
        {
            // show the chart
            chartControl.Draw(easingFunction);

            // animation
#if WPF
            NameScope.SetNameScope(translate1, new NameScope());
#endif

            var storyboard = new Storyboard();
            var ellipseMove = new DoubleAnimation();
            ellipseMove.EasingFunction = easingFunction;
            ellipseMove.Duration = new Duration(TimeSpan.FromSeconds(AnimationTimeSeconds));
            ellipseMove.From = 0;
            ellipseMove.To = 460;
#if WPF
            Storyboard.SetTargetName(ellipseMove, nameof(translate1));
            Storyboard.SetTargetProperty(ellipseMove, new PropertyPath(TranslateTransform.XProperty));
#else
            Storyboard.SetTarget(ellipseMove, translate1);
            Storyboard.SetTargetProperty(ellipseMove, "X");
#endif

            ellipseMove.BeginTime = TimeSpan.FromSeconds(0.5); // start animation in 0.5 seconds
            ellipseMove.FillBehavior = FillBehavior.HoldEnd; // keep position after animation

            storyboard.Children.Add(ellipseMove);
#if WPF
            storyboard.Begin(this);
#else
            storyboard.Begin();
#endif
        }
        public void AnimateVertexForward(VertexControl target)
        {
            var transform = CustomHelper.GetScaleTransform(target);
            if (transform == null)
            {
                target.RenderTransform = new ScaleTransform();
                transform = target.RenderTransform as ScaleTransform;
                if (CenterScale)
                    target.RenderTransformOrigin = new Point(.5, .5);
                else
                    target.RenderTransformOrigin = new Point(0, 0);
            }

            var sb = new Storyboard();
            var scaleAnimation = new DoubleAnimation { Duration = new Duration(TimeSpan.FromSeconds(Duration)), From = 1, To = ScaleTo };
            Storyboard.SetTarget(scaleAnimation, target);
            Storyboard.SetTargetProperty(scaleAnimation, "(UIElement.RenderTransform).(CompositeTransform.ScaleX)");
            sb.Children.Add(scaleAnimation);
            scaleAnimation = new DoubleAnimation { Duration = new Duration(TimeSpan.FromSeconds(Duration)), From = 1, To = ScaleTo };
            Storyboard.SetTarget(scaleAnimation, target);
            Storyboard.SetTargetProperty(scaleAnimation, "(UIElement.RenderTransform).(CompositeTransform.ScaleY)");
            sb.Children.Add(scaleAnimation);

            //transform.BeginAnimation(ScaleTransform.ScaleXProperty, scaleAnimation);
            //transform.BeginAnimation(ScaleTransform.ScaleYProperty, scaleAnimation);
            sb.Begin();
        }
Example #3
0
        /// <summary>
        /// Begint een nieuw storyboard dat het menu grid uitschuift of inschuift naar een positieve (zichtbaar) of negatieve (onzichtbaar) margin.
        /// </summary>
        public void BeginMenuAnimatie()
        {
            Storyboard storyboard = new Storyboard();
            TranslateTransform beweegTransformatie = new TranslateTransform();
            menu.RenderTransform = beweegTransformatie;
            DoubleAnimation verplaatsMenuAnimatie = new DoubleAnimation();
            verplaatsMenuAnimatie.Duration = new Duration(TimeSpan.FromSeconds(0.15));
            if (btnHideShow.Content.Equals(">"))
            {
                verplaatsMenuAnimatie.To = 303;
                verplaatsMenuAnimatie.From = 0;
                btnHideShow.Content = "<";
            }
            else
            {
                verplaatsMenuAnimatie.To = 0;
                verplaatsMenuAnimatie.From = 303;
                btnHideShow.Content = ">";
            }

            storyboard.Children.Add(verplaatsMenuAnimatie);
            Storyboard.SetTarget(verplaatsMenuAnimatie, beweegTransformatie);
            Storyboard.SetTargetProperty(verplaatsMenuAnimatie, "X");
            storyboard.Begin();
        }
        public void AnimateVertexBackward(VertexControl target)
        {
            var transform = CustomHelper.GetScaleTransform(target);
            if (transform == null)
            {
                target.RenderTransform = new ScaleTransform();
                transform = target.RenderTransform as ScaleTransform;
                target.RenderTransformOrigin = CenterScale ? new Point(.5, .5) : new Point(0, 0);
                return; //no need to back cause default already
            }

            if (transform.ScaleX <= 1 || transform.ScaleY <= 1) return;

            var sb = new Storyboard();
            var scaleAnimation = new DoubleAnimation{ Duration = new Duration(TimeSpan.FromSeconds(Duration)), From = transform.ScaleX, To = 1 };
            Storyboard.SetTarget(scaleAnimation, target);
            Storyboard.SetTargetProperty(scaleAnimation, "(UIElement.RenderTransform).(CompositeTransform.ScaleX)");
            sb.Children.Add(scaleAnimation);
            scaleAnimation = new DoubleAnimation { Duration = new Duration(TimeSpan.FromSeconds(Duration)), From = transform.ScaleX, To = 1 };
            Storyboard.SetTarget(scaleAnimation, target);
            Storyboard.SetTargetProperty(scaleAnimation, "(UIElement.RenderTransform).(CompositeTransform.ScaleY)");
            sb.Children.Add(scaleAnimation);

            //transform.BeginAnimation(ScaleTransform.ScaleXProperty, scaleAnimation);
            //transform.BeginAnimation(ScaleTransform.ScaleYProperty, scaleAnimation);
            sb.Begin();
        }
Example #5
0
        public void MoveTo(Point from, Point to, EventHandler<object> completed = null)
        {
            TranslateTransform trans = new TranslateTransform();

            _participant.Name = "MyTarget";
            _participant.RenderTransform = trans;

            DoubleAnimation anim1 = new DoubleAnimation() { From = from.X, To = to.X, Duration = TimeSpan.FromMilliseconds(Utility.GAME_TICK_MS - 1) };
            DoubleAnimation anim2 = new DoubleAnimation() { From = from.Y, To = to.Y, Duration = TimeSpan.FromMilliseconds(Utility.GAME_TICK_MS - 1) };

            Storyboard.SetTarget(anim1, _participant);
            Storyboard.SetTargetName(anim1, _participant.Name);
            Storyboard.SetTargetProperty(anim1, "(Canvas.Left)");

            Storyboard.SetTarget(anim2, _participant);
            Storyboard.SetTargetName(anim2, _participant.Name);
            Storyboard.SetTargetProperty(anim2, "(Canvas.Top)");

            Storyboard sb = new Storyboard();
            sb.Children.Add(anim1);
            sb.Children.Add(anim2);

            if (completed == null)
                sb.Completed += (object sender, object e) => { };
            else
                sb.Completed += completed;

            sb.Begin();
        }
Example #6
0
        private void InitializeControl()
        {
            try
            {

                if (root == null)
                {
                    root = (Canvas)GetTemplateChild("root");
                    layerStoryboard = (Storyboard)root.Resources["layerStoryboard"];

                    layerAnimationX = (DoubleAnimation)layerStoryboard.Children[0];
                    layerAnimationY = (DoubleAnimation)layerStoryboard.Children[1];

                    layerState = new LayerState(SensitivityX, SensitivityY);

                    Conductor.Beat += Conductor_Beat;

                    rootParent = (Canvas)this.Parent;
                    //rootParent.PointerPressed += rootParent_PointerPressed;
                    rootParent.ManipulationDelta += rootParent_ManipulationDelta;
                    rootParent.ManipulationMode = this.ManipulationMode; // &ManipulationModes.TranslateY;

                }


            }
            catch { }
        }
Example #7
0
        private void FadeIn()
        {
            if (_Running)
            {
                DoubleAnimation fadeIn = new DoubleAnimation();

                fadeIn.From = 0.0;
                fadeIn.To = 1;
                fadeIn.Duration = new Duration(TimeSpan.FromSeconds(2));
                fadeIn.BeginTime = TimeSpan.FromSeconds(2);

                Storyboard sb = new Storyboard();

                Storyboard.SetTarget(fadeIn, _Control);
                Storyboard.SetTargetProperty(fadeIn, "Opacity");

                sb.Children.Add(fadeIn);

                _Control.Resources.Clear();
                _Control.Resources.Add("FaderEffect", sb);

                sb.Completed += this.OnFadeInCompleted;

                sb.Begin();
            }
        }
        public static void Animate(this UIElement element, double from, double to, double fullDistance)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            var transform = new TranslateTransform();
            element.RenderTransform = transform;

            var xAnimation = new DoubleAnimation
            {
                From = from,
                Duration = TimeSpan.FromMilliseconds(GetAnimationSpeed(from, to, fullDistance)),
                To = to,
                EnableDependentAnimation = true,
                EasingFunction = new SineEase() { EasingMode = EasingMode.EaseOut }
            };

            Storyboard.SetTarget(xAnimation, transform);
            Storyboard.SetTargetProperty(xAnimation, "X");

            var storyboard = new Storyboard();
            storyboard.Children.Add(xAnimation);

            storyboard.Begin();
        }
        private void UIElement_OnPointerEntered(object sender, PointerRoutedEventArgs e)
        {
            var border = (Border)sender;

            // Somehow ZIndex doesn't work in the UniformGrid
            // Perhaps if Jupiter had a method called Panel.GetVisualChild available to override...
            // See: http://blog.pixelingene.com/2007/12/controlling-z-index-of-children-in-custom-controls/
            //Canvas.SetZIndex(border, ++_maxZIndex);
            var sb = new Storyboard();

            var a1 = new DoubleAnimation();
            a1.Duration = TimeSpan.FromSeconds(0.2);
            a1.To = 0.9;
            a1.EasingFunction = new PowerEase { Power = 2, EasingMode = EasingMode.EaseOut };
            Storyboard.SetTarget(a1, border.RenderTransform);
            Storyboard.SetTargetProperty(a1, "ScaleX");
            sb.Children.Add(a1);

            var a2 = new DoubleAnimation();
            a2.Duration = TimeSpan.FromSeconds(0.2);
            a2.To = 0.9;
            a2.EasingFunction = new PowerEase { Power = 2, EasingMode = EasingMode.EaseOut };
            Storyboard.SetTarget(a2, border.RenderTransform);
            Storyboard.SetTargetProperty(a2, "ScaleY");
            sb.Children.Add(a2);

            sb.Begin();
        }
Example #10
0
        static public void AnimateOpacity(FrameworkElement element, double start, double end, double duration)
        {
            element.Opacity = 0;

            Duration animationDuration = new Duration(TimeSpan.FromSeconds(duration));
            DoubleAnimation opacityAnimation = new DoubleAnimation();

            opacityAnimation.Duration = animationDuration;
            opacityAnimation.From = start;
            opacityAnimation.To = end;

            Storyboard sb = new Storyboard();
            sb.Duration = animationDuration;

            sb.Children.Add(opacityAnimation);

            Storyboard.SetTarget(opacityAnimation, element);

            // Set the X and Y properties of the Transform to be the target properties
            // of the two respective DoubleAnimations.
            Storyboard.SetTargetProperty(opacityAnimation, "Opacity");

            // Begin the animation.
            sb.Begin();
        }
Example #11
0
        //public LoginPageViewModel vm { get; private set; }
        public LoginPage()
        {
            this.InitializeComponent();
            DataContextChanged += LoginPage_DataContextChanged;
            _toRegSb = new Storyboard();
            Duration duration = new Duration(TimeSpan.FromSeconds(0.2));
            _logspda = new DoubleAnimation()
            {
                From = 0,
                To = -FrameWidth,
                AutoReverse = false,
                Duration = duration
            };
            _regspda = new DoubleAnimation()
            {
                From = FrameWidth,
                To = 0,
                AutoReverse = false,
                Duration = duration
            };
            Storyboard.SetTargetProperty(_regspda, "(UIElement.RenderTransform).(CompositeTransform.TranslateX)");
            Storyboard.SetTargetProperty(_logspda, "(UIElement.RenderTransform).(CompositeTransform.TranslateX)");
            Storyboard.SetTarget(_logspda, logSP);
            Storyboard.SetTarget(_regspda, regSP);

            _toRegSb.Children.Add(_regspda);
            _toRegSb.Children.Add(_logspda);

            Rect rect = new Rect(0, 0, FrameWidth, 300);
            RectangleGeometry reo = new RectangleGeometry();
            reo.Rect = rect;
            this.infoBorder.Clip = reo;
        }
Example #12
0
        private void Splarkle(Windows.UI.Input.PointerPoint point)
        {
            var x = point.Position.X;
            var y = point.Position.Y;
            var s = .5d;
            var dot = new Windows.UI.Xaml.Shapes.Ellipse
            {
                Height = 10,
                Width = 10,
                Opacity = 1,
                VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Top,
                HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Left,
                Fill = new SolidColorBrush(GetRandColor()),
                RenderTransform = new CompositeTransform
                {
                    TranslateX = x,
                    TranslateY = y,
                    ScaleX = s,
                    ScaleY = s,
                },
            };
            LayoutRoot.Children.Add(dot);

            var d = TimeSpan.FromMilliseconds(_Random.Next(300, 1200));

            x += _Random.Next(-100, 100);
            var atx = new DoubleAnimation { To = x, Duration = d };
            Storyboard.SetTarget(atx, dot.RenderTransform);
            Storyboard.SetTargetProperty(atx, "TranslateX");

            y += _Random.Next(-50, 100);
            var aty = new DoubleAnimation { To = y, Duration = d };
            Storyboard.SetTarget(aty, dot.RenderTransform);
            Storyboard.SetTargetProperty(aty, "TranslateY");

            s += _Random.Next(1, 2);
            var asx = new DoubleAnimation { To = s, Duration = d };
            Storyboard.SetTarget(asx, dot.RenderTransform);
            Storyboard.SetTargetProperty(asx, "ScaleX");

            var asy = new DoubleAnimation { To = s, Duration = d };
            Storyboard.SetTarget(asy, dot.RenderTransform);
            Storyboard.SetTargetProperty(asy, "ScaleY");

            var ao = new DoubleAnimation { To = 0, Duration = d };
            Storyboard.SetTarget(ao, dot);
            Storyboard.SetTargetProperty(ao, "Opacity");

            var story = new Storyboard();
            story.Completed += (sender, e) => LayoutRoot.Children.Remove(dot);
            story.Children.Add(atx);
            story.Children.Add(aty);
            story.Children.Add(asx);
            story.Children.Add(asy);
            story.Children.Add(ao);
            story.Begin();
        }
Example #13
0
 /// <summary>
 /// 创建动画
 /// </summary> 
 public static DoubleAnimation CreatAnimation(DependencyObject obj, string path, int duration, EasingFunctionBase easing = null)
 {
     DoubleAnimation da = new DoubleAnimation();
     da.EasingFunction = easing;
     da.Duration = TimeSpan.FromMilliseconds(duration);
     Storyboard.SetTarget(da, obj);
     Storyboard.SetTargetProperty(da, path);
     return da;
 }
 public static void BeginDoubleAnimation(this DependencyObject target, string path, double? to,
     Duration duration)
 {
     var animation = new DoubleAnimation
     {
         To = to,
         Duration = duration,
         EnableDependentAnimation = true
     };
     target.BeginAnimation(animation, path);
 }
 public static DoubleAnimation CreateDouble(double? to, Duration duration, string targetProperty)
 {
     var animation = new DoubleAnimation
     {
         To = to,
         Duration = duration,
         EnableDependentAnimation = true
     };
     Storyboard.SetTargetProperty(animation, targetProperty);
     return animation;
 }
Example #16
0
 public static DoubleAnimation CreateDoubleAnimation(UIElement uiElement, double from, double to,
     string propertyToAnimate)
 {
     DoubleAnimation animation = new DoubleAnimation();
     Storyboard.SetTarget(animation, uiElement);
     Storyboard.SetTargetProperty(animation, propertyToAnimate);
     animation.From = from;
     animation.To = to;
     animation.Duration = TimeSpan.FromSeconds(3);
     return animation;
 }
Example #17
0
 public static DoubleAnimation CreateDoubleAnimation(double? from, double? to, Duration duration, string targetProperty, DependencyObject target, EasingFunctionBase easing = null)
 {
     var db = new DoubleAnimation();
     db.To = to;
     db.From = from;
     db.EasingFunction = easing;
     db.Duration = duration;
     Storyboard.SetTarget(db, target);
     Storyboard.SetTargetProperty(db, targetProperty);
     return db;
 }
Example #18
0
        public static DoubleAnimation CreateDoubleAnimation(UIElement control, double from, double to,
            string property, TimeSpan duration)
        {
            DoubleAnimation animation = new DoubleAnimation();
            Storyboard.SetTarget(animation, control);
            Storyboard.SetTargetProperty(animation, property);
            animation.From = from;
            animation.To = to;
            animation.Duration = duration;

            return animation;
        }
Example #19
0
        public void Show()
        {
            //2s之内连续按2次,退出
            if (clickCount > 0)
            {
                if (Completed != null)
                {
                    Completed(true);
                }
            }
            else
            {
                clickCount++;

                if (Completed != null)
                {
                    Completed(false);
                }

                var tips = new JMessboxControl();
                tips.DataContext = this;
                popup.Height = 65;
                popup.Width = 200;
                popup.Margin = new Thickness(140, 380, 0, 0);
                popup.IsOpen = false;
                popup.Child = tips;

                //渐变效果:透明度200毫秒内从0->1
                Storyboard story = new Storyboard();
                DoubleAnimation topAnimation = new DoubleAnimation();
                topAnimation.From = 0;
                topAnimation.To = 1;
                topAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(200));
                Storyboard.SetTarget(topAnimation, tips);
                Storyboard.SetTargetProperty(topAnimation, "(UIElement.Opacity)");

                story.Children.Add(topAnimation);

                popup.IsOpen = true;
                story.Begin();
                //动画延迟2秒
                story.Duration = new Duration(new TimeSpan(0, 0, 2));
                //story.BeginTime = new TimeSpan(0, 0, 0, 0, 1);
                story.Completed += (s1, e1) =>
                {
                    //2s后执行此方法
                    clickCount = 0;
                    popup.IsOpen = false;
                    story.Stop();
                };
            }

        }
Example #20
0
 /// <summary>
 /// 创建动画
 /// </summary> 
 public static DoubleAnimation CreatAnimation(DependencyObject obj, Storyboard storyboard, string path, int duration, double? toValue, EasingFunctionBase easing, bool isEnableDependency)
 {
     DoubleAnimation da = new DoubleAnimation();
     da.EasingFunction = easing;
     da.Duration = TimeSpan.FromMilliseconds(duration);
     da.To = toValue;
     da.EnableDependentAnimation = isEnableDependency;
     Storyboard.SetTarget(da, obj);
     Storyboard.SetTargetProperty(da, path);
     storyboard.Children.Add(da);
     return da;
 }
Example #21
0
        public static Storyboard CreateDoubleSB(DependencyObject dpnObj, string property, double secondTime, Double to)
        {
            DoubleAnimation ca = new DoubleAnimation();
            ca.Duration = TimeSpan.FromSeconds(secondTime);
            ca.To = to;

            Storyboard.SetTarget(ca, dpnObj);
            Storyboard.SetTargetProperty(ca, property);
            Storyboard sb = new Storyboard();

            sb.Children.Add(ca);
            return sb;
        }
Example #22
0
        private async void SetBackground()
        {
            childList = new ZIndexList();

            PixelmapImage image = new PixelmapImage(1, 1);
            await image.SetSource(new Uri("ms-appx:///Assets/background.png"));

            ImageBrush brush = new ImageBrush();
            brush.ImageSource = await image.ToWriteableBitmapImage();
            //Grid someGrid = new Grid() { Width = 100, Height = 100, HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Left, Background = brush, Name = "someGrid" };
            //MainP.Children.Add(someGrid);

            image = await image.StretchToFit(210, 210);

            brush = new ImageBrush();
            brush.ImageSource = await image.ToWriteableBitmapImage();

            TPanel f = new TPanel() { Background = brush, HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Left, Height = 210, Margin = new Thickness(63, 291, 0, 0), VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Top, Width = 210 };
            f.Tapped += Button_Tapped;
            childList.Add(f);
            MainP.Children.Add(f);

            TransitionCollection tc = new TransitionCollection();
            tc.Add(new Windows.UI.Xaml.Media.Animation.AddDeleteThemeTransition());

            //someGrid.RenderTransform = new CompositeTransform();

            sb = new Storyboard();
            DoubleAnimation da = new DoubleAnimation();
            //Storyboard.SetTarget(da, someGrid);
            Storyboard.SetTargetProperty(da, "(UIElement.RenderTransform).(CompositeTransform.TranslateX)");
            da.From = 500;
            da.To = 1000;
                da.Duration = new Duration(new TimeSpan(0,0,0,0,100));
                //da.AutoReverse = true;
                da.Completed += (source, e) => { go = !go; (source as DoubleAnimation).To = go ? 500 : 1000; (source as DoubleAnimation).From = go ? 1000 : 500; if(go)sb.Begin();  };
            sb.Children.Add(da);

            for (int i = 0; i < 5; i++)
            {
                TPanel r = new TPanel() { Transitions = tc, Background = brush, HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Left, Height = 210, Margin = new Thickness((childList.Last() as TPanel).Margin.Left + elementDistance, 291, 0, 0), VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Top, Width = 210 };
                r.Tapped += Button_Tapped;
                RotatedText ro = new RotatedText();
                ro.text.Text = "Text " + i;
                ro.text.Loaded += (source, e) => { (source as TextBlock).Margin = new Thickness(0, (source as TextBlock).ActualWidth + 5, 0, 0); };
                r.Children.Add(ro);
                childList.Add(r);
                MainP.Children.Add(r);
            }
        }
Example #23
0
        public static void Animate(DependencyObject target, string property, double from, double to, int duration, EventHandler<object> completed)
        {
            var animation = new DoubleAnimation();
            animation.From = from;
            animation.To = to;
            animation.Duration = new TimeSpan(0, 0, 0, 0, duration);
            Storyboard.SetTarget(animation, target);
            Storyboard.SetTargetProperty(animation, property);

            var storyBoard = new Storyboard();
            storyBoard.Children.Add(animation);
            storyBoard.Completed += completed;
            storyBoard.Begin();
        }
Example #24
0
 private void AnimateEnemy(ContentControl enemy, double from, double to, string propertyToAnimate)
 {
     Storyboard storyboard = new Storyboard() { AutoReverse = true, RepeatBehavior = RepeatBehavior.Forever };
     DoubleAnimation animation = new DoubleAnimation()
     {
         From = from,
         To = to,
         Duration = new Duration(TimeSpan.FromSeconds(random.Next(4, 6)))
     };
     Storyboard.SetTarget(animation, enemy);
     Storyboard.SetTargetProperty(animation, propertyToAnimate);
     storyboard.Children.Add(animation);
     storyboard.Begin();
 }
Example #25
0
        public static DoubleAnimation CreateScaleXAnimation(ScaleTransform scale, double to, double seconds)
        {
            var scallingXAnimation = new DoubleAnimation
            {
                To = to,
                Duration = new Duration(TimeSpan.FromSeconds(seconds)),
                EasingFunction = new QuinticEase()

            };
            Storyboard.SetTarget(scallingXAnimation, scale);
            Storyboard.SetTargetProperty(scallingXAnimation, "ScaleX");

            return scallingXAnimation;
        }
Example #26
0
 void animateimage(double to, int index)
 {
     Windows.UI.Xaml.Media.Animation.Storyboard      story     = new Windows.UI.Xaml.Media.Animation.Storyboard();
     Windows.UI.Xaml.Media.Animation.DoubleAnimation animation = new Windows.UI.Xaml.Media.Animation.DoubleAnimation();
     animation.Duration = TimeSpan.FromMilliseconds(650);
     story.Children.Add(animation);
     Windows.UI.Xaml.Media.Animation.CubicEase ease1 = new Windows.UI.Xaml.Media.Animation.CubicEase();
     //ease1.EasingMode = Windows.UI.Xaml.Media.Animation.EasingMode.EaseIn ;
     animation.EnableDependentAnimation = true;
     animation.EasingFunction           = ease1;
     animation.To = to;
     Windows.UI.Xaml.Media.Animation.Storyboard.SetTargetProperty(animation, "Opacity");
     Windows.UI.Xaml.Media.Animation.Storyboard.SetTarget(animation, _imagelist[index]);
     story.Begin();
 }
Example #27
0
        /// <summary>
        /// Helper to create double animation</summary>
        /// 
        public static DoubleAnimation CreateDoubleAnimation(DependencyObject element, string property,
            double from, double to, double seconds)
        {
            DoubleAnimation da;

            da = new DoubleAnimation();
            da.To = to;
            da.From = from;

            da.Duration = new Duration(TimeSpan.FromSeconds(seconds));

            Storyboard.SetTargetProperty(da, property);
            Storyboard.SetTarget(da, element);
            return da;
        }
Example #28
0
 private DoubleAnimation CreateDoubleAnimation(double to, 
                                               Duration duration,
                                               DependencyObject target,
                                               string targetPath)
 {
     var animation = new DoubleAnimation
     {
         To = to,
         Duration = duration,
         EasingFunction = new CubicEase()
     };
     Storyboard.SetTarget(animation, target);
     Storyboard.SetTargetProperty(animation, targetPath);
     return animation;
 }
        public static void AddAnimation(this Storyboard storyboard, DependencyObject element,
                                        int duration, double toValue, String propertyPath,
                                        EasingFunctionBase easingFunction = null)
        {
            DoubleAnimation timeline = new DoubleAnimation();
            timeline.To = toValue;
            timeline.Duration = TimeSpan.FromMilliseconds(duration);
            if (easingFunction != null)
                timeline.EasingFunction = easingFunction;

            storyboard.Children.Add(timeline);

            Storyboard.SetTarget(timeline, element);
            Storyboard.SetTargetProperty(timeline, propertyPath);
        }
Example #30
0
 private static void SourceChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
 {
     FadingImage instance = (FadingImage)sender;
     instance.ImageA.Source = (ImageSource)args.OldValue;
     instance.ImageB.Source = (ImageSource)args.NewValue;
     DoubleAnimation doubleAnimation = new DoubleAnimation();
     doubleAnimation.From = 0;
     doubleAnimation.To = 1;
     doubleAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(instance.TransitionMilliseconds));
     Storyboard sb = new Storyboard();
     Storyboard.SetTarget(doubleAnimation, instance.ImageB);
     Storyboard.SetTargetProperty(doubleAnimation, "Opacity");
     sb.Children.Add(doubleAnimation);
     sb.Begin();
 }
        private static void AnimateOpacity(DependencyObject target, double from, double to)
        {
            var opacityAnimation = new DoubleAnimation
            {
                From = from,
                To = to,
                Duration = TimeSpan.FromMilliseconds(500)
            };

            Storyboard.SetTarget(opacityAnimation, target);
            Storyboard.SetTargetProperty(opacityAnimation, "Opacity");

            var storyboard = new Storyboard();
            storyboard.Children.Add(opacityAnimation);
            storyboard.Begin();
        }