Beispiel #1
0
        private void PreparePlay()
        {
            for (int i = 0; i < _elements.Count; ++i)
            {
                EffectElementBase element = _elements[i];

                // Check if we have a start value that needs setting.
                if (element.elementType == ElementType.AnimateBetween)
                {
                    View target = _rootView.FindChildByName(element.target);
                    if (target == null)
                    {
                        Console.WriteLine("Effect: Error: Could not find target: " + element.target);
                    }
                    else
                    {
                        int propertyIndex = target.GetPropertyIndex(element.property);
                        if (propertyIndex == -1)
                        {
                            Console.WriteLine("Effect: Error: Could not find property: " + element.property + " in target " + element.target);
                        }
                        else
                        {
                            PropertyValue propertyValue = PropertyValue.CreateFromObject((element as AnimateBetween).startValue);
                            target.SetProperty(propertyIndex, propertyValue);
                        }
                    }
                }
            }
        }
Beispiel #2
0
 internal static PropertyMap Add <T>(this PropertyMap propertyMap, int key, T value)
 {
     using (var pv = PropertyValue.CreateFromObject(value))
     {
         propertyMap.Add(key, pv);
     }
     return(propertyMap);
 }
        /// <summary>
        /// Creates an animation to animate the mixColor of the named visual.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        public Animation AnimateColor(string targetVisual, object destinationColor, int startTime, int endTime, AlphaFunction.BuiltinFunctions?alphaFunction = null, object initialColor = null)
        {
            Animation animation = null;

            using (PropertyMap animator = new PropertyMap())
                using (PropertyMap timePeriod = new PropertyMap())
                    using (PropertyValue pvDuration = new PropertyValue((endTime - startTime) / 1000.0f))
                        using (PropertyValue pvDelay = new PropertyValue(startTime / 1000.0f))
                            using (PropertyMap transition = new PropertyMap())
                                using (PropertyValue pvTarget = new PropertyValue(targetVisual))
                                    using (PropertyValue pvProperty = new PropertyValue("mixColor"))
                                        using (PropertyValue destValue = PropertyValue.CreateFromObject(destinationColor))
                                        {
                                            if (alphaFunction != null)
                                            {
                                                using (PropertyValue pvAlpha = new PropertyValue(AlphaFunction.BuiltinToPropertyKey(alphaFunction)))
                                                {
                                                    animator.Add("alphaFunction", pvAlpha);
                                                }
                                            }

                                            timePeriod.Add("duration", pvDuration);
                                            timePeriod.Add("delay", pvDelay);
                                            using (PropertyValue pvTimePeriod = new PropertyValue(timePeriod))
                                            {
                                                animator.Add("timePeriod", pvTimePeriod);
                                            }
                                            using (PropertyValue pvAnimator = new PropertyValue(animator))
                                            {
                                                transition.Add("animator", pvAnimator);
                                            }
                                            transition.Add("target", pvTarget);
                                            transition.Add("property", pvProperty);

                                            if (initialColor != null)
                                            {
                                                using (PropertyValue initValue = PropertyValue.CreateFromObject(initialColor))
                                                {
                                                    transition.Add("initialValue", initValue);
                                                }
                                            }

                                            transition.Add("targetValue", destValue);
                                            using (TransitionData transitionData = new TransitionData(transition))
                                            {
                                                animation = new Animation(Interop.View.CreateTransition(SwigCPtr, TransitionData.getCPtr(transitionData)), true);
                                            }
                                            if (NDalicPINVOKE.SWIGPendingException.Pending)
                                            {
                                                throw NDalicPINVOKE.SWIGPendingException.Retrieve();
                                            }
                                        }
            return(animation);
        }
Beispiel #4
0
        public void PropertyValueCreateFromObject()
        {
            tlog.Debug(tag, $"PropertyValueCreateFromObject START");

            Position pos           = new Position(10.0f, 20.0f, 30.0f);
            var      testingTarget = PropertyValue.CreateFromObject(pos);

            Assert.IsNotNull(testingTarget, "Should be not null!");
            Assert.IsInstanceOf <PropertyValue>(testingTarget, "Should be an Instance of PropertyValue!");

            testingTarget.Dispose();
            tlog.Debug(tag, $"PropertyValueCreateFromObject END (OK)");
        }
Beispiel #5
0
        /// <summary>
        /// Creates a visual animation (transition) with the input parameters.
        /// </summary>
        /// <param name="target">The visual map to animation.</param>
        /// <param name="property">The property of visual to animation.</param>
        /// <param name="destinationValue">The destination value of property after animation.</param>
        /// <param name="startTime">The start time of visual animation.</param>
        /// <param name="endTime">The end time of visual animation.</param>
        /// <param name="alphaFunction">The alpha function of visual animation.</param>
        /// <param name="initialValue">The initial property value of visual animation.</param>
        /// <returns>Animation instance</returns>
        /// <exception cref="ArgumentNullException"> Thrown when target is null. </exception>
        /// <since_tizen> 3 </since_tizen>
        public Animation AnimateVisual(VisualMap target, string property, object destinationValue, int startTime, int endTime, AlphaFunction.BuiltinFunctions?alphaFunction = null, object initialValue = null)
        {
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }

            string _alphaFunction = alphaFunction?.GetDescription();

            foreach (var item in _visualDictionary.ToList())
            {
                if (item.Value.Name == target.Name)
                {
                    PropertyMap _animator = new PropertyMap();
                    if (_alphaFunction != null)
                    {
                        _animator.Add("alphaFunction", new PropertyValue(_alphaFunction));
                    }

                    PropertyMap _timePeriod = new PropertyMap();
                    _timePeriod.Add("duration", new PropertyValue((endTime - startTime) / 1000.0f));
                    _timePeriod.Add("delay", new PropertyValue(startTime / 1000.0f));
                    _animator.Add("timePeriod", new PropertyValue(_timePeriod));

                    StringBuilder sb = new StringBuilder(property);
                    sb[0] = (char)(sb[0] | 0x20);
                    string _str = sb.ToString();
                    if (_str == "position")
                    {
                        _str = "offset";
                    }

                    PropertyValue destVal = PropertyValue.CreateFromObject(destinationValue);

                    PropertyMap _transition = new PropertyMap();
                    _transition.Add("target", new PropertyValue(target.Name));
                    _transition.Add("property", new PropertyValue(_str));
                    if (initialValue != null)
                    {
                        PropertyValue initVal = PropertyValue.CreateFromObject(initialValue);
                        _transition.Add("initialValue", new PropertyValue(initVal));
                    }
                    _transition.Add("targetValue", destVal);
                    _transition.Add("animator", new PropertyValue(_animator));

                    TransitionData _transitionData = new TransitionData(_transition);
                    return(this.CreateTransition(_transitionData));
                }
            }
            return(null);
        }
Beispiel #6
0
        /// <summary>
        /// Creates an animation to animate the mixColor of the named visual.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        public Animation AnimateColor(string targetVisual, object destinationColor, int startTime, int endTime, AlphaFunction.BuiltinFunctions?alphaFunction = null, object initialColor = null)
        {
            Animation animation = null;

            {
                PropertyMap _animator = new PropertyMap();
                if (alphaFunction != null)
                {
                    _animator.Add("alphaFunction", new PropertyValue(AlphaFunction.BuiltinToPropertyKey(alphaFunction)));
                }

                PropertyMap _timePeriod = new PropertyMap();
                _timePeriod.Add("duration", new PropertyValue((endTime - startTime) / 1000.0f));
                _timePeriod.Add("delay", new PropertyValue(startTime / 1000.0f));
                _animator.Add("timePeriod", new PropertyValue(_timePeriod));

                PropertyMap _transition = new PropertyMap();
                _transition.Add("animator", new PropertyValue(_animator));
                _transition.Add("target", new PropertyValue(targetVisual));
                _transition.Add("property", new PropertyValue("mixColor"));

                if (initialColor != null)
                {
                    PropertyValue initValue = PropertyValue.CreateFromObject(initialColor);
                    _transition.Add("initialValue", initValue);
                }

                PropertyValue destValue = PropertyValue.CreateFromObject(destinationColor);
                _transition.Add("targetValue", destValue);
                TransitionData _transitionData = new TransitionData(_transition);

                animation = new Animation(Interop.View.View_CreateTransition(swigCPtr, TransitionData.getCPtr(_transitionData)), true);
                if (NDalicPINVOKE.SWIGPendingException.Pending)
                {
                    throw NDalicPINVOKE.SWIGPendingException.Retrieve();
                }
            }
            return(animation);
        }
Beispiel #7
0
        /// <summary>
        /// Adds a group visual animation (transition) map with the input parameters.
        /// </summary>
        /// <param name="target">The visual map to animation.</param>
        /// <param name="property">The property of visual to animation.</param>
        /// <param name="destinationValue">The destination value of property after animation.</param>
        /// <param name="startTime">The start time of visual animation.</param>
        /// <param name="endTime">The end time of visual animation.</param>
        /// <param name="alphaFunction">The alpha function of visual animation.</param>
        /// <param name="initialValue">The initial property value of visual animation.</param>
        /// <exception cref="ArgumentNullException"> Thrown when target is null. </exception>
        /// <since_tizen> 3 </since_tizen>
        public void AnimateVisualAdd(VisualMap target, string property, object destinationValue, int startTime, int endTime, AlphaFunction.BuiltinFunctions?alphaFunction = null, object initialValue = null)
        {
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }

            string strAlpha = alphaFunction?.GetDescription();

            foreach (var item in visualDictionary.ToList())
            {
                if (item.Value.Name == target.Name)
                {
                    using (PropertyMap animator = new PropertyMap())
                        using (PropertyMap timePeriod = new PropertyMap())
                            using (PropertyValue pvDuration = new PropertyValue((endTime - startTime) / 1000.0f))
                                using (PropertyValue pvDelay = new PropertyValue(startTime / 1000.0f))
                                    using (PropertyValue destVal = PropertyValue.CreateFromObject(destinationValue))
                                        using (PropertyMap transition = new PropertyMap())
                                            using (PropertyValue pvTarget = new PropertyValue(target.Name))
                                            {
                                                if (strAlpha != null)
                                                {
                                                    using (PropertyValue pvStrAlpha = new PropertyValue(strAlpha))
                                                    {
                                                        animator.Add("alphaFunction", pvStrAlpha);
                                                    }
                                                }

                                                timePeriod.Add("duration", pvDuration);
                                                timePeriod.Add("delay", pvDelay);
                                                using (PropertyValue pvTimePeriod = new PropertyValue(timePeriod))
                                                {
                                                    animator.Add("timePeriod", pvTimePeriod);
                                                }

                                                StringBuilder sb = new StringBuilder(property);
                                                sb[0] = (char)(sb[0] | 0x20);
                                                string _str = sb.ToString();
                                                if (_str == "position")
                                                {
                                                    _str = "offset";
                                                }

                                                transition.Add("target", pvTarget);
                                                using (PropertyValue pvStr = new PropertyValue(_str))
                                                {
                                                    transition.Add("property", pvStr);
                                                }

                                                if (initialValue != null)
                                                {
                                                    using (PropertyValue initVal = PropertyValue.CreateFromObject(initialValue))
                                                        using (PropertyValue pvInitialValue = new PropertyValue(initVal))
                                                        {
                                                            transition.Add("initialValue", pvInitialValue);
                                                        }
                                                }
                                                transition.Add("targetValue", destVal);
                                                using (PropertyValue pvAnimator = new PropertyValue(animator))
                                                {
                                                    transition.Add("animator", pvAnimator);
                                                }

                                                using (PropertyValue pvTransition = new PropertyValue(transition))
                                                {
                                                    PropertyArray temp = animateArray.Add(pvTransition);
                                                    temp.Dispose();
                                                }
                                            }
                }
            }
        }
Beispiel #8
0
        /// <summary>
        /// Adds a group visual animation (transition) map with the input parameters.
        /// </summary>
        /// <param name="target">The visual map to animation.</param>
        /// <param name="property">The property of visual to animation.</param>
        /// <param name="destinationValue">The destination value of property after animation.</param>
        /// <param name="startTime">The start time of visual animation.</param>
        /// <param name="endTime">The end time of visual animation.</param>
        /// <param name="alphaFunction">The alpha function of visual animation.</param>
        /// <param name="initialValue">The initial property value of visual animation.</param>
        /// <since_tizen> 3 </since_tizen>
        public void AnimateVisualAdd(VisualMap target, string property, object destinationValue, int startTime, int endTime, AlphaFunction.BuiltinFunctions?alphaFunction = null, object initialValue = null)
        {
            string _alphaFunction = null;

            if (alphaFunction != null)
            {
                switch (alphaFunction)
                {
                case Tizen.NUI.AlphaFunction.BuiltinFunctions.Linear:
                {
                    _alphaFunction = "LINEAR";
                    break;
                }

                case Tizen.NUI.AlphaFunction.BuiltinFunctions.Reverse:
                {
                    _alphaFunction = "REVERSE";
                    break;
                }

                case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseInSquare:
                {
                    _alphaFunction = "EASE_IN_SQUARE";
                    break;
                }

                case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseOutSquare:
                {
                    _alphaFunction = "EASE_OUT_SQUARE";
                    break;
                }

                case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseIn:
                {
                    _alphaFunction = "EASE_IN";
                    break;
                }

                case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseOut:
                {
                    _alphaFunction = "EASE_OUT";
                    break;
                }

                case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseInOut:
                {
                    _alphaFunction = "EASE_IN_OUT";
                    break;
                }

                case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseInSine:
                {
                    _alphaFunction = "EASE_IN_SINE";
                    break;
                }

                case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseOutSine:
                {
                    _alphaFunction = "EASE_OUT_SINE";
                    break;
                }

                case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseInOutSine:
                {
                    _alphaFunction = "EASE_IN_OUT_SINE";
                    break;
                }

                case Tizen.NUI.AlphaFunction.BuiltinFunctions.Bounce:
                {
                    _alphaFunction = "BOUNCE";
                    break;
                }

                case Tizen.NUI.AlphaFunction.BuiltinFunctions.Sin:
                {
                    _alphaFunction = "SIN";
                    break;
                }

                case Tizen.NUI.AlphaFunction.BuiltinFunctions.EaseOutBack:
                {
                    _alphaFunction = "EASE_OUT_BACK";
                    break;
                }

                default:
                {
                    _alphaFunction = "DEFAULT";
                    break;
                }
                }
            }

            foreach (var item in _visualDictionary.ToList())
            {
                if (item.Value.Name == target.Name)
                {
                    PropertyMap _animator = new PropertyMap();
                    if (_alphaFunction != null)
                    {
                        _animator.Add("alphaFunction", new PropertyValue(_alphaFunction));
                    }

                    PropertyMap _timePeriod = new PropertyMap();
                    _timePeriod.Add("duration", new PropertyValue((endTime - startTime) / 1000.0f));
                    _timePeriod.Add("delay", new PropertyValue(startTime / 1000.0f));
                    _animator.Add("timePeriod", new PropertyValue(_timePeriod));

                    StringBuilder sb = new StringBuilder(property);
                    sb[0] = (char)(sb[0] | 0x20);
                    string _str = sb.ToString();
                    if (_str == "position")
                    {
                        _str = "offset";
                    }

                    PropertyValue destVal = PropertyValue.CreateFromObject(destinationValue);

                    PropertyMap _transition = new PropertyMap();
                    _transition.Add("target", new PropertyValue(target.Name));
                    _transition.Add("property", new PropertyValue(_str));
                    if (initialValue != null)
                    {
                        PropertyValue initVal = PropertyValue.CreateFromObject(initialValue);
                        _transition.Add("initialValue", new PropertyValue(initVal));
                    }
                    _transition.Add("targetValue", destVal);
                    _transition.Add("animator", new PropertyValue(_animator));

                    _animateArray.Add(new PropertyValue(_transition));
                }
            }
        }