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