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