Revert "[NUI] Remove APIs which have been deprecated in API7"
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Animation / Animation.cs
1 /*
2  * Copyright(c) 2021 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 namespace Tizen.NUI
19 {
20     using System;
21     using System.ComponentModel;
22     using System.Runtime.InteropServices;
23     using Tizen.NUI.BaseComponents;
24
25     using System.Collections;
26     using System.Collections.Generic;
27     using System.Linq;
28     using System.Reflection;
29     using System.Xml;
30     using Tizen.NUI.Binding.Internals;
31     using Tizen.NUI.Binding;
32     using System.Globalization;
33     using Tizen.NUI.Xaml.Internals;
34     using System.Diagnostics.CodeAnalysis;
35
36     /// <summary>
37     /// Animation can be used to animate the properties of any number of objects, typically view.<br />
38     /// If the "Finished" event is connected to a member function of an object, it must be disconnected before the object is destroyed.<br />
39     /// This is typically done in the object destructor, and requires either the animation handle to be stored.<br />
40     /// The overall animation time is superseded by the values given in the animation time used when calling the AnimateTo(), AnimateBy(), AnimateBetween() and AnimatePath() methods.<br />
41     /// If any of the individual calls to those functions exceeds the overall animation time (Duration), then the overall animation time is automatically extended.<br />
42     /// </summary>
43     /// <since_tizen> 3 </since_tizen>
44     public class Animation : BaseHandle
45     {
46         private static bool? disableAnimation = null;
47
48
49         private AnimationFinishedEventCallbackType _animationFinishedEventCallback;
50         private System.IntPtr _finishedCallbackOfNative;
51
52         private AnimationProgressReachedEventCallbackType _animationProgressReachedEventCallback;
53
54         private string[] _properties = null;
55         private string[] _destValue = null;
56         private int[] _startTime = null;
57         private int[] _endTime = null;
58
59         private List<string> propertyList = null;
60         private List<string> destValueList = null;
61         private List<int> startTimeList = null;
62         private List<int> endTimeList = null;
63
64         /// <summary>
65         /// Creates an initialized animation.<br />
66         /// The animation will not loop.<br />
67         /// The default end action is "Cancel".<br />
68         /// The default alpha function is linear.<br />
69         /// </summary>
70         /// <remarks>DurationmSeconds must be greater than zero.</remarks>
71         /// <param name="durationMilliSeconds">The duration in milliseconds.</param>
72         /// <since_tizen> 3 </since_tizen>
73         public Animation(int durationMilliSeconds) : this(Interop.Animation.New((float)durationMilliSeconds / 1000.0f), true)
74         {
75             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
76         }
77
78         internal Animation(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
79         {
80
81             _animationFinishedEventCallback = OnFinished;
82             _finishedCallbackOfNative = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(_animationFinishedEventCallback);
83         }
84
85         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
86         private delegate void AnimationFinishedEventCallbackType(IntPtr data);
87
88         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
89         private delegate void AnimationProgressReachedEventCallbackType(IntPtr data);
90
91         private event EventHandler _animationFinishedEventHandler;
92
93         /**
94         * @brief Event for the finished signal which can be used to subscribe or unsubscribe the event handler.
95         * The finished signal is emitted when an animation's animations have finished.
96         */
97         /// <since_tizen> 3 </since_tizen>
98         public event EventHandler Finished
99         {
100             add
101             {
102                 if (_animationFinishedEventHandler == null && disposed == false)
103                 {
104                     AnimationSignal finishedSignal = FinishedSignal();
105                     finishedSignal.Connect(_finishedCallbackOfNative);
106                     finishedSignal.Dispose();
107                 }
108                 _animationFinishedEventHandler += value;
109             }
110             remove
111             {
112                 _animationFinishedEventHandler -= value;
113
114                 AnimationSignal finishedSignal = FinishedSignal();
115                 if (_animationFinishedEventHandler == null && finishedSignal.Empty() == false)
116                 {
117                     finishedSignal.Disconnect(_finishedCallbackOfNative);
118                 }
119                 finishedSignal.Dispose();
120             }
121         }
122
123         private event EventHandler _animationProgressReachedEventHandler;
124
125         /**
126        * @brief Event for the ProgressReached signal, which can be used to subscribe or unsubscribe the event handler.
127        * The ProgressReached signal is emitted when the animation has reached a given progress percentage, this is set in the api SetProgressNotification.
128        */
129         /// <since_tizen> 3 </since_tizen>
130         public event EventHandler ProgressReached
131         {
132             add
133             {
134                 if (_animationProgressReachedEventHandler == null)
135                 {
136                     _animationProgressReachedEventCallback = OnProgressReached;
137                     AnimationSignal progressReachedSignal = ProgressReachedSignal();
138                     progressReachedSignal?.Connect(_animationProgressReachedEventCallback);
139                     progressReachedSignal?.Dispose();
140                 }
141
142                 _animationProgressReachedEventHandler += value;
143             }
144             remove
145             {
146                 _animationProgressReachedEventHandler -= value;
147
148                 AnimationSignal progressReachedSignal = ProgressReachedSignal();
149                 if (_animationProgressReachedEventHandler == null && progressReachedSignal?.Empty() == false)
150                 {
151                     progressReachedSignal?.Disconnect(_animationProgressReachedEventCallback);
152                 }
153                 progressReachedSignal.Dispose();
154             }
155         }
156
157         /// <summary>
158         /// Enumeration for what to do when the animation ends, stopped, or destroyed.
159         /// </summary>
160         /// <since_tizen> 3 </since_tizen>
161         [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1717:Only FlagsAttribute enums should have plural names")]
162         public enum EndActions
163         {
164             /// <summary>
165             /// When the animation ends, the animated property values are saved.
166             /// </summary>
167             Cancel,
168             /// <summary>
169             /// When the animation ends, the animated property values are forgotten.
170             /// </summary>
171             Discard,
172             /// <summary>
173             /// If the animation is stopped, the animated property values are saved as if the animation had run to completion, otherwise behaves like cancel.
174             /// </summary>
175             StopFinal
176         }
177
178         /// <summary>
179         /// Enumeration for what interpolation method to use on key-frame animations.
180         /// </summary>
181         /// <since_tizen> 3 </since_tizen>
182         public enum Interpolation
183         {
184             /// <summary>
185             /// Values in between key frames are interpolated using a linear polynomial. (Default)
186             /// </summary>
187             Linear,
188             /// <summary>
189             /// Values in between key frames are interpolated using a cubic polynomial.
190             /// </summary>
191             Cubic
192         }
193
194         /// <summary>
195         /// Enumeration for what state the animation is in.
196         /// </summary>
197         /// <remarks>Calling Reset() on this class will not reset the animation. It will call the BaseHandle.Reset() which drops the object handle.</remarks>
198         /// <since_tizen> 3 </since_tizen>
199         [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1717:Only FlagsAttribute enums should have plural names")]
200         public enum States
201         {
202             /// <summary>
203             /// The animation has stopped.
204             /// </summary>
205             Stopped,
206             /// <summary>
207             /// The animation is playing.
208             /// </summary>
209             Playing,
210             /// <summary>
211             /// The animation is paused.
212             /// </summary>
213             Paused
214         }
215
216         /// <summary>
217         /// Gets or sets the duration in milliseconds of the animation.
218         /// </summary>
219         /// <since_tizen> 3 </since_tizen>
220         public int Duration
221         {
222             set
223             {
224                 SetDuration(MilliSecondsToSeconds(value));
225             }
226             get
227             {
228                 return SecondsToMilliSeconds(GetDuration());
229             }
230         }
231
232         /// <summary>
233         ///  Gets or sets the default alpha function for the animation.
234         /// </summary>
235         /// <since_tizen> 3 </since_tizen>
236         public AlphaFunction DefaultAlphaFunction
237         {
238             set
239             {
240                 SetDefaultAlphaFunction(value);
241             }
242             get
243             {
244                 AlphaFunction ret = GetDefaultAlphaFunction();
245                 return ret;
246             }
247         }
248
249         /// <summary>
250         /// Queries the state of the animation.
251         /// </summary>
252         /// <since_tizen> 3 </since_tizen>
253         public States State
254         {
255             get
256             {
257                 return GetState();
258             }
259         }
260
261         /// <summary>
262         /// Set: Enables looping for a specified number of repeats. A zero is the same as Looping = true; i.e., repeat forever.<br />
263         /// This property resets the looping value and should not be used with the Looping property.<br />
264         /// Setting this parameter does not cause the animation to Play().<br />
265         /// Get: Gets the loop count. A zero is the same as Looping = true; i.e., repeat forever.<br />
266         /// The loop count is initially 1 for play once.<br />
267         /// </summary>
268         /// <since_tizen> 3 </since_tizen>
269         public int LoopCount
270         {
271             set
272             {
273                 SetLoopCount(value);
274             }
275             get
276             {
277                 int ret = GetLoopCount();
278                 return ret;
279             }
280         }
281
282         /// <summary>
283         /// Gets or sets the status of whether the animation will loop.<br />
284         /// This property resets the loop count and should not be used with the LoopCount property.<br />
285         /// Setting this parameter does not cause the animation to Play().<br />
286         /// </summary>
287         /// <since_tizen> 3 </since_tizen>
288         public bool Looping
289         {
290             set
291             {
292                 SetLooping(value);
293             }
294             get
295             {
296                 bool ret = IsLooping();
297                 return ret;
298             }
299         }
300
301
302         /// <summary>
303         /// Gets or sets the end action of the animation.<br />
304         /// This action is performed when the animation ends or if it is stopped.<br />
305         /// The default end action is cancel.<br />
306         /// </summary>
307         /// <since_tizen> 3 </since_tizen>
308         public EndActions EndAction
309         {
310             set
311             {
312                 SetEndAction(value);
313             }
314             get
315             {
316                 return GetEndAction();
317             }
318         }
319
320         /// <summary>
321         /// Gets the current loop count.<br />
322         /// A value 0 indicating the current loop count when looping.<br />
323         /// </summary>
324         /// <since_tizen> 3 </since_tizen>
325         public int CurrentLoop
326         {
327             get
328             {
329                 return GetCurrentLoop();
330             }
331         }
332
333         /// <summary>
334         /// Gets or sets the disconnect action.<br />
335         /// If any of the animated property owners are disconnected from the stage while the animation is being played, then this action is performed.<br />
336         /// The default action is cancel.<br />
337         /// </summary>
338         /// <since_tizen> 3 </since_tizen>
339         public EndActions DisconnectAction
340         {
341             set
342             {
343                 Interop.Animation.SetDisconnectAction(SwigCPtr, (int)value);
344                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
345             }
346             get
347             {
348                 Animation.EndActions ret = (Animation.EndActions)Interop.Animation.GetDisconnectAction(SwigCPtr);
349                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
350                 return ret;
351             }
352         }
353
354
355         /// <summary>
356         /// Gets or sets the progress of the animation.<br />
357         /// The animation will play (or continue playing) from this point.<br />
358         /// The progress must be in the 0-1 interval or in the play range interval if defined<br />
359         /// otherwise, it will be ignored.<br />
360         /// </summary>
361         /// <since_tizen> 3 </since_tizen>
362         public float CurrentProgress
363         {
364             set
365             {
366                 Interop.Animation.SetCurrentProgress(SwigCPtr, value);
367                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
368             }
369             get
370             {
371                 float ret = Interop.Animation.GetCurrentProgress(SwigCPtr);
372                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
373                 return ret;
374             }
375         }
376
377         /// <summary>
378         /// Gets or sets specificifications of a speed factor for the animation.<br />
379         /// The speed factor is a multiplier of the normal velocity of the animation.<br />
380         /// Values between [0, 1] will slow down the animation and values above one will speed up the animation.<br />
381         /// It is also possible to specify a negative multiplier to play the animation in reverse.<br />
382         /// </summary>
383         /// <since_tizen> 3 </since_tizen>
384         public float SpeedFactor
385         {
386             set
387             {
388                 Interop.Animation.SetSpeedFactor(SwigCPtr, value);
389                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
390             }
391             get
392             {
393                 float ret = Interop.Animation.GetSpeedFactor(SwigCPtr);
394                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
395                 return ret;
396             }
397         }
398
399         /// <summary>
400         /// Gets or sets the playing range.<br />
401         /// Animation will play between the values specified. Both values (range.x and range.y ) should be between 0-1,
402         /// otherwise they will be ignored. If the range provided is not in proper order (minimum, maximum ), it will be reordered.<br />
403         /// </summary>
404         /// <since_tizen> 3 </since_tizen>
405         public RelativeVector2 PlayRange
406         {
407             set
408             {
409                 Interop.Animation.SetPlayRange(SwigCPtr, Vector2.getCPtr(value));
410                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
411             }
412             get
413             {
414                 Vector2 ret = new Vector2(Interop.Animation.GetPlayRange(SwigCPtr), true);
415                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
416                 return ret;
417             }
418         }
419
420
421         /// <summary>
422         /// Gets or sets the progress notification marker which triggers the ProgressReachedSignal.<br />
423         /// Percentage of animation progress should be greater than 0 and less than 1, for example, 0.3 for 30% <br />
424         /// One notification can be set on each animation.
425         /// </summary>
426         /// <since_tizen> 3 </since_tizen>
427         public float ProgressNotification
428         {
429             set
430             {
431                 Interop.Animation.SetProgressNotification(SwigCPtr, value);
432                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
433             }
434             get
435             {
436                 float ret = Interop.Animation.GetProgressNotification(SwigCPtr);
437                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
438                 return ret;
439             }
440         }
441
442         /// <summary>
443         /// Gets or sets the properties of the animation.
444         /// </summary>
445         //ToDo : will raise deprecated-ACR, [Obsolete("Deprecated in API9, Will be removed in API11, Please use PropertyList instead")]
446         [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "This API will be deprecated, so suppressing the warning for now")]
447         public string[] Properties
448         {
449             get
450             {
451                 return _properties;
452             }
453             set
454             {
455                 _properties = value;
456             }
457         }
458
459         /// <summary>
460         /// Gets or sets the destination value for each property of the animation.
461         /// </summary>
462         //ToDo : will raise deprecated-ACR, [Obsolete("Deprecated in API9, Will be removed in API11, Please use DestValueList instead")]
463         [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "This API will be deprecated, so suppressing the warning for now")]
464         public string[] DestValue
465         {
466             get
467             {
468                 return _destValue;
469             }
470             set
471             {
472                 _destValue = value;
473             }
474         }
475
476         /// <summary>
477         /// Gets or sets the start time for each property of the animation.
478         /// </summary>
479         //ToDo : will raise deprecated-ACR, [Obsolete("Deprecated in API9, Will be removed in API11, Please use StartTimeList instead")]
480         [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "This API will be deprecated, so suppressing the warning for now")]
481         public int[] StartTime
482         {
483             get
484             {
485                 return _startTime;
486             }
487             set
488             {
489                 _startTime = value;
490             }
491         }
492
493         /// <summary>
494         /// Gets or sets the end time for each property of the animation.
495         /// </summary>
496         //ToDo : will raise deprecated-ACR, [Obsolete("Deprecated in API9, Will be removed in API11, Please use EndTimeList instead")]
497         [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "This API will be deprecated, so suppressing the warning for now")]
498         public int[] EndTime
499         {
500             get
501             {
502                 return _endTime;
503             }
504             set
505             {
506                 _endTime = value;
507             }
508         }
509
510         /// <summary>
511         /// Get the list of the properties of the animation.
512         /// </summary>
513         [EditorBrowsable(EditorBrowsableState.Never)]
514         public IList<string> PropertyList
515         {
516             get
517             {
518                 if (null == propertyList)
519                 {
520                     propertyList = new List<string>();
521                 }
522
523                 return propertyList;
524             }
525         }
526
527         /// <summary>
528         /// Get the list of the destination value for each property of the animation.
529         /// </summary>
530         [EditorBrowsable(EditorBrowsableState.Never)]
531         public IList<string> DestValueList
532         {
533             get
534             {
535                 if (null == destValueList)
536                 {
537                     destValueList = new List<string>();
538                 }
539
540                 return destValueList;
541             }
542         }
543
544         /// <summary>
545         /// Get the list of the start time for each property of the animation.
546         /// </summary>
547         [EditorBrowsable(EditorBrowsableState.Never)]
548         public IList<int> StartTimeList
549         {
550             get
551             {
552                 if (null == startTimeList)
553                 {
554                     startTimeList = new List<int>();
555                 }
556
557                 return startTimeList;
558             }
559         }
560
561         /// <summary>
562         /// Get the list of end time for each property of the animation.
563         /// </summary>
564         [EditorBrowsable(EditorBrowsableState.Never)]
565         public IList<int> EndTimeList
566         {
567             get
568             {
569                 if (null == endTimeList)
570                 {
571                     endTimeList = new List<int>();
572                 }
573
574                 return endTimeList;
575             }
576         }
577
578         private bool DisableAnimation
579         {
580             get
581             {
582                 if (disableAnimation.HasValue == false)
583                 {
584                     string type = Environment.GetEnvironmentVariable("PlatformSmartType");
585                     if (type == "Entry")
586                         disableAnimation = true;
587                     else
588                         disableAnimation = false;
589                 }
590                 return disableAnimation.Value;
591             }
592         }
593
594         /// <summary>
595         /// Downcasts a handle to animation handle.<br />
596         /// If handle points to an animation object, the downcast produces a valid handle.<br />
597         /// If not, the returned handle is left uninitialized.<br />
598         /// </summary>
599         /// <param name="handle">Handle to an object.</param>
600         /// <returns>Handle to an animation object or an uninitialized handle.</returns>
601         /// <exception cref="ArgumentNullException"> Thrown when handle is null. </exception>
602         /// <since_tizen> 3 </since_tizen>
603         [Obsolete("Deprecated in API6, Will be removed in API9, Please use as keyword instead!")]
604         [EditorBrowsable(EditorBrowsableState.Never)]
605         public static Animation DownCast(BaseHandle handle)
606         {
607             if (handle == null)
608             {
609                 throw new ArgumentNullException(nameof(handle));
610             }
611             Animation ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as Animation;
612             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
613             return ret;
614         }
615
616         /// <summary>
617         /// Stops the animation.
618         /// </summary>
619         /// <param name="action">The end action can be set.</param>
620         /// <since_tizen> 3 </since_tizen>
621         public void Stop(EndActions action = EndActions.Cancel)
622         {
623             SetEndAction(action);
624             Interop.Animation.Stop(SwigCPtr);
625             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
626         }
627
628         /// <summary>
629         /// Animates a property value by a relative amount.<br />
630         /// </summary>
631         /// <param name="target">The target object to animate.</param>
632         /// <param name="property">The target property to animate.</param>
633         /// <param name="relativeValue">The property value will change by this amount.</param>
634         /// <param name="alphaFunction">The alpha function to apply.</param>
635         /// <exception cref="ArgumentNullException"> Thrown when target or property or relativeValue is null. </exception>
636         /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given relativeValue is invalid format. </exception>
637         /// <since_tizen> 3 </since_tizen>
638         public void AnimateBy(View target, string property, object relativeValue, AlphaFunction alphaFunction = null)
639         {
640             if (target == null)
641             {
642                 throw new ArgumentNullException(nameof(target));
643             }
644             if (property == null)
645             {
646                 throw new ArgumentNullException(nameof(property));
647             }
648             if (relativeValue == null)
649             {
650                 throw new ArgumentNullException(nameof(relativeValue));
651             }
652
653             using (var result = PropertyHelper.Search(target, property))
654             {
655                 if (result == null)
656                 {
657                     throw new ArgumentException("string property is invalid");
658                 }
659
660                 var current = result;
661                 while (current != null)
662                 {
663                     var targetValue = current.RefineValue(relativeValue) ?? throw new ArgumentException("Invalid " + nameof(relativeValue));
664                     AnimateBy(current.Property, targetValue, alphaFunction);
665                     targetValue.Dispose();
666                     current = current.NextResult;
667                 }
668             }
669         }
670
671         /// <summary>
672         /// Animates a property value by a relative amount.<br />
673         /// </summary>
674         /// <param name="target">The target object to animate.</param>
675         /// <param name="property">The target property to animate.</param>
676         /// <param name="relativeValue">The property value will change by this amount.</param>
677         /// <param name="startTime">The start time of the animation.</param>
678         /// <param name="endTime">The end time of the animation.</param>
679         /// <param name="alphaFunction">The alpha function to apply.</param>
680         /// <exception cref="ArgumentNullException"> Thrown when target or property or relativeValue is null. </exception>
681         /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given relativeValue is invalid format. </exception>
682         /// <since_tizen> 3 </since_tizen>
683         public void AnimateBy(View target, string property, object relativeValue, int startTime, int endTime, AlphaFunction alphaFunction = null)
684         {
685             if (target == null)
686             {
687                 throw new ArgumentNullException(nameof(target));
688             }
689             if (property == null)
690             {
691                 throw new ArgumentNullException(nameof(property));
692             }
693             if (relativeValue == null)
694             {
695                 throw new ArgumentNullException(nameof(relativeValue));
696             }
697
698             using (var result = PropertyHelper.Search(target, property))
699             {
700                 if (result == null)
701                 {
702                     throw new ArgumentException("string property is invalid");
703                 }
704
705                 var current = result;
706                 using (var time = new TimePeriod(MilliSecondsToSeconds(startTime), MilliSecondsToSeconds(endTime - startTime)))
707                 while (current != null)
708                 {
709                     var targetValue = current.RefineValue(relativeValue) ?? throw new ArgumentException("Invalid " + nameof(relativeValue));
710                     AnimateBy(current.Property, targetValue, alphaFunction, time);
711                     targetValue.Dispose();
712                     current = current.NextResult;
713                 }
714             }
715         }
716
717         /// <summary>
718         /// Animates a property to a destination value.<br />
719         /// </summary>
720         /// <param name="target">The target object to animate.</param>
721         /// <param name="property">The target property to animate.</param>
722         /// <param name="destinationValue">The destination value.</param>
723         /// <param name="alphaFunction">The alpha function to apply.</param>
724         /// <exception cref="ArgumentNullException"> Thrown when target or property or destinationValue is null. </exception>
725         /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given destinationValue is invalid format. </exception>
726         /// <since_tizen> 3 </since_tizen>
727         public void AnimateTo(View target, string property, object destinationValue, AlphaFunction alphaFunction = null)
728         {
729             if (target == null)
730             {
731                 throw new ArgumentNullException(nameof(target));
732             }
733             if (property == null)
734             {
735                 throw new ArgumentNullException(nameof(property));
736             }
737             if (destinationValue == null)
738             {
739                 throw new ArgumentNullException(nameof(destinationValue));
740             }
741
742             using (var result = PropertyHelper.Search(target, property))
743             {
744                 if (result == null)
745                 {
746                     throw new ArgumentException("string property is invalid");
747                 }
748
749                 var current = result;
750                 while (current != null)
751                 {
752                     var targetValue = current.RefineValue(destinationValue) ?? throw new ArgumentException("Invalid " + nameof(destinationValue));
753                     AnimateTo(current.Property, targetValue, alphaFunction);
754                     targetValue.Dispose();
755                     current = current.NextResult;
756                 }
757             }
758         }
759
760         /// <summary>
761         /// Animates one or more properties to a destination value.<br />
762         /// </summary>
763         /// <param name="target">The target object to animate.</param>
764         /// <exception cref="ArgumentNullException"> Thrown when target is null. </exception>
765         public void PlayAnimateTo(View target)
766         {
767             if (target == null)
768             {
769                 throw new ArgumentNullException(nameof(target));
770             }
771
772             Clear();
773
774             if (null != propertyList && null != destValueList && null != startTimeList && null != endTimeList)
775             {
776                 if (propertyList.Count == destValueList.Count
777                     &&
778                     startTimeList.Count == endTimeList.Count
779                     &&
780                     propertyList.Count == startTimeList.Count)
781                 {
782                     int count = propertyList.Count;
783                     for (int index = 0; index < count; index++)
784                     {
785                         var elementType = target.GetType();
786                         PropertyInfo propertyInfo = elementType.GetProperties().FirstOrDefault(fi => fi.Name == propertyList[index]);
787
788                         if (propertyInfo != null)
789                         {
790                             object destinationValue = ConvertTo(destValueList[index], propertyInfo.PropertyType);
791
792                             if (destinationValue != null)
793                             {
794                                 AnimateTo(target, propertyList[index], destinationValue, startTimeList[index], endTimeList[index]);
795                             }
796                         }
797                     }
798                     Play();
799                 }
800             }
801             else
802             {
803                 if (_properties.Length == _destValue.Length && _startTime.Length == _endTime.Length && _properties.Length == _startTime.Length)
804                 {
805                     int length = _properties.Length;
806                     for (int index = 0; index < length; index++)
807                     {
808                         //object destinationValue = _destValue[index];
809                         var elementType = target.GetType();
810                         PropertyInfo propertyInfo = elementType.GetProperties().FirstOrDefault(fi => fi.Name == _properties[index]);
811                         //var propertyInfo = elementType.GetRuntimeProperties().FirstOrDefault(p => p.Name == localName);
812                         if (propertyInfo != null)
813                         {
814                             object destinationValue = ConvertTo(_destValue[index], propertyInfo.PropertyType);
815
816                             if (destinationValue != null)
817                             {
818                                 AnimateTo(target, _properties[index], destinationValue, _startTime[index], _endTime[index]);
819                             }
820                         }
821                     }
822                     Play();
823                 }
824             }
825         }
826
827         /// <summary>
828         /// Animates a property to a destination value.<br />
829         /// </summary>
830         /// <param name="target">The target object to animate.</param>
831         /// <param name="property">The target property to animate.</param>
832         /// <param name="destinationValue">The destination value.</param>
833         /// <param name="startTime">The start time of the animation.</param>
834         /// <param name="endTime">The end time of the animation.</param>
835         /// <param name="alphaFunction">The alpha function to apply.</param>
836         /// <exception cref="ArgumentNullException"> Thrown when target or property or destinationValue is null. </exception>
837         /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given destinationValue is invalid format. </exception>
838         /// <since_tizen> 3 </since_tizen>
839         public void AnimateTo(View target, string property, object destinationValue, int startTime, int endTime, AlphaFunction alphaFunction = null)
840         {
841             if (target == null)
842             {
843                 throw new ArgumentNullException(nameof(target));
844             }
845             if (property == null)
846             {
847                 throw new ArgumentNullException(nameof(property));
848             }
849             if (destinationValue == null)
850             {
851                 throw new ArgumentNullException(nameof(destinationValue));
852             }
853
854             using (var result = PropertyHelper.Search(target, property))
855             {
856                 if (result == null)
857                 {
858                     throw new ArgumentException("string property is invalid");
859                 }
860
861                 var current = result;
862                 using (var time = new TimePeriod(MilliSecondsToSeconds(startTime), MilliSecondsToSeconds(endTime - startTime)))
863                 while (current != null)
864                 {
865                     var targetValue = current.RefineValue(destinationValue) ?? throw new ArgumentException("Invalid " + nameof(destinationValue));
866                     AnimateTo(current.Property, targetValue, alphaFunction, time);
867                     targetValue.Dispose();
868                     current = current.NextResult;
869                 }
870             }
871         }
872
873         /// <summary>
874         /// Animates a property between keyframes.
875         /// </summary>
876         /// <param name="target">The target object to animate.</param>
877         /// <param name="property">The target property to animate.</param>
878         /// <param name="keyFrames">The set of time or value pairs between which to animate.</param>
879         /// <param name="interpolation">The method used to interpolate between values.</param>
880         /// <param name="alphaFunction">The alpha function to apply.</param>
881         /// <exception cref="ArgumentNullException"> Thrown when target or property or keyFrames is null. </exception>
882         /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given keyFrames has invalid value. </exception>
883         /// <since_tizen> 3 </since_tizen>
884         public void AnimateBetween(View target, string property, KeyFrames keyFrames, Interpolation interpolation = Interpolation.Linear, AlphaFunction alphaFunction = null)
885         {
886             if (target == null)
887             {
888                 throw new ArgumentNullException(nameof(target));
889             }
890             if (property == null)
891             {
892                 throw new ArgumentNullException(nameof(property));
893             }
894             if (keyFrames == null)
895             {
896                 throw new ArgumentNullException(nameof(keyFrames));
897             }
898
899             using (var result = PropertyHelper.Search(target, property))
900             {
901                 if (result == null)
902                 {
903                     throw new ArgumentException("string property is invalid");
904                 }
905
906                 var current = result;
907                 while (current != null)
908                 {
909                     // NOTE Do not dispose keyFrames object returned by GetRefinedKeyFrames() here.
910                     AnimateBetween(current.Property, current.RefineKeyFrames(keyFrames) ?? throw new ArgumentException("Invalid " + nameof(keyFrames)), alphaFunction, interpolation);   
911                     current = current.NextResult;
912                 }
913             }
914         }
915
916         /// <summary>
917         /// Animates a property between keyframes.
918         /// </summary>
919         /// <param name="target">The target object to animate</param>
920         /// <param name="property">The target property to animate</param>
921         /// <param name="keyFrames">The set of time/value pairs between which to animate</param>
922         /// <param name="startTime">The start time of animation in milliseconds.</param>
923         /// <param name="endTime">The end time of animation in milliseconds.</param>
924         /// <param name="interpolation">The method used to interpolate between values.</param>
925         /// <param name="alphaFunction">The alpha function to apply.</param>
926         /// <exception cref="ArgumentNullException"> Thrown when target or property or keyFrames is null. </exception>
927         /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given keyFrames has invalid value. </exception>
928         /// <since_tizen> 3 </since_tizen>
929         public void AnimateBetween(View target, string property, KeyFrames keyFrames, int startTime, int endTime, Interpolation interpolation = Interpolation.Linear, AlphaFunction alphaFunction = null)
930         {
931             if (target == null)
932             {
933                 throw new ArgumentNullException(nameof(target));
934             }
935             if (property == null)
936             {
937                 throw new ArgumentNullException(nameof(property));
938             }
939             if (keyFrames == null)
940             {
941                 throw new ArgumentNullException(nameof(keyFrames));
942             }
943
944             using (var result = PropertyHelper.Search(target, property))
945             {
946                 if (result == null)
947                 {
948                     throw new ArgumentException("string property is invalid");
949                 }
950
951                 var current = result;
952                 using (var time = new TimePeriod(MilliSecondsToSeconds(startTime), MilliSecondsToSeconds(endTime - startTime)))
953                 while (current != null)
954                 {
955                     // NOTE Do not dispose keyFrames object returned by GetRefinedKeyFrames() here.
956                     AnimateBetween(current.Property, current.RefineKeyFrames(keyFrames) ?? throw new ArgumentException("Invalid " + nameof(keyFrames)), alphaFunction, time, interpolation);   
957                     current = current.NextResult;
958                 }
959             }
960         }
961
962         /// <summary>
963         /// Animates the view's position and orientation through a predefined path.<br />
964         /// The view will rotate to orient the supplied forward vector with the path's tangent.<br />
965         /// If forward is the zero vector then no rotation will happen.<br />
966         /// </summary>
967         /// <param name="view">The view to animate.</param>
968         /// <param name="path">It defines position and orientation.</param>
969         /// <param name="forward">The vector (in local space coordinate system) will be oriented with the path's tangent direction.</param>
970         /// <param name="alphaFunction">The alpha function to apply.</param>
971         /// <since_tizen> 3 </since_tizen>
972         public void AnimatePath(View view, Path path, Vector3 forward, AlphaFunction alphaFunction = null)
973         {
974             if (alphaFunction == null)
975             {
976                 Animate(view, path, forward);
977             }
978             else
979             {
980                 Animate(view, path, forward, alphaFunction);
981             }
982         }
983
984         /// <summary>
985         /// Animates the view's position and orientation through a predefined path.<br />
986         /// The view will rotate to orient the supplied forward vector with the path's tangent.<br />
987         /// If forward is the zero vector then no rotation will happen.<br />
988         /// </summary>
989         /// <param name="view">The view to animate.</param>
990         /// <param name="path">It defines position and orientation.</param>
991         /// <param name="forward">The vector (in local space coordinate system) will be oriented with the path's tangent direction.</param>
992         /// <param name="startTime">The start time of the animation.</param>
993         /// <param name="endTime">The end time of the animation.</param>
994         /// <param name="alphaFunction">The alpha function to apply.</param>
995         /// <since_tizen> 3 </since_tizen>
996         public void AnimatePath(View view, Path path, Vector3 forward, int startTime, int endTime, AlphaFunction alphaFunction = null)
997         {
998             TimePeriod time = new TimePeriod(MilliSecondsToSeconds(startTime), MilliSecondsToSeconds(endTime - startTime));
999             if (alphaFunction == null)
1000             {
1001                 Animate(view, path, forward, time);
1002             }
1003             else
1004             {
1005                 Animate(view, path, forward, alphaFunction, time);
1006             }
1007             time.Dispose();
1008         }
1009
1010         /// <summary>
1011         /// Creates an initialized animation.<br />
1012         /// The animation will not loop.<br />
1013         /// The default end action is "Cancel".<br />
1014         /// The default alpha function is linear.<br />
1015         /// </summary>
1016         /// <since_tizen> 3 </since_tizen>
1017         public Animation() : this(Interop.Animation.New(0.0f), true)
1018         {
1019             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1020         }
1021
1022         /// <summary>
1023         /// Plays the animation.
1024         /// </summary>
1025         /// <since_tizen> 3 </since_tizen>
1026         public void Play()
1027         {
1028             Interop.Animation.Play(SwigCPtr);
1029             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1030
1031             if (DisableAnimation == true)
1032                 Stop(EndActions.StopFinal);
1033         }
1034
1035         /// <summary>
1036         /// Plays the animation from a given point.<br />
1037         /// The progress must be in the 0-1 interval or in the play range interval if defined,
1038         /// otherwise, it will be ignored.<br />
1039         /// </summary>
1040         /// <param name="progress">A value between [0,1], or between the play range if specified, from where the animation should start playing.</param>
1041         /// <since_tizen> 3 </since_tizen>
1042         public void PlayFrom(float progress)
1043         {
1044             Interop.Animation.PlayFrom(SwigCPtr, progress);
1045             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1046         }
1047
1048         /// <summary>
1049         /// Plays the animation after a given delay time.<br/>
1050         /// The delay time is not included in the looping time.<br/>
1051         /// When the delay time is a negative value, it would treat as play immediately.<br/>
1052         /// </summary>
1053         /// <param name="delayMilliseconds">The delay time.</param>
1054         /// <since_tizen> 4 </since_tizen>
1055         public void PlayAfter(int delayMilliseconds)
1056         {
1057             Interop.Animation.PlayAfter(SwigCPtr, MilliSecondsToSeconds(delayMilliseconds));
1058             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1059         }
1060
1061         /// <summary>
1062         /// Pauses the animation.
1063         /// </summary>
1064         /// <since_tizen> 3 </since_tizen>
1065         public void Pause()
1066         {
1067             Interop.Animation.Pause(SwigCPtr);
1068             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1069         }
1070
1071         /// <summary>
1072         /// Stops the animation.
1073         /// </summary>
1074         /// <since_tizen> 3 </since_tizen>
1075         public void Stop()
1076         {
1077             Interop.Animation.Stop(SwigCPtr);
1078             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1079         }
1080
1081         /// <summary>
1082         /// Clears the animation.<br />
1083         /// This disconnects any objects that were being animated, effectively stopping the animation.<br />
1084         /// </summary>
1085         /// <since_tizen> 3 </since_tizen>
1086         public void Clear()
1087         {
1088             Interop.Animation.Clear(SwigCPtr);
1089             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1090         }
1091
1092         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Animation obj)
1093         {
1094             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
1095         }
1096
1097         internal object ConvertTo(object value, Type toType)
1098         {
1099             Func<object> getConverter = () =>
1100             {
1101                 string converterTypeName = GetTypeConverterTypeName(toType.GetTypeInfo().CustomAttributes);
1102                 if (converterTypeName == null)
1103                     return null;
1104
1105                 Type convertertype = Type.GetType(converterTypeName);
1106                 return Activator.CreateInstance(convertertype);
1107             };
1108
1109             return ConvertTo(value, toType, getConverter);
1110         }
1111
1112         internal object ConvertTo(object value, Type toType, Func<object> getConverter)
1113         {
1114             if (value == null)
1115                 return null;
1116
1117             var str = value as string;
1118             if (str != null)
1119             {
1120                 //If there's a [TypeConverter], use it
1121                 object converter = getConverter?.Invoke();
1122                 var xfTypeConverter = converter as Tizen.NUI.Binding.TypeConverter;
1123                 if (xfTypeConverter != null)
1124                     return value = xfTypeConverter.ConvertFromInvariantString(str);
1125                 var converterType = converter?.GetType();
1126                 if (converterType != null)
1127                 {
1128                     var convertFromStringInvariant = converterType.GetRuntimeMethod("ConvertFromInvariantString",
1129                         new[] { typeof(string) });
1130                     if (convertFromStringInvariant != null)
1131                         return value = convertFromStringInvariant.Invoke(converter, new object[] { str });
1132                 }
1133
1134                 //If the type is nullable, as the value is not null, it's safe to assume we want the built-in conversion
1135                 if (toType.GetTypeInfo().IsGenericType && toType.GetGenericTypeDefinition() == typeof(Nullable<>))
1136                     toType = Nullable.GetUnderlyingType(toType);
1137
1138                 //Obvious Built-in conversions
1139                 if (toType.GetTypeInfo().IsEnum)
1140                     return Enum.Parse(toType, str, true);
1141                 if (toType == typeof(SByte))
1142                     return SByte.Parse(str, CultureInfo.InvariantCulture);
1143                 if (toType == typeof(Int16))
1144                     return Int16.Parse(str, CultureInfo.InvariantCulture);
1145                 if (toType == typeof(Int32))
1146                     return Int32.Parse(str, CultureInfo.InvariantCulture);
1147                 if (toType == typeof(Int64))
1148                     return Int64.Parse(str, CultureInfo.InvariantCulture);
1149                 if (toType == typeof(Byte))
1150                     return Byte.Parse(str, CultureInfo.InvariantCulture);
1151                 if (toType == typeof(UInt16))
1152                     return UInt16.Parse(str, CultureInfo.InvariantCulture);
1153                 if (toType == typeof(UInt32))
1154                     return UInt32.Parse(str, CultureInfo.InvariantCulture);
1155                 if (toType == typeof(UInt64))
1156                     return UInt64.Parse(str, CultureInfo.InvariantCulture);
1157                 if (toType == typeof(Single))
1158                     return Single.Parse(str, CultureInfo.InvariantCulture);
1159                 if (toType == typeof(Double))
1160                     return Double.Parse(str, CultureInfo.InvariantCulture);
1161                 if (toType == typeof(Boolean))
1162                     return Boolean.Parse(str);
1163                 if (toType == typeof(TimeSpan))
1164                     return TimeSpan.Parse(str, CultureInfo.InvariantCulture);
1165                 if (toType == typeof(DateTime))
1166                     return DateTime.Parse(str, CultureInfo.InvariantCulture);
1167                 if (toType == typeof(Char))
1168                 {
1169                     char c = '\0';
1170                     _ = Char.TryParse(str, out c);
1171                     return c;
1172                 }
1173                 if (toType == typeof(String) && str.StartsWith("{}", StringComparison.Ordinal))
1174                     return str.Substring(2);
1175                 if (toType == typeof(String))
1176                     return value;
1177                 if (toType == typeof(Decimal))
1178                     return Decimal.Parse(str, CultureInfo.InvariantCulture);
1179             }
1180
1181             //if the value is not assignable and there's an implicit conversion, convert
1182             if (value != null && !toType.IsAssignableFrom(value.GetType()))
1183             {
1184                 var opImplicit = GetImplicitConversionOperator(value.GetType(), value.GetType(), toType)
1185                                  ?? GetImplicitConversionOperator(toType, value.GetType(), toType);
1186                 //var opImplicit = value.GetType().GetImplicitConversionOperator(fromType: value.GetType(), toType: toType)
1187                 //                ?? toType.GetImplicitConversionOperator(fromType: value.GetType(), toType: toType);
1188
1189                 if (opImplicit != null)
1190                 {
1191                     value = opImplicit.Invoke(null, new[] { value });
1192                     return value;
1193                 }
1194             }
1195
1196             return value;
1197         }
1198
1199         internal string GetTypeConverterTypeName(IEnumerable<CustomAttributeData> attributes)
1200         {
1201             var converterAttribute =
1202                 attributes.FirstOrDefault(cad => Tizen.NUI.Binding.TypeConverterAttribute.TypeConvertersType.Contains(cad.AttributeType.FullName));
1203             if (converterAttribute == null)
1204                 return null;
1205             if (converterAttribute.ConstructorArguments[0].ArgumentType == typeof(string))
1206                 return (string)converterAttribute.ConstructorArguments[0].Value;
1207             if (converterAttribute.ConstructorArguments[0].ArgumentType == typeof(Type))
1208                 return ((Type)converterAttribute.ConstructorArguments[0].Value).AssemblyQualifiedName;
1209             return null;
1210         }
1211
1212         internal MethodInfo GetImplicitConversionOperator(Type onType, Type fromType, Type toType)
1213         {
1214 #if NETSTANDARD1_0
1215             var mi = onType.GetRuntimeMethod("op_Implicit", new[] { fromType });
1216 #else
1217             var bindingFlags = BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy;
1218             var mi = onType.GetMethod("op_Implicit", bindingFlags, null, new[] { fromType }, null);
1219 #endif
1220             if (mi == null) return null;
1221             if (!mi.IsSpecialName) return null;
1222             if (!mi.IsPublic) return null;
1223             if (!mi.IsStatic) return null;
1224             if (!toType.IsAssignableFrom(mi.ReturnType)) return null;
1225
1226             return mi;
1227         }
1228
1229         internal Animation(float durationSeconds) : this(Interop.Animation.New(durationSeconds), true)
1230         {
1231             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1232
1233         }
1234
1235         internal Animation(Animation handle) : this(Interop.Animation.NewAnimation(Animation.getCPtr(handle)), true)
1236         {
1237             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1238         }
1239
1240         internal Animation Assign(Animation rhs)
1241         {
1242             Animation ret = new Animation(Interop.Animation.Assign(SwigCPtr, Animation.getCPtr(rhs)), false);
1243             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1244             return ret;
1245         }
1246
1247         internal void SetDuration(float seconds)
1248         {
1249             Interop.Animation.SetDuration(SwigCPtr, seconds);
1250             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1251         }
1252
1253         internal float GetDuration()
1254         {
1255             float ret = Interop.Animation.GetDuration(SwigCPtr);
1256             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1257             return ret;
1258         }
1259
1260         internal void SetLooping(bool looping)
1261         {
1262             Interop.Animation.SetLooping(SwigCPtr, looping);
1263             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1264         }
1265
1266         internal void SetLoopCount(int count)
1267         {
1268             Interop.Animation.SetLoopCount(SwigCPtr, count);
1269             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1270         }
1271
1272         internal int GetLoopCount()
1273         {
1274             int ret = Interop.Animation.GetLoopCount(SwigCPtr);
1275             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1276             return ret;
1277         }
1278
1279         internal int GetCurrentLoop()
1280         {
1281             int ret = Interop.Animation.GetCurrentLoop(SwigCPtr);
1282             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1283             return ret;
1284         }
1285
1286         internal bool IsLooping()
1287         {
1288             bool ret = Interop.Animation.IsLooping(SwigCPtr);
1289             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1290             return ret;
1291         }
1292
1293         internal void SetEndAction(Animation.EndActions action)
1294         {
1295             Interop.Animation.SetEndAction(SwigCPtr, (int)action);
1296             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1297         }
1298
1299         internal Animation.EndActions GetEndAction()
1300         {
1301             Animation.EndActions ret = (Animation.EndActions)Interop.Animation.GetEndAction(SwigCPtr);
1302             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1303             return ret;
1304         }
1305
1306         internal void SetDisconnectAction(Animation.EndActions disconnectAction)
1307         {
1308             Interop.Animation.SetDisconnectAction(SwigCPtr, (int)disconnectAction);
1309             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1310         }
1311
1312         internal Animation.EndActions GetDisconnectAction()
1313         {
1314             Animation.EndActions ret = (Animation.EndActions)Interop.Animation.GetDisconnectAction(SwigCPtr);
1315             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1316             return ret;
1317         }
1318
1319         internal void SetDefaultAlphaFunction(AlphaFunction alpha)
1320         {
1321             Interop.Animation.SetDefaultAlphaFunction(SwigCPtr, AlphaFunction.getCPtr(alpha));
1322             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1323         }
1324
1325         internal AlphaFunction GetDefaultAlphaFunction()
1326         {
1327             AlphaFunction ret = new AlphaFunction(Interop.Animation.GetDefaultAlphaFunction(SwigCPtr), true);
1328             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1329             return ret;
1330         }
1331
1332         internal void SetCurrentProgress(float progress)
1333         {
1334             Interop.Animation.SetCurrentProgress(SwigCPtr, progress);
1335             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1336         }
1337
1338         internal float GetCurrentProgress()
1339         {
1340             float ret = Interop.Animation.GetCurrentProgress(SwigCPtr);
1341             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1342             return ret;
1343         }
1344
1345         internal void SetSpeedFactor(float factor)
1346         {
1347             Interop.Animation.SetSpeedFactor(SwigCPtr, factor);
1348             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1349         }
1350
1351         internal float GetSpeedFactor()
1352         {
1353             float ret = Interop.Animation.GetSpeedFactor(SwigCPtr);
1354             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1355             return ret;
1356         }
1357
1358         internal void SetPlayRange(Vector2 range)
1359         {
1360             Interop.Animation.SetPlayRange(SwigCPtr, Vector2.getCPtr(range));
1361             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1362         }
1363
1364         internal Vector2 GetPlayRange()
1365         {
1366             Vector2 ret = new Vector2(Interop.Animation.GetPlayRange(SwigCPtr), true);
1367             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1368             return ret;
1369         }
1370
1371         internal Animation.States GetState()
1372         {
1373             Animation.States ret = (Animation.States)Interop.Animation.GetState(SwigCPtr);
1374             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1375             return ret;
1376         }
1377
1378         internal AnimationSignal FinishedSignal()
1379         {
1380             AnimationSignal ret = new AnimationSignal(Interop.Animation.FinishedSignal(SwigCPtr), false);
1381             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1382             return ret;
1383         }
1384
1385         internal AnimationSignal ProgressReachedSignal()
1386         {
1387             AnimationSignal ret = new AnimationSignal(Interop.Animation.ProgressReachedSignal(SwigCPtr), false);
1388             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1389             return ret;
1390         }
1391
1392         internal void AnimateBy(Property target, PropertyValue relativeValue, AlphaFunction alpha)
1393         {
1394             if (alpha == null)
1395             {
1396                 Interop.Animation.AnimateBy(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(relativeValue));
1397             }
1398             else
1399             {
1400                 Interop.Animation.AnimateByAlphaFunction(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(relativeValue), AlphaFunction.getCPtr(alpha));
1401             }
1402             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1403         }
1404
1405         internal void AnimateBy(Property target, PropertyValue relativeValue, AlphaFunction alpha, TimePeriod period)
1406         {
1407             if (alpha == null)
1408             {
1409                 Interop.Animation.AnimateByTimePeriod(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(relativeValue), TimePeriod.getCPtr(period));
1410             }
1411             else
1412             {
1413                 Interop.Animation.AnimateBy(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(relativeValue), AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period));
1414             }
1415             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1416         }
1417
1418         internal void AnimateTo(Property target, PropertyValue destinationValue, AlphaFunction alpha)
1419         {
1420             if (alpha == null)
1421             {
1422                 Interop.Animation.AnimateTo(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(destinationValue));
1423             }
1424             else
1425             {
1426                 Interop.Animation.AnimateToAlphaFunction(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(destinationValue), AlphaFunction.getCPtr(alpha));
1427             }
1428             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1429         }
1430
1431         internal void AnimateTo(Property target, PropertyValue destinationValue, AlphaFunction alpha, TimePeriod period)
1432         {
1433             if (alpha == null)
1434             {
1435                 Interop.Animation.AnimateToTimePeriod(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(destinationValue), TimePeriod.getCPtr(period));
1436             }
1437             else
1438             {
1439                 Interop.Animation.AnimateTo(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(destinationValue), AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period));
1440             }
1441             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1442         }
1443
1444         internal void AnimateBetween(Property target, KeyFrames keyFrames)
1445         {
1446             Interop.Animation.AnimateBetween(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames));
1447             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1448         }
1449
1450         internal void AnimateBetween(Property target, KeyFrames keyFrames, AlphaFunction alpha)
1451         {
1452             Interop.Animation.AnimateBetweenAlphaFunction(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), AlphaFunction.getCPtr(alpha));
1453             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1454         }
1455
1456         internal void AnimateBetween(Property target, KeyFrames keyFrames, AlphaFunction alpha, Animation.Interpolation interpolation)
1457         {
1458             if (alpha == null)
1459             {
1460                 Interop.Animation.AnimateBetween(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), (int)interpolation);
1461             }
1462             else
1463             {
1464                 Interop.Animation.AnimateBetweenAlphaFunctionInterpolation(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), AlphaFunction.getCPtr(alpha), (int)interpolation);
1465             }
1466             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1467         }
1468
1469         internal void AnimateBetween(Property target, KeyFrames keyFrames, TimePeriod period)
1470         {
1471             Interop.Animation.AnimateBetweenTimePeriod(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), TimePeriod.getCPtr(period));
1472             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1473         }
1474
1475         internal void AnimateBetween(Property target, KeyFrames keyFrames, AlphaFunction alpha, TimePeriod period)
1476         {
1477             Interop.Animation.AnimateBetween(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period));
1478             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1479         }
1480
1481         internal void AnimateBetween(Property target, KeyFrames keyFrames, AlphaFunction alpha, TimePeriod period, Animation.Interpolation interpolation)
1482         {
1483             if (alpha == null)
1484             {
1485                 Interop.Animation.AnimateBetweenTimePeriodInterpolation(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), TimePeriod.getCPtr(period), (int)interpolation);
1486             }
1487             else
1488             {
1489                 Interop.Animation.AnimateBetween(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period), (int)interpolation);
1490             }
1491             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1492         }
1493
1494         internal void Animate(View view, Path path, Vector3 forward)
1495         {
1496             Interop.Animation.Animate(SwigCPtr, View.getCPtr(view), Path.getCPtr(path), Vector3.getCPtr(forward));
1497             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1498         }
1499
1500         internal void Animate(View view, Path path, Vector3 forward, AlphaFunction alpha)
1501         {
1502             Interop.Animation.AnimateAlphaFunction(SwigCPtr, View.getCPtr(view), Path.getCPtr(path), Vector3.getCPtr(forward), AlphaFunction.getCPtr(alpha));
1503             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1504         }
1505
1506         internal void Animate(View view, Path path, Vector3 forward, TimePeriod period)
1507         {
1508             Interop.Animation.AnimateTimePeriod(SwigCPtr, View.getCPtr(view), Path.getCPtr(path), Vector3.getCPtr(forward), TimePeriod.getCPtr(period));
1509             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1510         }
1511
1512         internal void Animate(View view, Path path, Vector3 forward, AlphaFunction alpha, TimePeriod period)
1513         {
1514             Interop.Animation.Animate(SwigCPtr, View.getCPtr(view), Path.getCPtr(path), Vector3.getCPtr(forward), AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period));
1515             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1516         }
1517
1518         internal void Show(View view, float delaySeconds)
1519         {
1520             Interop.Animation.Show(SwigCPtr, View.getCPtr(view), delaySeconds);
1521             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1522         }
1523
1524         internal void Hide(View view, float delaySeconds)
1525         {
1526             Interop.Animation.Hide(SwigCPtr, View.getCPtr(view), delaySeconds);
1527             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1528         }
1529
1530         /// <summary>
1531         /// To make animation instance be disposed.
1532         /// </summary>
1533         /// <since_tizen> 3 </since_tizen>
1534         protected override void Dispose(DisposeTypes type)
1535         {
1536             if (disposed)
1537             {
1538                 return;
1539             }
1540
1541             if (_animationFinishedEventHandler != null)
1542             {
1543                 AnimationSignal finishedSignal = FinishedSignal();
1544                 finishedSignal?.Disconnect(_finishedCallbackOfNative);
1545                 finishedSignal?.Dispose();
1546                 _animationFinishedEventHandler = null;
1547             }
1548
1549             if (_animationProgressReachedEventCallback != null)
1550             {
1551                 AnimationSignal progressReachedSignal = ProgressReachedSignal();
1552                 progressReachedSignal?.Disconnect(_animationProgressReachedEventCallback);
1553                 progressReachedSignal?.Dispose();
1554                 _animationProgressReachedEventCallback = null;
1555             }
1556
1557             base.Dispose(type);
1558         }
1559
1560         /// This will not be public opened.
1561         [EditorBrowsable(EditorBrowsableState.Never)]
1562         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1563         {
1564             if (swigCPtr.Handle == IntPtr.Zero || this.HasBody() == false)
1565             {
1566                 Tizen.Log.Fatal("NUI", $"[ERROR] Animation ReleaseSwigCPtr()! IntPtr=0x{swigCPtr.Handle:X} HasBody={this.HasBody()}");
1567                 return;
1568             }
1569             Interop.Animation.DeleteAnimation(swigCPtr);
1570         }
1571
1572         private void OnFinished(IntPtr data)
1573         {
1574             if (_animationFinishedEventHandler != null)
1575             {
1576                 //here we send all data to user event handlers
1577                 _animationFinishedEventHandler(this, null);
1578             }
1579         }
1580
1581         private void OnProgressReached(IntPtr data)
1582         {
1583             if (_animationProgressReachedEventHandler != null)
1584             {
1585                 //here we send all data to user event handlers
1586                 _animationProgressReachedEventHandler(this, null);
1587             }
1588         }
1589
1590         private float MilliSecondsToSeconds(int millisec)
1591         {
1592             return (float)millisec / 1000.0f;
1593         }
1594
1595         private int SecondsToMilliSeconds(float sec)
1596         {
1597             return (int)(sec * 1000);
1598         }
1599     }
1600 }