Inheritance: Windows.UI.Xaml.DependencyObject, ITimeline
Example #1
0
 public EventToken(Timeline animation, Storyboard storyboard)
 {
     _Children = new Dictionary<IAnimator, TimeSpan?>();
     _Animation = animation;
     _Animation.Completed += AnimationEventHandler;
     TokenStoryboard = storyboard;
 }
 public static void BeginAnimation(this DependencyObject target, Timeline animation, string path)
 {
     var sb = new Storyboard();
     Storyboard.SetTarget(animation, target);
     Storyboard.SetTargetProperty(animation, path);
     sb.Children.Add(animation);
     sb.Begin();
 }
 private static void BeginAnimation(DependencyObject obj, string property, Timeline animation)
 {
     Storyboard.SetTargetProperty(animation, property);
     Storyboard.SetTarget(animation, obj);
     var storyboard = new Storyboard();
     storyboard.Children.Add(animation);
     storyboard.Begin();
 }
        protected override void ApplyAnimationParams(Timeline animation)
        {
            DoubleAnimation doubleAnim = animation as DoubleAnimation;

            // Apply Ease
            doubleAnim.EasingFunction = _ease;

            // Apply To
            doubleAnim.To = _to;

            // Apply From
            if (_fromDefined)
            {
                doubleAnim.From = _from;
            }
        }
 public static void AddAnimation(this Storyboard storyboard, DependencyObject element, Timeline timeline, String propertyPath)
 {
     storyboard.Children.Add(timeline);
     Storyboard.SetTarget(timeline, element);
     Storyboard.SetTargetProperty(timeline, propertyPath);
 }
 public TimelineEvents(Timeline This)
 {
     this.This = This;
 }
Example #7
0
 public static void SetTarget(Timeline timeline, DependencyObject target) => timeline.Target = target;
Example #8
0
 /// <summary>
 /// Explicitly sets the target using an ElementNameSubject, in case of lazy
 /// evaluation of the target element.
 /// </summary>
 public static void SetTarget(Timeline timeline, ElementNameSubject target) => timeline.SetElementNameTarget(target);
 // Subclass must apply required settings
 protected abstract void ApplyAnimationParams(Timeline animation);
Example #10
0
 public AnimationImplementation(Timeline owner)
 {
     this._owner = owner;
 }
Example #11
0
 public void AddAnimtation(Timeline animation)
 {
     _storyboard.Children.Add(animation);
 }
Example #12
0
        /// <summary>
        /// Creates the actual animator instance
        /// </summary>
        private static IValueAnimator CreateColor(Timeline timeline, ColorOffset startingValue, ColorOffset targetValue)
        {
            // TODO: GPU-bound color animations - https://github.com/unoplatform/uno/issues/2947

            return(new NativeValueAnimatorAdapter(ValueAnimator.OfArgb((Android.Graphics.Color)(Color) startingValue, (Android.Graphics.Color)(Color) targetValue)));
        }
 private static object GetTimelineTarget(Control control, FrameworkElement templateRoot, Timeline timeline)
 {
     string targetName = Storyboard.GetTargetName(timeline);
     if (string.IsNullOrEmpty(targetName))
     {
         return null;
     }
     if (control is UserControl)
     {
         return control.FindName(targetName);
     }
     return templateRoot.FindName(targetName);
 }
Example #14
0
 /// <summary>
 /// Helper for the UpdateDropIndicatorAnimationHeight method.
 /// </summary>
 private void UpdateDropIndicatorAnimationHeight(double height, Timeline animation)
 {
     DoubleAnimation da = animation as DoubleAnimation;
     if (da != null)
     {
         string targetName = Storyboard.GetTargetName(da);
         PropertyPath targetPath = new PropertyPath(Storyboard.GetTargetProperty(da));
         if ((targetName == ReorderListBoxItem.DropBeforeSpacePart ||
              targetName == ReorderListBoxItem.DropAfterSpacePart) &&
             targetPath != null && targetPath.Path == "Height")
         {
             if (da.From > 0 && da.From != height)
             {
                 da.From = height;
             }
             if (da.To > 0 && da.To != height)
             {
                 da.To = height;
             }
         }
     }
 }
Example #15
0
 public static string GetTargetProperty(Timeline timeline)
 {
     return((string)timeline.GetValue(TargetPropertyProperty));
 }
Example #16
0
 public static void SetTargetName(Timeline timeline, string value)
 {
     timeline.SetValue(TargetNameProperty, value);
 }
Example #17
0
        private static IValueAnimator CreateColor(Timeline timeline, ColorOffset startingValue, ColorOffset targetValue)
        {
            // TODO: GPU-bound color animations - https://github.com/unoplatform/uno/issues/2947

            return(new ColorValueAnimator(startingValue, targetValue));
        }
 private static DependencyProperty LayoutPropertyFromTimeline(Timeline timeline, bool forceRuntimeProperty)
 {
     DependencyProperty property;
     string targetProperty = Storyboard.GetTargetProperty(timeline);
     DependencyProperty runtimeVisibilityProperty = GetRuntimeVisibilityProperty(timeline);
     if (runtimeVisibilityProperty != null)
     {
         if (RuntimeVisibility == null)
         {
             LayoutProperties.Add(runtimeVisibilityProperty);
             RuntimeVisibility = runtimeVisibilityProperty;
         }
         if (forceRuntimeProperty)
         {
             return runtimeVisibilityProperty;
         }
         return UIElement.VisibilityProperty;
     }
     if (((targetProperty != null) && PathToPropertyMap.TryGetValue(targetProperty, out property)) && LayoutProperties.Contains(property))
     {
         return property;
     }
     return null;
 }
Example #19
0
 public static void StoryboardBindTargetAndProperty(Timeline timeline, DependencyObject target, string path)
 {
     Storyboard.SetTarget(timeline, target);
     Storyboard.SetTargetProperty(timeline, path);
 }
Example #20
0
        protected override void ApplyAnimationParams(Timeline animation)
        {
            DoubleAnimation doubleAnim = animation as DoubleAnimation;

            // Apply To
            doubleAnim.To = 0.0;

            // Apply From
            if (_fromDefined)
            {
                doubleAnim.From = 1.0;
            }
        }
Example #21
0
        private static IValueAnimator GetGPUAnimator(this Timeline timeline, double startingValue, double targetValue)
        {
            // Overview    : http://developer.android.com/guide/topics/graphics/prop-animation.html#property-vs-view
            // Performance : http://developer.android.com/guide/topics/graphics/hardware-accel.html#layers-anims
            // Properties  : http://developer.android.com/guide/topics/graphics/prop-animation.html#views

            var info     = timeline.PropertyInfo.GetPathItems().Last();
            var target   = info.DataContext;
            var property = info.PropertyName.Split(new[] { '.' }).Last().Replace("(", "").Replace(")", "");

            if (target is View view)
            {
                switch (property)
                {
                case nameof(FrameworkElement.Opacity):
                    return(new NativeValueAnimatorAdapter(GetRelativeAnimator(view, "alpha", startingValue, targetValue)));
                }
            }

            if (target is TranslateTransform translate)
            {
                switch (property)
                {
                case nameof(TranslateTransform.X):
                    return(new NativeValueAnimatorAdapter(GetPixelsAnimator(translate.View, "translationX", startingValue, targetValue), PrepareTranslateX(translate, startingValue), Complete(translate)));

                case nameof(TranslateTransform.Y):
                    return(new NativeValueAnimatorAdapter(GetPixelsAnimator(translate.View, "translationY", startingValue, targetValue), PrepareTranslateY(translate, startingValue), Complete(translate)));
                }
            }

            if (target is RotateTransform rotate)
            {
                switch (property)
                {
                case nameof(RotateTransform.Angle):
                    return(new NativeValueAnimatorAdapter(GetRelativeAnimator(rotate.View, "rotation", startingValue, targetValue), PrepareAngle(rotate, startingValue), Complete(rotate)));
                }
            }

            if (target is ScaleTransform scale)
            {
                switch (property)
                {
                case nameof(ScaleTransform.ScaleX):
                    return(new NativeValueAnimatorAdapter(GetRelativeAnimator(scale.View, "scaleX", startingValue, targetValue), PrepareScaleX(scale, startingValue), Complete(scale)));

                case nameof(ScaleTransform.ScaleY):
                    return(new NativeValueAnimatorAdapter(GetRelativeAnimator(scale.View, "scaleY", startingValue, targetValue), PrepareScaleY(scale, startingValue), Complete(scale)));
                }
            }

            //if (target is SkewTransform skew)
            //{
            //	switch (property)
            //	{
            //		case nameof(SkewTransform.AngleX):
            //			return ObjectAnimator.OfFloat(skew.View, "scaleX", ViewHelper.LogicalToPhysicalPixels(targetValue), startingValue);

            //		case nameof(SkewTransform.AngleY):
            //			return ObjectAnimator.OfFloat(skew.View, "scaleY", ViewHelper.LogicalToPhysicalPixels(targetValue), startingValue);
            //	}
            //}

            if (target is CompositeTransform composite)
            {
                switch (property)
                {
                case nameof(CompositeTransform.TranslateX):
                    return(new NativeValueAnimatorAdapter(GetPixelsAnimator(composite.View, "translationX", startingValue, targetValue), PrepareTranslateX(composite, startingValue), Complete(composite)));

                case nameof(CompositeTransform.TranslateY):
                    return(new NativeValueAnimatorAdapter(GetPixelsAnimator(composite.View, "translationY", startingValue, targetValue), PrepareTranslateY(composite, startingValue), Complete(composite)));

                case nameof(CompositeTransform.Rotation):
                    return(new NativeValueAnimatorAdapter(GetRelativeAnimator(composite.View, "rotation", startingValue, targetValue), PrepareAngle(composite, startingValue), Complete(composite)));

                case nameof(CompositeTransform.ScaleX):
                    return(new NativeValueAnimatorAdapter(GetRelativeAnimator(composite.View, "scaleX", startingValue, targetValue), PrepareScaleX(composite, startingValue), Complete(composite)));

                case nameof(CompositeTransform.ScaleY):
                    return(new NativeValueAnimatorAdapter(GetRelativeAnimator(composite.View, "scaleY", startingValue, targetValue), PrepareScaleY(composite, startingValue), Complete(composite)));

                    //case nameof(CompositeTransform.SkewX):
                    //	return ObjectAnimator.OfFloat(composite.View, "scaleX", ViewHelper.LogicalToPhysicalPixels(targetValue), startingValue);

                    //case nameof(CompositeTransform.SkewY):
                    //	return ObjectAnimator.OfFloat(composite.View, "scaleY", ViewHelper.LogicalToPhysicalPixels(targetValue), startingValue);
                }
            }

            Application.Current.RaiseRecoverableUnhandledException(new NotSupportedException($"GPU bound animation of {property} is not supported on {target}. Use a discrete animation instead."));
            return(new NativeValueAnimatorAdapter(ValueAnimator.OfFloat((float)startingValue, (float)targetValue)));
        }
Example #22
0
 public static string GetTargetProperty(Timeline timeline) => (string)timeline.GetValue(TargetPropertyProperty);
Example #23
0
 public static void SetTargetProperty(Timeline timeline, string value) => timeline.SetValue(TargetPropertyProperty, value);
Example #24
0
        protected void CreateStoryboard()
        {
            _animation = CreateAnimation();
            _storyboard = new Storyboard();
            ApplyAnimationParams(_animation);

            // Apply Duration
            _animation.Duration = _duration;

            _storyboard.Children.Add(_animation);
        }
Example #25
0
 /// <summary>
 /// Creates the actual animator instance
 /// </summary>
 internal static IValueAnimator Create(Timeline timeline, double startingValue, double targetValue)
 {
     return(new RenderingLoopFloatAnimator((float)startingValue, (float)targetValue));
 }