[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         internal static Animation DownCast(BaseHandle handle)
603         {
604             if (handle == null)
605             {
606                 throw new ArgumentNullException(nameof(handle));
607             }
608             Animation ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as Animation;
609             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
610             return ret;
611         }
612
613         /// <summary>
614         /// Stops the animation.
615         /// </summary>
616         /// <param name="action">The end action can be set.</param>
617         /// <since_tizen> 3 </since_tizen>
618         public void Stop(EndActions action = EndActions.Cancel)
619         {
620             SetEndAction(action);
621             Interop.Animation.Stop(SwigCPtr);
622             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
623         }
624
625         /// <summary>
626         /// Animates a property value by a relative amount.<br />
627         /// </summary>
628         /// <param name="target">The target object to animate.</param>
629         /// <param name="property">The target property to animate.</param>
630         /// <param name="relativeValue">The property value will change by this amount.</param>
631         /// <param name="alphaFunction">The alpha function to apply.</param>
632         /// <exception cref="ArgumentNullException"> Thrown when target or property or relativeValue is null. </exception>
633         /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given relativeValue is invalid format. </exception>
634         /// <since_tizen> 3 </since_tizen>
635         public void AnimateBy(View target, string property, object relativeValue, AlphaFunction alphaFunction = null)
636         {
637             if (target == null)
638             {
639                 throw new ArgumentNullException(nameof(target));
640             }
641             if (property == null)
642             {
643                 throw new ArgumentNullException(nameof(property));
644             }
645             if (relativeValue == null)
646             {
647                 throw new ArgumentNullException(nameof(relativeValue));
648             }
649
650             using (var result = PropertyHelper.Search(target, property))
651             {
652                 if (result == null)
653                 {
654                     throw new ArgumentException("string property is invalid");
655                 }
656
657                 var current = result;
658                 while (current != null)
659                 {
660                     var targetValue = current.RefineValue(relativeValue) ?? throw new ArgumentException("Invalid " + nameof(relativeValue));
661                     AnimateBy(current.Property, targetValue, alphaFunction);
662                     targetValue.Dispose();
663                     current = current.NextResult;
664                 }
665             }
666         }
667
668         /// <summary>
669         /// Animates a property value by a relative amount.<br />
670         /// </summary>
671         /// <param name="target">The target object to animate.</param>
672         /// <param name="property">The target property to animate.</param>
673         /// <param name="relativeValue">The property value will change by this amount.</param>
674         /// <param name="startTime">The start time of the animation.</param>
675         /// <param name="endTime">The end time of the animation.</param>
676         /// <param name="alphaFunction">The alpha function to apply.</param>
677         /// <exception cref="ArgumentNullException"> Thrown when target or property or relativeValue is null. </exception>
678         /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given relativeValue is invalid format. </exception>
679         /// <since_tizen> 3 </since_tizen>
680         public void AnimateBy(View target, string property, object relativeValue, int startTime, int endTime, AlphaFunction alphaFunction = null)
681         {
682             if (target == null)
683             {
684                 throw new ArgumentNullException(nameof(target));
685             }
686             if (property == null)
687             {
688                 throw new ArgumentNullException(nameof(property));
689             }
690             if (relativeValue == null)
691             {
692                 throw new ArgumentNullException(nameof(relativeValue));
693             }
694
695             using (var result = PropertyHelper.Search(target, property))
696             {
697                 if (result == null)
698                 {
699                     throw new ArgumentException("string property is invalid");
700                 }
701
702                 var current = result;
703                 using (var time = new TimePeriod(MilliSecondsToSeconds(startTime), MilliSecondsToSeconds(endTime - startTime)))
704                 while (current != null)
705                 {
706                     var targetValue = current.RefineValue(relativeValue) ?? throw new ArgumentException("Invalid " + nameof(relativeValue));
707                     AnimateBy(current.Property, targetValue, alphaFunction, time);
708                     targetValue.Dispose();
709                     current = current.NextResult;
710                 }
711             }
712         }
713
714         /// <summary>
715         /// Animates a property to a destination value.<br />
716         /// </summary>
717         /// <param name="target">The target object to animate.</param>
718         /// <param name="property">The target property to animate.</param>
719         /// <param name="destinationValue">The destination value.</param>
720         /// <param name="alphaFunction">The alpha function to apply.</param>
721         /// <exception cref="ArgumentNullException"> Thrown when target or property or destinationValue is null. </exception>
722         /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given destinationValue is invalid format. </exception>
723         /// <since_tizen> 3 </since_tizen>
724         public void AnimateTo(View target, string property, object destinationValue, AlphaFunction alphaFunction = null)
725         {
726             if (target == null)
727             {
728                 throw new ArgumentNullException(nameof(target));
729             }
730             if (property == null)
731             {
732                 throw new ArgumentNullException(nameof(property));
733             }
734             if (destinationValue == null)
735             {
736                 throw new ArgumentNullException(nameof(destinationValue));
737             }
738
739             using (var result = PropertyHelper.Search(target, property))
740             {
741                 if (result == null)
742                 {
743                     throw new ArgumentException("string property is invalid");
744                 }
745
746                 var current = result;
747                 while (current != null)
748                 {
749                     var targetValue = current.RefineValue(destinationValue) ?? throw new ArgumentException("Invalid " + nameof(destinationValue));
750                     AnimateTo(current.Property, targetValue, alphaFunction);
751                     targetValue.Dispose();
752                     current = current.NextResult;
753                 }
754             }
755         }
756
757         /// <summary>
758         /// Animates one or more properties to a destination value.<br />
759         /// </summary>
760         /// <param name="target">The target object to animate.</param>
761         /// <exception cref="ArgumentNullException"> Thrown when target is null. </exception>
762         public void PlayAnimateTo(View target)
763         {
764             if (target == null)
765             {
766                 throw new ArgumentNullException(nameof(target));
767             }
768
769             Clear();
770
771             if (null != propertyList && null != destValueList && null != startTimeList && null != endTimeList)
772             {
773                 if (propertyList.Count == destValueList.Count
774                     &&
775                     startTimeList.Count == endTimeList.Count
776                     &&
777                     propertyList.Count == startTimeList.Count)
778                 {
779                     int count = propertyList.Count;
780                     for (int index = 0; index < count; index++)
781                     {
782                         var elementType = target.GetType();
783                         PropertyInfo propertyInfo = elementType.GetProperties().FirstOrDefault(fi => fi.Name == propertyList[index]);
784
785                         if (propertyInfo != null)
786                         {
787                             object destinationValue = ConvertTo(destValueList[index], propertyInfo.PropertyType);
788
789                             if (destinationValue != null)
790                             {
791                                 AnimateTo(target, propertyList[index], destinationValue, startTimeList[index], endTimeList[index]);
792                             }
793                         }
794                     }
795                     Play();
796                 }
797             }
798             else
799             {
800                 if (_properties.Length == _destValue.Length && _startTime.Length == _endTime.Length && _properties.Length == _startTime.Length)
801                 {
802                     int length = _properties.Length;
803                     for (int index = 0; index < length; index++)
804                     {
805                         //object destinationValue = _destValue[index];
806                         var elementType = target.GetType();
807                         PropertyInfo propertyInfo = elementType.GetProperties().FirstOrDefault(fi => fi.Name == _properties[index]);
808                         //var propertyInfo = elementType.GetRuntimeProperties().FirstOrDefault(p => p.Name == localName);
809                         if (propertyInfo != null)
810                         {
811                             object destinationValue = ConvertTo(_destValue[index], propertyInfo.PropertyType);
812
813                             if (destinationValue != null)
814                             {
815                                 AnimateTo(target, _properties[index], destinationValue, _startTime[index], _endTime[index]);
816                             }
817                         }
818                     }
819                     Play();
820                 }
821             }
822         }
823
824         /// <summary>
825         /// Animates a property to a destination value.<br />
826         /// </summary>
827         /// <param name="target">The target object to animate.</param>
828         /// <param name="property">The target property to animate.</param>
829         /// <param name="destinationValue">The destination value.</param>
830         /// <param name="startTime">The start time of the animation.</param>
831         /// <param name="endTime">The end time of the animation.</param>
832         /// <param name="alphaFunction">The alpha function to apply.</param>
833         /// <exception cref="ArgumentNullException"> Thrown when target or property or destinationValue is null. </exception>
834         /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given destinationValue is invalid format. </exception>
835         /// <since_tizen> 3 </since_tizen>
836         public void AnimateTo(View target, string property, object destinationValue, int startTime, int endTime, AlphaFunction alphaFunction = null)
837         {
838             if (target == null)
839             {
840                 throw new ArgumentNullException(nameof(target));
841             }
842             if (property == null)
843             {
844                 throw new ArgumentNullException(nameof(property));
845             }
846             if (destinationValue == null)
847             {
848                 throw new ArgumentNullException(nameof(destinationValue));
849             }
850
851             using (var result = PropertyHelper.Search(target, property))
852             {
853                 if (result == null)
854                 {
855                     throw new ArgumentException("string property is invalid");
856                 }
857
858                 var current = result;
859                 using (var time = new TimePeriod(MilliSecondsToSeconds(startTime), MilliSecondsToSeconds(endTime - startTime)))
860                 while (current != null)
861                 {
862                     var targetValue = current.RefineValue(destinationValue) ?? throw new ArgumentException("Invalid " + nameof(destinationValue));
863                     AnimateTo(current.Property, targetValue, alphaFunction, time);
864                     targetValue.Dispose();
865                     current = current.NextResult;
866                 }
867             }
868         }
869
870         /// <summary>
871         /// Animates a property between keyframes.
872         /// </summary>
873         /// <param name="target">The target object to animate.</param>
874         /// <param name="property">The target property to animate.</param>
875         /// <param name="keyFrames">The set of time or value pairs between which to animate.</param>
876         /// <param name="interpolation">The method used to interpolate between values.</param>
877         /// <param name="alphaFunction">The alpha function to apply.</param>
878         /// <exception cref="ArgumentNullException"> Thrown when target or property or keyFrames is null. </exception>
879         /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given keyFrames has invalid value. </exception>
880         /// <since_tizen> 3 </since_tizen>
881         public void AnimateBetween(View target, string property, KeyFrames keyFrames, Interpolation interpolation = Interpolation.Linear, AlphaFunction alphaFunction = null)
882         {
883             if (target == null)
884             {
885                 throw new ArgumentNullException(nameof(target));
886             }
887             if (property == null)
888             {
889                 throw new ArgumentNullException(nameof(property));
890             }
891             if (keyFrames == null)
892             {
893                 throw new ArgumentNullException(nameof(keyFrames));
894             }
895
896             using (var result = PropertyHelper.Search(target, property))
897             {
898                 if (result == null)
899                 {
900                     throw new ArgumentException("string property is invalid");
901                 }
902
903                 var current = result;
904                 while (current != null)
905                 {
906                     // NOTE Do not dispose keyFrames object returned by GetRefinedKeyFrames() here.
907                     AnimateBetween(current.Property, current.RefineKeyFrames(keyFrames) ?? throw new ArgumentException("Invalid " + nameof(keyFrames)), alphaFunction, interpolation);   
908                     current = current.NextResult;
909                 }
910             }
911         }
912
913         /// <summary>
914         /// Animates a property between keyframes.
915         /// </summary>
916         /// <param name="target">The target object to animate</param>
917         /// <param name="property">The target property to animate</param>
918         /// <param name="keyFrames">The set of time/value pairs between which to animate</param>
919         /// <param name="startTime">The start time of animation in milliseconds.</param>
920         /// <param name="endTime">The end time of animation in milliseconds.</param>
921         /// <param name="interpolation">The method used to interpolate between values.</param>
922         /// <param name="alphaFunction">The alpha function to apply.</param>
923         /// <exception cref="ArgumentNullException"> Thrown when target or property or keyFrames is null. </exception>
924         /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given keyFrames has invalid value. </exception>
925         /// <since_tizen> 3 </since_tizen>
926         public void AnimateBetween(View target, string property, KeyFrames keyFrames, int startTime, int endTime, Interpolation interpolation = Interpolation.Linear, AlphaFunction alphaFunction = null)
927         {
928             if (target == null)
929             {
930                 throw new ArgumentNullException(nameof(target));
931             }
932             if (property == null)
933             {
934                 throw new ArgumentNullException(nameof(property));
935             }
936             if (keyFrames == null)
937             {
938                 throw new ArgumentNullException(nameof(keyFrames));
939             }
940
941             using (var result = PropertyHelper.Search(target, property))
942             {
943                 if (result == null)
944                 {
945                     throw new ArgumentException("string property is invalid");
946                 }
947
948                 var current = result;
949                 using (var time = new TimePeriod(MilliSecondsToSeconds(startTime), MilliSecondsToSeconds(endTime - startTime)))
950                 while (current != null)
951                 {
952                     // NOTE Do not dispose keyFrames object returned by GetRefinedKeyFrames() here.
953                     AnimateBetween(current.Property, current.RefineKeyFrames(keyFrames) ?? throw new ArgumentException("Invalid " + nameof(keyFrames)), alphaFunction, time, interpolation);   
954                     current = current.NextResult;
955                 }
956             }
957         }
958
959         /// <summary>
960         /// Animates the view's position and orientation through a predefined path.<br />
961         /// The view will rotate to orient the supplied forward vector with the path's tangent.<br />
962         /// If forward is the zero vector then no rotation will happen.<br />
963         /// </summary>
964         /// <param name="view">The view to animate.</param>
965         /// <param name="path">It defines position and orientation.</param>
966         /// <param name="forward">The vector (in local space coordinate system) will be oriented with the path's tangent direction.</param>
967         /// <param name="alphaFunction">The alpha function to apply.</param>
968         /// <since_tizen> 3 </since_tizen>
969         public void AnimatePath(View view, Path path, Vector3 forward, AlphaFunction alphaFunction = null)
970         {
971             if (alphaFunction == null)
972             {
973                 Animate(view, path, forward);
974             }
975             else
976             {
977                 Animate(view, path, forward, alphaFunction);
978             }
979         }
980
981         /// <summary>
982         /// Animates the view's position and orientation through a predefined path.<br />
983         /// The view will rotate to orient the supplied forward vector with the path's tangent.<br />
984         /// If forward is the zero vector then no rotation will happen.<br />
985         /// </summary>
986         /// <param name="view">The view to animate.</param>
987         /// <param name="path">It defines position and orientation.</param>
988         /// <param name="forward">The vector (in local space coordinate system) will be oriented with the path's tangent direction.</param>
989         /// <param name="startTime">The start time of the animation.</param>
990         /// <param name="endTime">The end time of the animation.</param>
991         /// <param name="alphaFunction">The alpha function to apply.</param>
992         /// <since_tizen> 3 </since_tizen>
993         public void AnimatePath(View view, Path path, Vector3 forward, int startTime, int endTime, AlphaFunction alphaFunction = null)
994         {
995             TimePeriod time = new TimePeriod(MilliSecondsToSeconds(startTime), MilliSecondsToSeconds(endTime - startTime));
996             if (alphaFunction == null)
997             {
998                 Animate(view, path, forward, time);
999             }
1000             else
1001             {
1002                 Animate(view, path, forward, alphaFunction, time);
1003             }
1004             time.Dispose();
1005         }
1006
1007         /// <summary>
1008         /// Creates an initialized animation.<br />
1009         /// The animation will not loop.<br />
1010         /// The default end action is "Cancel".<br />
1011         /// The default alpha function is linear.<br />
1012         /// </summary>
1013         /// <since_tizen> 3 </since_tizen>
1014         public Animation() : this(Interop.Animation.New(0.0f), true)
1015         {
1016             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1017         }
1018
1019         /// <summary>
1020         /// Plays the animation.
1021         /// </summary>
1022         /// <since_tizen> 3 </since_tizen>
1023         public void Play()
1024         {
1025             Interop.Animation.Play(SwigCPtr);
1026             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1027
1028             if (DisableAnimation == true)
1029                 Stop(EndActions.StopFinal);
1030         }
1031
1032         /// <summary>
1033         /// Plays the animation from a given point.<br />
1034         /// The progress must be in the 0-1 interval or in the play range interval if defined,
1035         /// otherwise, it will be ignored.<br />
1036         /// </summary>
1037         /// <param name="progress">A value between [0,1], or between the play range if specified, from where the animation should start playing.</param>
1038         /// <since_tizen> 3 </since_tizen>
1039         public void PlayFrom(float progress)
1040         {
1041             Interop.Animation.PlayFrom(SwigCPtr, progress);
1042             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1043         }
1044
1045         /// <summary>
1046         /// Plays the animation after a given delay time.<br/>
1047         /// The delay time is not included in the looping time.<br/>
1048         /// When the delay time is a negative value, it would treat as play immediately.<br/>
1049         /// </summary>
1050         /// <param name="delayMilliseconds">The delay time.</param>
1051         /// <since_tizen> 4 </since_tizen>
1052         public void PlayAfter(int delayMilliseconds)
1053         {
1054             Interop.Animation.PlayAfter(SwigCPtr, MilliSecondsToSeconds(delayMilliseconds));
1055             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1056         }
1057
1058         /// <summary>
1059         /// Pauses the animation.
1060         /// </summary>
1061         /// <since_tizen> 3 </since_tizen>
1062         public void Pause()
1063         {
1064             Interop.Animation.Pause(SwigCPtr);
1065             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1066         }
1067
1068         /// <summary>
1069         /// Stops the animation.
1070         /// </summary>
1071         /// <since_tizen> 3 </since_tizen>
1072         public void Stop()
1073         {
1074             Interop.Animation.Stop(SwigCPtr);
1075             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1076         }
1077
1078         /// <summary>
1079         /// Clears the animation.<br />
1080         /// This disconnects any objects that were being animated, effectively stopping the animation.<br />
1081         /// </summary>
1082         /// <since_tizen> 3 </since_tizen>
1083         public void Clear()
1084         {
1085             Interop.Animation.Clear(SwigCPtr);
1086             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1087         }
1088
1089         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Animation obj)
1090         {
1091             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
1092         }
1093
1094         internal object ConvertTo(object value, Type toType)
1095         {
1096             Func<object> getConverter = () =>
1097             {
1098                 string converterTypeName = GetTypeConverterTypeName(toType.GetTypeInfo().CustomAttributes);
1099                 if (converterTypeName == null)
1100                     return null;
1101
1102                 Type convertertype = Type.GetType(converterTypeName);
1103                 return Activator.CreateInstance(convertertype);
1104             };
1105
1106             return ConvertTo(value, toType, getConverter);
1107         }
1108
1109         internal object ConvertTo(object value, Type toType, Func<object> getConverter)
1110         {
1111             if (value == null)
1112                 return null;
1113
1114             var str = value as string;
1115             if (str != null)
1116             {
1117                 //If there's a [TypeConverter], use it
1118                 object converter = getConverter?.Invoke();
1119                 var xfTypeConverter = converter as Tizen.NUI.Binding.TypeConverter;
1120                 if (xfTypeConverter != null)
1121                     return value = xfTypeConverter.ConvertFromInvariantString(str);
1122                 var converterType = converter?.GetType();
1123                 if (converterType != null)
1124                 {
1125                     var convertFromStringInvariant = converterType.GetRuntimeMethod("ConvertFromInvariantString",
1126                         new[] { typeof(string) });
1127                     if (convertFromStringInvariant != null)
1128                         return value = convertFromStringInvariant.Invoke(converter, new object[] { str });
1129                 }
1130
1131                 //If the type is nullable, as the value is not null, it's safe to assume we want the built-in conversion
1132                 if (toType.GetTypeInfo().IsGenericType && toType.GetGenericTypeDefinition() == typeof(Nullable<>))
1133                     toType = Nullable.GetUnderlyingType(toType);
1134
1135                 //Obvious Built-in conversions
1136                 if (toType.GetTypeInfo().IsEnum)
1137                     return Enum.Parse(toType, str, true);
1138                 if (toType == typeof(SByte))
1139                     return SByte.Parse(str, CultureInfo.InvariantCulture);
1140                 if (toType == typeof(Int16))
1141                     return Int16.Parse(str, CultureInfo.InvariantCulture);
1142                 if (toType == typeof(Int32))
1143                     return Int32.Parse(str, CultureInfo.InvariantCulture);
1144                 if (toType == typeof(Int64))
1145                     return Int64.Parse(str, CultureInfo.InvariantCulture);
1146                 if (toType == typeof(Byte))
1147                     return Byte.Parse(str, CultureInfo.InvariantCulture);
1148                 if (toType == typeof(UInt16))
1149                     return UInt16.Parse(str, CultureInfo.InvariantCulture);
1150                 if (toType == typeof(UInt32))
1151                     return UInt32.Parse(str, CultureInfo.InvariantCulture);
1152                 if (toType == typeof(UInt64))
1153                     return UInt64.Parse(str, CultureInfo.InvariantCulture);
1154                 if (toType == typeof(Single))
1155                     return Single.Parse(str, CultureInfo.InvariantCulture);
1156                 if (toType == typeof(Double))
1157                     return Double.Parse(str, CultureInfo.InvariantCulture);
1158                 if (toType == typeof(Boolean))
1159                     return Boolean.Parse(str);
1160                 if (toType == typeof(TimeSpan))
1161                     return TimeSpan.Parse(str, CultureInfo.InvariantCulture);
1162                 if (toType == typeof(DateTime))
1163                     return DateTime.Parse(str, CultureInfo.InvariantCulture);
1164                 if (toType == typeof(Char))
1165                 {
1166                     char c = '\0';
1167                     _ = Char.TryParse(str, out c);
1168                     return c;
1169                 }
1170                 if (toType == typeof(String) && str.StartsWith("{}", StringComparison.Ordinal))
1171                     return str.Substring(2);
1172                 if (toType == typeof(String))
1173                     return value;
1174                 if (toType == typeof(Decimal))
1175                     return Decimal.Parse(str, CultureInfo.InvariantCulture);
1176             }
1177
1178             //if the value is not assignable and there's an implicit conversion, convert
1179             if (value != null && !toType.IsAssignableFrom(value.GetType()))
1180             {
1181                 var opImplicit = GetImplicitConversionOperator(value.GetType(), value.GetType(), toType)
1182                                  ?? GetImplicitConversionOperator(toType, value.GetType(), toType);
1183                 //var opImplicit = value.GetType().GetImplicitConversionOperator(fromType: value.GetType(), toType: toType)
1184                 //                ?? toType.GetImplicitConversionOperator(fromType: value.GetType(), toType: toType);
1185
1186                 if (opImplicit != null)
1187                 {
1188                     value = opImplicit.Invoke(null, new[] { value });
1189                     return value;
1190                 }
1191             }
1192
1193             return value;
1194         }
1195
1196         internal string GetTypeConverterTypeName(IEnumerable<CustomAttributeData> attributes)
1197         {
1198             var converterAttribute =
1199                 attributes.FirstOrDefault(cad => Tizen.NUI.Binding.TypeConverterAttribute.TypeConvertersType.Contains(cad.AttributeType.FullName));
1200             if (converterAttribute == null)
1201                 return null;
1202             if (converterAttribute.ConstructorArguments[0].ArgumentType == typeof(string))
1203                 return (string)converterAttribute.ConstructorArguments[0].Value;
1204             if (converterAttribute.ConstructorArguments[0].ArgumentType == typeof(Type))
1205                 return ((Type)converterAttribute.ConstructorArguments[0].Value).AssemblyQualifiedName;
1206             return null;
1207         }
1208
1209         internal MethodInfo GetImplicitConversionOperator(Type onType, Type fromType, Type toType)
1210         {
1211 #if NETSTANDARD1_0
1212             var mi = onType.GetRuntimeMethod("op_Implicit", new[] { fromType });
1213 #else
1214             var bindingFlags = BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy;
1215             var mi = onType.GetMethod("op_Implicit", bindingFlags, null, new[] { fromType }, null);
1216 #endif
1217             if (mi == null) return null;
1218             if (!mi.IsSpecialName) return null;
1219             if (!mi.IsPublic) return null;
1220             if (!mi.IsStatic) return null;
1221             if (!toType.IsAssignableFrom(mi.ReturnType)) return null;
1222
1223             return mi;
1224         }
1225
1226         internal Animation(float durationSeconds) : this(Interop.Animation.New(durationSeconds), true)
1227         {
1228             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1229
1230         }
1231
1232         internal Animation(Animation handle) : this(Interop.Animation.NewAnimation(Animation.getCPtr(handle)), true)
1233         {
1234             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1235         }
1236
1237         internal Animation Assign(Animation rhs)
1238         {
1239             Animation ret = new Animation(Interop.Animation.Assign(SwigCPtr, Animation.getCPtr(rhs)), false);
1240             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1241             return ret;
1242         }
1243
1244         internal void SetDuration(float seconds)
1245         {
1246             Interop.Animation.SetDuration(SwigCPtr, seconds);
1247             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1248         }
1249
1250         internal float GetDuration()
1251         {
1252             float ret = Interop.Animation.GetDuration(SwigCPtr);
1253             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1254             return ret;
1255         }
1256
1257         internal void SetLooping(bool looping)
1258         {
1259             Interop.Animation.SetLooping(SwigCPtr, looping);
1260             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1261         }
1262
1263         internal void SetLoopCount(int count)
1264         {
1265             Interop.Animation.SetLoopCount(SwigCPtr, count);
1266             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1267         }
1268
1269         internal int GetLoopCount()
1270         {
1271             int ret = Interop.Animation.GetLoopCount(SwigCPtr);
1272             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1273             return ret;
1274         }
1275
1276         internal int GetCurrentLoop()
1277         {
1278             int ret = Interop.Animation.GetCurrentLoop(SwigCPtr);
1279             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1280             return ret;
1281         }
1282
1283         internal bool IsLooping()
1284         {
1285             bool ret = Interop.Animation.IsLooping(SwigCPtr);
1286             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1287             return ret;
1288         }
1289
1290         internal void SetEndAction(Animation.EndActions action)
1291         {
1292             Interop.Animation.SetEndAction(SwigCPtr, (int)action);
1293             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1294         }
1295
1296         internal Animation.EndActions GetEndAction()
1297         {
1298             Animation.EndActions ret = (Animation.EndActions)Interop.Animation.GetEndAction(SwigCPtr);
1299             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1300             return ret;
1301         }
1302
1303         internal void SetDisconnectAction(Animation.EndActions disconnectAction)
1304         {
1305             Interop.Animation.SetDisconnectAction(SwigCPtr, (int)disconnectAction);
1306             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1307         }
1308
1309         internal Animation.EndActions GetDisconnectAction()
1310         {
1311             Animation.EndActions ret = (Animation.EndActions)Interop.Animation.GetDisconnectAction(SwigCPtr);
1312             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1313             return ret;
1314         }
1315
1316         internal void SetDefaultAlphaFunction(AlphaFunction alpha)
1317         {
1318             Interop.Animation.SetDefaultAlphaFunction(SwigCPtr, AlphaFunction.getCPtr(alpha));
1319             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1320         }
1321
1322         internal AlphaFunction GetDefaultAlphaFunction()
1323         {
1324             AlphaFunction ret = new AlphaFunction(Interop.Animation.GetDefaultAlphaFunction(SwigCPtr), true);
1325             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1326             return ret;
1327         }
1328
1329         internal void SetCurrentProgress(float progress)
1330         {
1331             Interop.Animation.SetCurrentProgress(SwigCPtr, progress);
1332             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1333         }
1334
1335         internal float GetCurrentProgress()
1336         {
1337             float ret = Interop.Animation.GetCurrentProgress(SwigCPtr);
1338             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1339             return ret;
1340         }
1341
1342         internal void SetSpeedFactor(float factor)
1343         {
1344             Interop.Animation.SetSpeedFactor(SwigCPtr, factor);
1345             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1346         }
1347
1348         internal float GetSpeedFactor()
1349         {
1350             float ret = Interop.Animation.GetSpeedFactor(SwigCPtr);
1351             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1352             return ret;
1353         }
1354
1355         internal void SetPlayRange(Vector2 range)
1356         {
1357             Interop.Animation.SetPlayRange(SwigCPtr, Vector2.getCPtr(range));
1358             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1359         }
1360
1361         internal Vector2 GetPlayRange()
1362         {
1363             Vector2 ret = new Vector2(Interop.Animation.GetPlayRange(SwigCPtr), true);
1364             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1365             return ret;
1366         }
1367
1368         internal Animation.States GetState()
1369         {
1370             Animation.States ret = (Animation.States)Interop.Animation.GetState(SwigCPtr);
1371             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1372             return ret;
1373         }
1374
1375         internal AnimationSignal FinishedSignal()
1376         {
1377             AnimationSignal ret = new AnimationSignal(Interop.Animation.FinishedSignal(SwigCPtr), false);
1378             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1379             return ret;
1380         }
1381
1382         internal AnimationSignal ProgressReachedSignal()
1383         {
1384             AnimationSignal ret = new AnimationSignal(Interop.Animation.ProgressReachedSignal(SwigCPtr), false);
1385             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1386             return ret;
1387         }
1388
1389         internal void AnimateBy(Property target, PropertyValue relativeValue, AlphaFunction alpha)
1390         {
1391             if (alpha == null)
1392             {
1393                 Interop.Animation.AnimateBy(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(relativeValue));
1394             }
1395             else
1396             {
1397                 Interop.Animation.AnimateByAlphaFunction(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(relativeValue), AlphaFunction.getCPtr(alpha));
1398             }
1399             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1400         }
1401
1402         internal void AnimateBy(Property target, PropertyValue relativeValue, AlphaFunction alpha, TimePeriod period)
1403         {
1404             if (alpha == null)
1405             {
1406                 Interop.Animation.AnimateByTimePeriod(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(relativeValue), TimePeriod.getCPtr(period));
1407             }
1408             else
1409             {
1410                 Interop.Animation.AnimateBy(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(relativeValue), AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period));
1411             }
1412             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1413         }
1414
1415         internal void AnimateTo(Property target, PropertyValue destinationValue, AlphaFunction alpha)
1416         {
1417             if (alpha == null)
1418             {
1419                 Interop.Animation.AnimateTo(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(destinationValue));
1420             }
1421             else
1422             {
1423                 Interop.Animation.AnimateToAlphaFunction(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(destinationValue), AlphaFunction.getCPtr(alpha));
1424             }
1425             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1426         }
1427
1428         internal void AnimateTo(Property target, PropertyValue destinationValue, AlphaFunction alpha, TimePeriod period)
1429         {
1430             if (alpha == null)
1431             {
1432                 Interop.Animation.AnimateToTimePeriod(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(destinationValue), TimePeriod.getCPtr(period));
1433             }
1434             else
1435             {
1436                 Interop.Animation.AnimateTo(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(destinationValue), AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period));
1437             }
1438             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1439         }
1440
1441         internal void AnimateBetween(Property target, KeyFrames keyFrames)
1442         {
1443             Interop.Animation.AnimateBetween(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames));
1444             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1445         }
1446
1447         internal void AnimateBetween(Property target, KeyFrames keyFrames, AlphaFunction alpha)
1448         {
1449             Interop.Animation.AnimateBetweenAlphaFunction(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), AlphaFunction.getCPtr(alpha));
1450             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1451         }
1452
1453         internal void AnimateBetween(Property target, KeyFrames keyFrames, AlphaFunction alpha, Animation.Interpolation interpolation)
1454         {
1455             if (alpha == null)
1456             {
1457                 Interop.Animation.AnimateBetween(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), (int)interpolation);
1458             }
1459             else
1460             {
1461                 Interop.Animation.AnimateBetweenAlphaFunctionInterpolation(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), AlphaFunction.getCPtr(alpha), (int)interpolation);
1462             }
1463             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1464         }
1465
1466         internal void AnimateBetween(Property target, KeyFrames keyFrames, TimePeriod period)
1467         {
1468             Interop.Animation.AnimateBetweenTimePeriod(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), TimePeriod.getCPtr(period));
1469             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1470         }
1471
1472         internal void AnimateBetween(Property target, KeyFrames keyFrames, AlphaFunction alpha, TimePeriod period)
1473         {
1474             Interop.Animation.AnimateBetween(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period));
1475             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1476         }
1477
1478         internal void AnimateBetween(Property target, KeyFrames keyFrames, AlphaFunction alpha, TimePeriod period, Animation.Interpolation interpolation)
1479         {
1480             if (alpha == null)
1481             {
1482                 Interop.Animation.AnimateBetweenTimePeriodInterpolation(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), TimePeriod.getCPtr(period), (int)interpolation);
1483             }
1484             else
1485             {
1486                 Interop.Animation.AnimateBetween(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period), (int)interpolation);
1487             }
1488             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1489         }
1490
1491         internal void Animate(View view, Path path, Vector3 forward)
1492         {
1493             Interop.Animation.Animate(SwigCPtr, View.getCPtr(view), Path.getCPtr(path), Vector3.getCPtr(forward));
1494             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1495         }
1496
1497         internal void Animate(View view, Path path, Vector3 forward, AlphaFunction alpha)
1498         {
1499             Interop.Animation.AnimateAlphaFunction(SwigCPtr, View.getCPtr(view), Path.getCPtr(path), Vector3.getCPtr(forward), AlphaFunction.getCPtr(alpha));
1500             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1501         }
1502
1503         internal void Animate(View view, Path path, Vector3 forward, TimePeriod period)
1504         {
1505             Interop.Animation.AnimateTimePeriod(SwigCPtr, View.getCPtr(view), Path.getCPtr(path), Vector3.getCPtr(forward), TimePeriod.getCPtr(period));
1506             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1507         }
1508
1509         internal void Animate(View view, Path path, Vector3 forward, AlphaFunction alpha, TimePeriod period)
1510         {
1511             Interop.Animation.Animate(SwigCPtr, View.getCPtr(view), Path.getCPtr(path), Vector3.getCPtr(forward), AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period));
1512             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1513         }
1514
1515         internal void Show(View view, float delaySeconds)
1516         {
1517             Interop.Animation.Show(SwigCPtr, View.getCPtr(view), delaySeconds);
1518             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1519         }
1520
1521         internal void Hide(View view, float delaySeconds)
1522         {
1523             Interop.Animation.Hide(SwigCPtr, View.getCPtr(view), delaySeconds);
1524             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1525         }
1526
1527         /// <summary>
1528         /// To make animation instance be disposed.
1529         /// </summary>
1530         /// <since_tizen> 3 </since_tizen>
1531         protected override void Dispose(DisposeTypes type)
1532         {
1533             if (disposed)
1534             {
1535                 return;
1536             }
1537
1538             if (_animationFinishedEventHandler != null)
1539             {
1540                 AnimationSignal finishedSignal = FinishedSignal();
1541                 finishedSignal?.Disconnect(_finishedCallbackOfNative);
1542                 finishedSignal?.Dispose();
1543                 _animationFinishedEventHandler = null;
1544             }
1545
1546             if (_animationProgressReachedEventCallback != null)
1547             {
1548                 AnimationSignal progressReachedSignal = ProgressReachedSignal();
1549                 progressReachedSignal?.Disconnect(_animationProgressReachedEventCallback);
1550                 progressReachedSignal?.Dispose();
1551                 _animationProgressReachedEventCallback = null;
1552             }
1553
1554             base.Dispose(type);
1555         }
1556
1557         /// This will not be public opened.
1558         [EditorBrowsable(EditorBrowsableState.Never)]
1559         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1560         {
1561             if (swigCPtr.Handle == IntPtr.Zero || this.HasBody() == false)
1562             {
1563                 Tizen.Log.Fatal("NUI", $"[ERROR] Animation ReleaseSwigCPtr()! IntPtr=0x{swigCPtr.Handle:X} HasBody={this.HasBody()}");
1564                 return;
1565             }
1566             Interop.Animation.DeleteAnimation(swigCPtr);
1567         }
1568
1569         private void OnFinished(IntPtr data)
1570         {
1571             if (_animationFinishedEventHandler != null)
1572             {
1573                 //here we send all data to user event handlers
1574                 _animationFinishedEventHandler(this, null);
1575             }
1576         }
1577
1578         private void OnProgressReached(IntPtr data)
1579         {
1580             if (_animationProgressReachedEventHandler != null)
1581             {
1582                 //here we send all data to user event handlers
1583                 _animationProgressReachedEventHandler(this, null);
1584             }
1585         }
1586
1587         private float MilliSecondsToSeconds(int millisec)
1588         {
1589             return (float)millisec / 1000.0f;
1590         }
1591
1592         private int SecondsToMilliSeconds(float sec)
1593         {
1594             return (int)(sec * 1000);
1595         }
1596     }
1597 }