2 * Copyright(c) 2021 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 using System.ComponentModel;
22 using System.Runtime.InteropServices;
23 using System.Collections.Generic;
25 using System.Reflection;
26 using System.Globalization;
27 using System.Diagnostics.CodeAnalysis;
29 using Tizen.NUI.BaseComponents;
32 /// Animation can be used to animate the properties of any number of objects, typically view.<br />
33 /// If the "Finished" event is connected to a member function of an object, it must be disconnected before the object is destroyed.<br />
34 /// This is typically done in the object destructor, and requires either the animation handle to be stored.<br />
35 /// 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 />
36 /// If any of the individual calls to those functions exceeds the overall animation time (Duration), then the overall animation time is automatically extended.<br />
38 /// <since_tizen> 3 </since_tizen>
39 public class Animation : BaseHandle
41 private static bool? disableAnimation = null;
43 private AnimationFinishedEventCallbackType animationFinishedEventCallback;
44 private System.IntPtr finishedCallbackOfNative;
46 private AnimationProgressReachedEventCallbackType animationProgressReachedEventCallback;
48 private string[] properties = null;
49 private string[] destValue = null;
50 private int[] startTime = null;
51 private int[] endTime = null;
53 private List<string> propertyList = null;
54 private List<string> destValueList = null;
55 private List<int> startTimeList = null;
56 private List<int> endTimeList = null;
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 />
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)
69 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
72 internal Animation(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
74 animationFinishedEventCallback = OnFinished;
75 finishedCallbackOfNative = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(animationFinishedEventCallback);
78 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
79 private delegate void AnimationFinishedEventCallbackType(IntPtr data);
81 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
82 private delegate void AnimationProgressReachedEventCallbackType(IntPtr data);
84 private event EventHandler animationFinishedEventHandler;
87 /// Event for the finished signal which can be used to subscribe or unsubscribe the event handler.<br />
88 /// The finished signal is emitted when an animation's animations have finished.<br />
90 /// <since_tizen> 3 </since_tizen>
91 public event EventHandler Finished
95 if (animationFinishedEventHandler == null && disposed == false)
97 AnimationSignal finishedSignal = FinishedSignal();
98 finishedSignal.Connect(finishedCallbackOfNative);
99 finishedSignal.Dispose();
101 animationFinishedEventHandler += value;
105 animationFinishedEventHandler -= value;
107 AnimationSignal finishedSignal = FinishedSignal();
108 if (animationFinishedEventHandler == null && finishedSignal.Empty() == false)
110 finishedSignal.Disconnect(finishedCallbackOfNative);
112 finishedSignal.Dispose();
116 private event EventHandler animationProgressReachedEventHandler;
119 /// Event for the ProgressReached signal, which can be used to subscribe or unsubscribe the event handler.<br />
120 /// The ProgressReached signal is emitted when the animation has reached a given progress percentage, this is set in the api SetProgressNotification.<br />
123 /// This value only be applied if animation state is Stopped.
125 /// <since_tizen> 3 </since_tizen>
126 public event EventHandler ProgressReached
130 if (animationProgressReachedEventHandler == null)
132 animationProgressReachedEventCallback = OnProgressReached;
133 AnimationSignal progressReachedSignal = ProgressReachedSignal();
134 progressReachedSignal?.Connect(animationProgressReachedEventCallback);
135 progressReachedSignal?.Dispose();
138 animationProgressReachedEventHandler += value;
142 animationProgressReachedEventHandler -= value;
144 AnimationSignal progressReachedSignal = ProgressReachedSignal();
145 if (animationProgressReachedEventHandler == null && progressReachedSignal?.Empty() == false)
147 progressReachedSignal?.Disconnect(animationProgressReachedEventCallback);
149 progressReachedSignal.Dispose();
154 /// Enumeration for what to do when the animation ends, stopped, or destroyed.
156 /// <since_tizen> 3 </since_tizen>
157 [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1717:Only FlagsAttribute enums should have plural names")]
158 public enum EndActions
161 /// When the animation ends, the animated property values are saved.
165 /// When the animation ends, the animated property values are forgotten.
169 /// If the animation is stopped, the animated property values are saved as if the animation had run to completion, otherwise behaves like cancel.
175 /// Enumeration for what interpolation method to use on key-frame animations.
177 /// <since_tizen> 3 </since_tizen>
178 public enum Interpolation
181 /// Values in between key frames are interpolated using a linear polynomial. (Default)
185 /// Values in between key frames are interpolated using a cubic polynomial.
191 /// Enumeration for what state the animation is in.
193 /// <remarks>Calling Reset() on this class will not reset the animation. It will call the BaseHandle.Reset() which drops the object handle.</remarks>
194 /// <since_tizen> 3 </since_tizen>
195 [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1717:Only FlagsAttribute enums should have plural names")]
199 /// The animation has stopped.
203 /// The animation is playing.
207 /// The animation is paused.
213 /// Enumeration for what looping mode is in.
215 /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
216 [EditorBrowsable(EditorBrowsableState.Never)]
217 [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1717:Only FlagsAttribute enums should have plural names")]
218 public enum LoopingModes
221 /// When the animation arrives at the end in looping mode, the animation restarts from the beginning. (Default)
223 /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
224 [EditorBrowsable(EditorBrowsableState.Never)]
227 /// When the animation arrives at the end in looping mode, the animation reverses direction and runs backwards again.
229 /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
230 [EditorBrowsable(EditorBrowsableState.Never)]
235 /// Gets or sets the duration in milliseconds of the animation.
236 /// This duration is applied to the animations are added after the Duration is set.
240 /// animation.AnimateTo(actor, "position", destination);
241 /// animation.Duration = 500; // This duration 500 is only applied to the size animation.
242 /// animation.AnimateTo(actor, "size", size);
245 /// <since_tizen> 3 </since_tizen>
250 SetDuration(MilliSecondsToSeconds(value));
254 return SecondsToMilliSeconds(GetDuration());
259 /// Gets or sets the default alpha function for the animation.
260 /// This DefaultAlphaFunction is only applied to the animations are added after the DefaultAlphaFunction is set.
264 /// animation.AnimateTo(actor, "position", destination);
265 /// animation.DefaultAlphaFunction = newAlphaFunction; // This newAlphaFunction is applied only for the size animation.
266 /// animation.AnimateTo(actor, "size", size);
269 /// <since_tizen> 3 </since_tizen>
270 public AlphaFunction DefaultAlphaFunction
274 SetDefaultAlphaFunction(value);
278 AlphaFunction ret = GetDefaultAlphaFunction();
284 /// Queries the state of the animation.
286 /// <since_tizen> 3 </since_tizen>
296 /// Set: Enables looping for a specified number of repeats. A zero is the same as Looping = true; i.e., repeat forever.<br />
297 /// This property resets the looping value and should not be used with the Looping property.<br />
298 /// Setting this parameter does not cause the animation to Play().<br />
299 /// Get: Gets the loop count. A zero is the same as Looping = true; i.e., repeat forever.<br />
300 /// The loop count is initially 1 for play once.<br />
302 /// <since_tizen> 3 </since_tizen>
311 int ret = GetLoopCount();
317 /// Gets or sets the status of whether the animation will loop.<br />
318 /// This property resets the loop count and should not be used with the LoopCount property.<br />
319 /// Setting this parameter does not cause the animation to Play().<br />
321 /// <since_tizen> 3 </since_tizen>
330 bool ret = IsLooping();
337 /// Gets or sets the end action of the animation.<br />
338 /// This action is performed when the animation ends or if it is stopped.<br />
339 /// The default end action is EndActions.Cancel.<br />
342 /// Change the action value from EndActions.Discard, or to EndActions.Discard during animation is playing / paused will not works well.
344 /// <since_tizen> 3 </since_tizen>
345 public EndActions EndAction
353 return GetEndAction();
358 /// Gets the current loop count.<br />
359 /// A value 0 indicating the current loop count when looping.<br />
361 /// <since_tizen> 3 </since_tizen>
362 public int CurrentLoop
366 return GetCurrentLoop();
371 /// Gets or sets the disconnect action.<br />
372 /// If any of the animated property owners are disconnected from the stage while the animation is being played, then this action is performed.<br />
373 /// The default action is EndActions.StopFinal.<br />
375 /// <since_tizen> 3 </since_tizen>
376 public EndActions DisconnectAction
380 Interop.Animation.SetDisconnectAction(SwigCPtr, (int)value);
381 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
385 Animation.EndActions ret = (Animation.EndActions)Interop.Animation.GetDisconnectAction(SwigCPtr);
386 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
393 /// Gets or sets the progress of the animation.<br />
394 /// The animation will play (or continue playing) from this point.<br />
395 /// The progress must be in the 0-1 interval or in the play range interval if defined<br />
396 /// otherwise, it will be ignored.<br />
398 /// <since_tizen> 3 </since_tizen>
399 public float CurrentProgress
403 Interop.Animation.SetCurrentProgress(SwigCPtr, value);
404 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
408 float ret = Interop.Animation.GetCurrentProgress(SwigCPtr);
409 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
415 /// Gets or sets specifications of a speed factor for the animation.<br />
416 /// The speed factor is a multiplier of the normal velocity of the animation.<br />
417 /// Values between [0, 1] will slow down the animation and values above one will speed up the animation.<br />
418 /// It is also possible to specify a negative multiplier to play the animation in reverse.<br />
420 /// <since_tizen> 3 </since_tizen>
421 public float SpeedFactor
425 Interop.Animation.SetSpeedFactor(SwigCPtr, value);
426 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
430 float ret = Interop.Animation.GetSpeedFactor(SwigCPtr);
431 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
437 /// Gets or sets the playing range.<br />
438 /// Animation will play between the values specified. Both values (range.x and range.y ) should be between 0-1,
439 /// otherwise they will be ignored. If the range provided is not in proper order (minimum, maximum ), it will be reordered.<br />
441 /// <since_tizen> 3 </since_tizen>
442 public RelativeVector2 PlayRange
446 Interop.Animation.SetPlayRange(SwigCPtr, Vector2.getCPtr(value));
447 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
451 Vector2 ret = new Vector2(Interop.Animation.GetPlayRange(SwigCPtr), true);
452 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
459 /// Gets or sets the progress notification marker which triggers the ProgressReachedSignal.<br />
460 /// Percentage of animation progress should be greater than 0 and less than 1, for example, 0.3 for 30%<br />
461 /// One notification can be set on each animation.
464 /// This value only be applied if animation state is Stopped.
466 /// <since_tizen> 3 </since_tizen>
467 public float ProgressNotification
471 Interop.Animation.SetProgressNotification(SwigCPtr, value);
472 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
476 float ret = Interop.Animation.GetProgressNotification(SwigCPtr);
477 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
483 /// Enumeration for what looping mode is in.
485 /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
486 [EditorBrowsable(EditorBrowsableState.Never)]
487 public LoopingModes LoopingMode
491 Interop.Animation.SetLoopingMode(SwigCPtr, (int)value);
492 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
496 Animation.LoopingModes ret = (Animation.LoopingModes)Interop.Animation.GetLoopingMode(SwigCPtr);
497 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
503 /// Gets or sets the properties of the animation.
505 //ToDo : will raise deprecated-ACR, [Obsolete("Deprecated in API9, will be removed in API11, Use PropertyList instead")]
506 [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "This API will be deprecated, so suppressing the warning for now")]
507 public string[] Properties
520 /// Gets or sets the destination value for each property of the animation.
522 //ToDo : will raise deprecated-ACR, [Obsolete("Deprecated in API9, will be removed in API11, Use DestValueList instead")]
523 [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "This API will be deprecated, so suppressing the warning for now")]
524 public string[] DestValue
537 /// Gets or sets the start time for each property of the animation.
539 //ToDo : will raise deprecated-ACR, [Obsolete("Deprecated in API9, will be removed in API11, Use StartTimeList instead")]
540 [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "This API will be deprecated, so suppressing the warning for now")]
541 public int[] StartTime
554 /// Gets or sets the end time for each property of the animation.
556 //ToDo : will raise deprecated-ACR, [Obsolete("Deprecated in API9, will be removed in API11, Use EndTimeList instead")]
557 [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "This API will be deprecated, so suppressing the warning for now")]
571 /// Get the list of the properties of the animation.
573 [EditorBrowsable(EditorBrowsableState.Never)]
574 public IList<string> PropertyList
578 if (null == propertyList)
580 propertyList = new List<string>();
588 /// Get the list of the destination value for each property of the animation.
590 [EditorBrowsable(EditorBrowsableState.Never)]
591 public IList<string> DestValueList
595 if (null == destValueList)
597 destValueList = new List<string>();
600 return destValueList;
605 /// Get the list of the start time for each property of the animation.
607 [EditorBrowsable(EditorBrowsableState.Never)]
608 public IList<int> StartTimeList
612 if (null == startTimeList)
614 startTimeList = new List<int>();
617 return startTimeList;
622 /// Get the list of end time for each property of the animation.
624 [EditorBrowsable(EditorBrowsableState.Never)]
625 public IList<int> EndTimeList
629 if (null == endTimeList)
631 endTimeList = new List<int>();
638 private bool DisableAnimation
642 if (disableAnimation.HasValue == false)
644 string type = Environment.GetEnvironmentVariable("PlatformSmartType");
646 disableAnimation = true;
648 disableAnimation = false;
650 return disableAnimation.Value;
655 /// Downcasts a handle to animation handle.<br />
656 /// If handle points to an animation object, the downcast produces a valid handle.<br />
657 /// If not, the returned handle is left uninitialized.<br />
659 /// <param name="handle">Handle to an object.</param>
660 /// <returns>Handle to an animation object or an uninitialized handle.</returns>
661 /// <exception cref="ArgumentNullException"> Thrown when handle is null. </exception>
662 internal static Animation DownCast(BaseHandle handle)
666 throw new ArgumentNullException(nameof(handle));
668 Animation ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as Animation;
669 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
674 /// Stops the animation. It will change this animation's EndAction property.
677 /// Change the value from EndActions.Discard, or to EndActions.Discard during animation is playing / paused will not works well.<br />
678 /// If you want to stop by EndActions.Discard, EndAction property also should be EndActions.Discard before Play API called.
680 /// <param name="action">The end action can be set.</param>
681 /// <since_tizen> 3 </since_tizen>
682 public void Stop(EndActions action)
684 SetEndAction(action);
685 Interop.Animation.Stop(SwigCPtr);
686 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
690 /// Animates a property value by a relative amount.<br />
692 /// <param name="target">The target animatable object to animate.</param>
693 /// <param name="property">The target property to animate.</param>
694 /// <param name="relativeValue">The property value will change by this amount.</param>
695 /// <param name="alphaFunction">The alpha function to apply.</param>
696 /// <exception cref="ArgumentNullException"> Thrown when target or property or relativeValue is null. </exception>
697 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given relativeValue is invalid format. </exception>
698 /// This will not be public opened.
699 [EditorBrowsable(EditorBrowsableState.Never)]
700 public void AnimateBy(Animatable target, string property, object relativeValue, AlphaFunction alphaFunction = null)
704 throw new ArgumentNullException(nameof(target));
706 if (property == null)
708 throw new ArgumentNullException(nameof(property));
710 if (relativeValue == null)
712 throw new ArgumentNullException(nameof(relativeValue));
715 using (var result = PropertyHelper.Search(target, property))
719 throw new ArgumentException("string property is invalid");
722 var current = result;
723 while (current != null)
726 var targetValueIntPtr = current.RefineValueIntPtr(relativeValue);
727 if (targetValueIntPtr == global::System.IntPtr.Zero)
729 throw new ArgumentException("Invalid " + nameof(relativeValue));
731 AnimateByIntPtr(current.Property, targetValueIntPtr, alphaFunction);
732 Interop.PropertyValue.DeletePropertyValueIntPtr(targetValueIntPtr);
733 current = current.NextResult;
739 /// Animates a property value by a relative amount.<br />
741 /// <param name="target">The target animatable object to animate.</param>
742 /// <param name="property">The target property to animate.</param>
743 /// <param name="relativeValue">The property value will change by this amount.</param>
744 /// <param name="startTime">The start time of the animation.</param>
745 /// <param name="endTime">The end time of the animation.</param>
746 /// <param name="alphaFunction">The alpha function to apply.</param>
747 /// <exception cref="ArgumentNullException"> Thrown when target or property or relativeValue is null. </exception>
748 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given relativeValue is invalid format. </exception>
749 /// This will not be public opened.
750 [EditorBrowsable(EditorBrowsableState.Never)]
751 public void AnimateBy(Animatable target, string property, object relativeValue, int startTime, int endTime, AlphaFunction alphaFunction = null)
755 throw new ArgumentNullException(nameof(target));
757 if (property == null)
759 throw new ArgumentNullException(nameof(property));
761 if (relativeValue == null)
763 throw new ArgumentNullException(nameof(relativeValue));
766 using (var result = PropertyHelper.Search(target, property))
770 throw new ArgumentException("string property is invalid");
773 var current = result;
774 using (var time = new TimePeriod(startTime, endTime - startTime))
775 while (current != null)
778 var targetValueIntPtr = current.RefineValueIntPtr(relativeValue);
779 if (targetValueIntPtr == global::System.IntPtr.Zero)
781 throw new ArgumentException("Invalid " + nameof(relativeValue));
783 AnimateByIntPtr(current.Property, targetValueIntPtr, alphaFunction, time);
784 Interop.PropertyValue.DeletePropertyValueIntPtr(targetValueIntPtr);
785 current = current.NextResult;
791 /// Animates a property value by a relative amount.<br />
793 /// <param name="target">The target object to animate.</param>
794 /// <param name="property">The target property to animate.</param>
795 /// <param name="relativeValue">The property value will change by this amount.</param>
796 /// <param name="alphaFunction">The alpha function to apply.</param>
797 /// <exception cref="ArgumentNullException"> Thrown when target or property or relativeValue is null. </exception>
798 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given relativeValue is invalid format. </exception>
799 /// <since_tizen> 3 </since_tizen>
800 public void AnimateBy(View target, string property, object relativeValue, AlphaFunction alphaFunction = null)
802 AnimateBy(target as Animatable, property, relativeValue, alphaFunction);
806 /// Animates a property value by a relative amount.<br />
808 /// <param name="target">The target object to animate.</param>
809 /// <param name="property">The target property to animate.</param>
810 /// <param name="relativeValue">The property value will change by this amount.</param>
811 /// <param name="startTime">The start time of the animation.</param>
812 /// <param name="endTime">The end time of the animation.</param>
813 /// <param name="alphaFunction">The alpha function to apply.</param>
814 /// <exception cref="ArgumentNullException"> Thrown when target or property or relativeValue is null. </exception>
815 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given relativeValue is invalid format. </exception>
816 /// <since_tizen> 3 </since_tizen>
817 public void AnimateBy(View target, string property, object relativeValue, int startTime, int endTime, AlphaFunction alphaFunction = null)
819 AnimateBy(target as Animatable, property, relativeValue, startTime, endTime, alphaFunction);
823 /// Animates a property to a destination value.<br />
825 /// <param name="target">The target animatable object to animate.</param>
826 /// <param name="property">The target property to animate.</param>
827 /// <param name="destinationValue">The destination value.</param>
828 /// <param name="alphaFunction">The alpha function to apply.</param>
829 /// <exception cref="ArgumentNullException"> Thrown when target or property or destinationValue is null. </exception>
830 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given destinationValue is invalid format. </exception>
831 /// This will not be public opened.
832 [EditorBrowsable(EditorBrowsableState.Never)]
833 public void AnimateTo(Animatable target, string property, object destinationValue, AlphaFunction alphaFunction = null)
837 throw new ArgumentNullException(nameof(target));
839 if (property == null)
841 throw new ArgumentNullException(nameof(property));
843 if (destinationValue == null)
845 throw new ArgumentNullException(nameof(destinationValue));
848 using (var result = PropertyHelper.Search(target, property))
852 throw new ArgumentException("string property is invalid");
855 var current = result;
856 while (current != null)
859 var targetValueIntPtr = current.RefineValueIntPtr(destinationValue);
860 if (targetValueIntPtr == global::System.IntPtr.Zero)
862 throw new ArgumentException("Invalid " + nameof(destinationValue));
864 AnimateToIntPtr(current.Property, targetValueIntPtr, alphaFunction);
865 Interop.PropertyValue.DeletePropertyValueIntPtr(targetValueIntPtr);
866 current = current.NextResult;
872 /// Animates a property to a destination value.<br />
874 /// <param name="target">The target animatable object to animate.</param>
875 /// <param name="property">The target property to animate.</param>
876 /// <param name="destinationValue">The destination value.</param>
877 /// <param name="startTime">The start time of the animation.</param>
878 /// <param name="endTime">The end time of the animation.</param>
879 /// <param name="alphaFunction">The alpha function to apply.</param>
880 /// <exception cref="ArgumentNullException"> Thrown when target or property or destinationValue is null. </exception>
881 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given destinationValue is invalid format. </exception>
882 /// This will not be public opened.
883 [EditorBrowsable(EditorBrowsableState.Never)]
884 public void AnimateTo(Animatable target, string property, object destinationValue, int startTime, int endTime, AlphaFunction alphaFunction = null)
888 throw new ArgumentNullException(nameof(target));
890 if (property == null)
892 throw new ArgumentNullException(nameof(property));
894 if (destinationValue == null)
896 throw new ArgumentNullException(nameof(destinationValue));
899 using (var result = PropertyHelper.Search(target, property))
903 throw new ArgumentException("string property is invalid");
906 var current = result;
907 using (var time = new TimePeriod(startTime, endTime - startTime))
908 while (current != null)
910 #if NUI_ANIMATION_PROPERTY_CHANGE_1
911 var targetValueIntPtr = current.RefineValueIntPtr(destinationValue);
912 if (targetValueIntPtr == global::System.IntPtr.Zero)
914 throw new ArgumentException("Invalid " + nameof(destinationValue));
916 AnimateToIntPtr(current.Property, targetValueIntPtr, alphaFunction, time);
917 Interop.PropertyValue.DeletePropertyValueIntPtr(targetValueIntPtr);
919 var targetValue = current.RefineValue(destinationValue) ?? throw new ArgumentException("Invalid " + nameof(destinationValue));
920 AnimateTo(current.Property, targetValue, alphaFunction, time);
921 targetValue.Dispose();
923 current = current.NextResult;
929 /// Animates a property to a destination value.<br />
931 /// <param name="target">The target object to animate.</param>
932 /// <param name="property">The target property to animate.</param>
933 /// <param name="destinationValue">The destination value.</param>
934 /// <param name="alphaFunction">The alpha function to apply.</param>
935 /// <exception cref="ArgumentNullException"> Thrown when target or property or destinationValue is null. </exception>
936 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given destinationValue is invalid format. </exception>
937 /// <since_tizen> 3 </since_tizen>
938 public void AnimateTo(View target, string property, object destinationValue, AlphaFunction alphaFunction = null)
940 AnimateTo(target as Animatable, property, destinationValue, alphaFunction);
944 /// Animates a property to a destination value.<br />
946 /// <param name="target">The target object to animate.</param>
947 /// <param name="property">The target property to animate.</param>
948 /// <param name="destinationValue">The destination value.</param>
949 /// <param name="startTime">The start time of the animation.</param>
950 /// <param name="endTime">The end time of the animation.</param>
951 /// <param name="alphaFunction">The alpha function to apply.</param>
952 /// <exception cref="ArgumentNullException"> Thrown when target or property or destinationValue is null. </exception>
953 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given destinationValue is invalid format. </exception>
954 /// <since_tizen> 3 </since_tizen>
955 public void AnimateTo(View target, string property, object destinationValue, int startTime, int endTime, AlphaFunction alphaFunction = null)
957 AnimateTo(target as Animatable, property, destinationValue, startTime, endTime, alphaFunction);
961 /// Animates one or more properties to a destination value.<br />
963 /// <param name="target">The target object to animate.</param>
964 /// <exception cref="ArgumentNullException"> Thrown when target is null. </exception>
965 public void PlayAnimateTo(View target)
969 throw new ArgumentNullException(nameof(target));
974 if (null != propertyList && null != destValueList && null != startTimeList && null != endTimeList)
976 if (propertyList.Count == destValueList.Count
978 startTimeList.Count == endTimeList.Count
980 propertyList.Count == startTimeList.Count)
982 int count = propertyList.Count;
983 for (int index = 0; index < count; index++)
985 var elementType = target.GetType();
986 PropertyInfo propertyInfo = elementType.GetProperties().FirstOrDefault(fi => fi.Name == propertyList[index]);
988 if (propertyInfo != null)
990 object destinationValue = ConvertTo(destValueList[index], propertyInfo.PropertyType);
992 if (destinationValue != null)
994 AnimateTo(target, propertyList[index], destinationValue, startTimeList[index], endTimeList[index]);
1003 if (properties.Length == destValue.Length && startTime.Length == endTime.Length && properties.Length == startTime.Length)
1005 int length = properties.Length;
1006 for (int index = 0; index < length; index++)
1008 //object destinationValue = _destValue[index];
1009 var elementType = target.GetType();
1010 PropertyInfo propertyInfo = elementType.GetProperties().FirstOrDefault(fi => fi.Name == properties[index]);
1011 //var propertyInfo = elementType.GetRuntimeProperties().FirstOrDefault(p => p.Name == localName);
1012 if (propertyInfo != null)
1014 object destinationValue = ConvertTo(destValue[index], propertyInfo.PropertyType);
1016 if (destinationValue != null)
1018 AnimateTo(target, properties[index], destinationValue, startTime[index], endTime[index]);
1028 /// Animates a property between keyframes.
1030 /// <param name="target">The target animatable object to animate.</param>
1031 /// <param name="property">The target property to animate.</param>
1032 /// <param name="keyFrames">The set of time or value pairs between which to animate.</param>
1033 /// <param name="interpolation">The method used to interpolate between values.</param>
1034 /// <param name="alphaFunction">The alpha function to apply.</param>
1035 /// <exception cref="ArgumentNullException"> Thrown when target or property or keyFrames is null. </exception>
1036 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given keyFrames has invalid value. </exception>
1037 /// This will not be public opened.
1038 [EditorBrowsable(EditorBrowsableState.Never)]
1039 public void AnimateBetween(Animatable target, string property, KeyFrames keyFrames, Interpolation interpolation = Interpolation.Linear, AlphaFunction alphaFunction = null)
1043 throw new ArgumentNullException(nameof(target));
1045 if (property == null)
1047 throw new ArgumentNullException(nameof(property));
1049 if (keyFrames == null)
1051 throw new ArgumentNullException(nameof(keyFrames));
1054 using (var result = PropertyHelper.Search(target, property))
1058 throw new ArgumentException("string property is invalid");
1061 var current = result;
1062 while (current != null)
1064 // NOTE Do not dispose keyFrames object returned by GetRefinedKeyFrames() here.
1065 AnimateBetween(current.Property, current.RefineKeyFrames(keyFrames) ?? throw new ArgumentException("Invalid " + nameof(keyFrames)), alphaFunction, interpolation);
1066 current = current.NextResult;
1072 /// Animates a property between keyframes.
1074 /// <param name="target">The target animatable object to animate</param>
1075 /// <param name="property">The target property to animate</param>
1076 /// <param name="keyFrames">The set of time/value pairs between which to animate</param>
1077 /// <param name="startTime">The start time of animation in milliseconds.</param>
1078 /// <param name="endTime">The end time of animation in milliseconds.</param>
1079 /// <param name="interpolation">The method used to interpolate between values.</param>
1080 /// <param name="alphaFunction">The alpha function to apply.</param>
1081 /// <exception cref="ArgumentNullException"> Thrown when target or property or keyFrames is null. </exception>
1082 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given keyFrames has invalid value. </exception>
1083 /// This will not be public opened.
1084 [EditorBrowsable(EditorBrowsableState.Never)]
1085 public void AnimateBetween(Animatable target, string property, KeyFrames keyFrames, int startTime, int endTime, Interpolation interpolation = Interpolation.Linear, AlphaFunction alphaFunction = null)
1089 throw new ArgumentNullException(nameof(target));
1091 if (property == null)
1093 throw new ArgumentNullException(nameof(property));
1095 if (keyFrames == null)
1097 throw new ArgumentNullException(nameof(keyFrames));
1100 using (var result = PropertyHelper.Search(target, property))
1104 throw new ArgumentException("string property is invalid");
1107 var current = result;
1108 using (var time = new TimePeriod(startTime, endTime - startTime))
1109 while (current != null)
1111 // NOTE Do not dispose keyFrames object returned by GetRefinedKeyFrames() here.
1112 AnimateBetween(current.Property, current.RefineKeyFrames(keyFrames) ?? throw new ArgumentException("Invalid " + nameof(keyFrames)), alphaFunction, time, interpolation);
1113 current = current.NextResult;
1119 /// Animates a property between keyframes.
1121 /// <param name="target">The target object to animate.</param>
1122 /// <param name="property">The target property to animate.</param>
1123 /// <param name="keyFrames">The set of time or value pairs between which to animate.</param>
1124 /// <param name="interpolation">The method used to interpolate between values.</param>
1125 /// <param name="alphaFunction">The alpha function to apply.</param>
1126 /// <exception cref="ArgumentNullException"> Thrown when target or property or keyFrames is null. </exception>
1127 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given keyFrames has invalid value. </exception>
1128 /// <since_tizen> 3 </since_tizen>
1129 public void AnimateBetween(View target, string property, KeyFrames keyFrames, Interpolation interpolation = Interpolation.Linear, AlphaFunction alphaFunction = null)
1131 AnimateBetween(target as Animatable, property, keyFrames, interpolation, alphaFunction);
1135 /// Animates a property between keyframes.
1137 /// <param name="target">The target object to animate</param>
1138 /// <param name="property">The target property to animate</param>
1139 /// <param name="keyFrames">The set of time/value pairs between which to animate</param>
1140 /// <param name="startTime">The start time of animation in milliseconds.</param>
1141 /// <param name="endTime">The end time of animation in milliseconds.</param>
1142 /// <param name="interpolation">The method used to interpolate between values.</param>
1143 /// <param name="alphaFunction">The alpha function to apply.</param>
1144 /// <exception cref="ArgumentNullException"> Thrown when target or property or keyFrames is null. </exception>
1145 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given keyFrames has invalid value. </exception>
1146 /// <since_tizen> 3 </since_tizen>
1147 public void AnimateBetween(View target, string property, KeyFrames keyFrames, int startTime, int endTime, Interpolation interpolation = Interpolation.Linear, AlphaFunction alphaFunction = null)
1149 AnimateBetween(target as Animatable, property, keyFrames, startTime, endTime, interpolation, alphaFunction);
1153 /// Animates the view's position and orientation through a predefined path.<br />
1154 /// The view will rotate to orient the supplied forward vector with the path's tangent.<br />
1155 /// If forward is the zero vector then no rotation will happen.<br />
1157 /// <param name="view">The view to animate.</param>
1158 /// <param name="path">It defines position and orientation.</param>
1159 /// <param name="forward">The vector (in local space coordinate system) will be oriented with the path's tangent direction.</param>
1160 /// <param name="alphaFunction">The alpha function to apply.</param>
1161 /// <since_tizen> 3 </since_tizen>
1162 public void AnimatePath(View view, Path path, Vector3 forward, AlphaFunction alphaFunction = null)
1164 if (alphaFunction == null)
1166 Animate(view, path, forward);
1170 Animate(view, path, forward, alphaFunction);
1175 /// Animates the view's position and orientation through a predefined path.<br />
1176 /// The view will rotate to orient the supplied forward vector with the path's tangent.<br />
1177 /// If forward is the zero vector then no rotation will happen.<br />
1179 /// <param name="view">The view to animate.</param>
1180 /// <param name="path">It defines position and orientation.</param>
1181 /// <param name="forward">The vector (in local space coordinate system) will be oriented with the path's tangent direction.</param>
1182 /// <param name="startTime">The start time of the animation.</param>
1183 /// <param name="endTime">The end time of the animation.</param>
1184 /// <param name="alphaFunction">The alpha function to apply.</param>
1185 /// <since_tizen> 3 </since_tizen>
1186 public void AnimatePath(View view, Path path, Vector3 forward, int startTime, int endTime, AlphaFunction alphaFunction = null)
1188 TimePeriod time = new TimePeriod(startTime, endTime - startTime);
1189 if (alphaFunction == null)
1191 Animate(view, path, forward, time);
1195 Animate(view, path, forward, alphaFunction, time);
1201 /// Creates an initialized animation.<br />
1202 /// The animation will not loop.<br />
1203 /// The default end action is "Cancel".<br />
1204 /// The default alpha function is linear.<br />
1206 /// <since_tizen> 3 </since_tizen>
1207 public Animation() : this(Interop.Animation.New(0.0f), true)
1209 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1213 /// Plays the animation.
1215 /// <since_tizen> 3 </since_tizen>
1218 Interop.Animation.Play(SwigCPtr);
1219 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1221 if (DisableAnimation == true)
1222 Stop(EndActions.StopFinal);
1226 /// Plays the animation from a given point.<br />
1227 /// The progress must be in the 0-1 interval or in the play range interval if defined,
1228 /// otherwise, it will be ignored.<br />
1230 /// <param name="progress">A value between [0,1], or between the play range if specified, from where the animation should start playing.</param>
1231 /// <since_tizen> 3 </since_tizen>
1232 public void PlayFrom(float progress)
1234 Interop.Animation.PlayFrom(SwigCPtr, progress);
1235 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1239 /// Plays the animation after a given delay time.<br/>
1240 /// The delay time is not included in the looping time.<br/>
1241 /// When the delay time is a negative value, it would treat as play immediately.<br/>
1243 /// <param name="delayMilliseconds">The delay time.</param>
1244 /// <since_tizen> 4 </since_tizen>
1245 public void PlayAfter(int delayMilliseconds)
1247 Interop.Animation.PlayAfter(SwigCPtr, MilliSecondsToSeconds(delayMilliseconds));
1248 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1252 /// Pauses the animation.
1254 /// <since_tizen> 3 </since_tizen>
1257 Interop.Animation.Pause(SwigCPtr);
1258 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1262 /// Stops the animation.
1264 /// <since_tizen> 3 </since_tizen>
1267 Interop.Animation.Stop(SwigCPtr);
1268 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1272 /// Clears the animation.<br />
1273 /// This disconnects any objects that were being animated, effectively stopping the animation.<br />
1275 /// <since_tizen> 3 </since_tizen>
1278 Interop.Animation.Clear(SwigCPtr);
1279 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1282 internal object ConvertTo(object value, Type toType)
1284 Func<object> getConverter = () =>
1286 string converterTypeName = GetTypeConverterTypeName(toType.GetTypeInfo().CustomAttributes);
1287 if (converterTypeName == null)
1290 Type convertertype = Type.GetType(converterTypeName);
1291 return Activator.CreateInstance(convertertype);
1294 return ConvertTo(value, toType, getConverter);
1297 internal object ConvertTo(object value, Type toType, Func<object> getConverter)
1302 var str = value as string;
1305 //If there's a [TypeConverter], use it
1306 object converter = getConverter?.Invoke();
1307 var xfTypeConverter = converter as Tizen.NUI.Binding.TypeConverter;
1308 if (xfTypeConverter != null)
1309 return value = xfTypeConverter.ConvertFromInvariantString(str);
1310 var converterType = converter?.GetType();
1311 if (converterType != null)
1313 var convertFromStringInvariant = converterType.GetRuntimeMethod("ConvertFromInvariantString",
1314 new[] { typeof(string) });
1315 if (convertFromStringInvariant != null)
1316 return value = convertFromStringInvariant.Invoke(converter, new object[] { str });
1319 //If the type is nullable, as the value is not null, it's safe to assume we want the built-in conversion
1320 if (toType.GetTypeInfo().IsGenericType && toType.GetGenericTypeDefinition() == typeof(Nullable<>))
1321 toType = Nullable.GetUnderlyingType(toType);
1323 //Obvious Built-in conversions
1324 if (toType.GetTypeInfo().IsEnum)
1325 return Enum.Parse(toType, str, true);
1326 if (toType == typeof(SByte))
1327 return SByte.Parse(str, CultureInfo.InvariantCulture);
1328 if (toType == typeof(Int16))
1329 return Int16.Parse(str, CultureInfo.InvariantCulture);
1330 if (toType == typeof(Int32))
1331 return Int32.Parse(str, CultureInfo.InvariantCulture);
1332 if (toType == typeof(Int64))
1333 return Int64.Parse(str, CultureInfo.InvariantCulture);
1334 if (toType == typeof(Byte))
1335 return Byte.Parse(str, CultureInfo.InvariantCulture);
1336 if (toType == typeof(UInt16))
1337 return UInt16.Parse(str, CultureInfo.InvariantCulture);
1338 if (toType == typeof(UInt32))
1339 return UInt32.Parse(str, CultureInfo.InvariantCulture);
1340 if (toType == typeof(UInt64))
1341 return UInt64.Parse(str, CultureInfo.InvariantCulture);
1342 if (toType == typeof(Single))
1343 return Single.Parse(str, CultureInfo.InvariantCulture);
1344 if (toType == typeof(Double))
1345 return Double.Parse(str, CultureInfo.InvariantCulture);
1346 if (toType == typeof(Boolean))
1347 return Boolean.Parse(str);
1348 if (toType == typeof(TimeSpan))
1349 return TimeSpan.Parse(str, CultureInfo.InvariantCulture);
1350 if (toType == typeof(DateTime))
1351 return DateTime.Parse(str, CultureInfo.InvariantCulture);
1352 if (toType == typeof(Char))
1355 _ = Char.TryParse(str, out c);
1358 if (toType == typeof(String) && str.StartsWith("{}", StringComparison.Ordinal))
1359 return str.Substring(2);
1360 if (toType == typeof(String))
1362 if (toType == typeof(Decimal))
1363 return Decimal.Parse(str, CultureInfo.InvariantCulture);
1366 //if the value is not assignable and there's an implicit conversion, convert
1367 if (value != null && !toType.IsAssignableFrom(value.GetType()))
1369 var opImplicit = GetImplicitConversionOperator(value.GetType(), value.GetType(), toType)
1370 ?? GetImplicitConversionOperator(toType, value.GetType(), toType);
1371 //var opImplicit = value.GetType().GetImplicitConversionOperator(fromType: value.GetType(), toType: toType)
1372 // ?? toType.GetImplicitConversionOperator(fromType: value.GetType(), toType: toType);
1374 if (opImplicit != null)
1376 value = opImplicit.Invoke(null, new[] { value });
1384 internal string GetTypeConverterTypeName(IEnumerable<CustomAttributeData> attributes)
1386 var converterAttribute =
1387 attributes.FirstOrDefault(cad => Tizen.NUI.Binding.TypeConverterAttribute.TypeConvertersType.Contains(cad.AttributeType.FullName));
1388 if (converterAttribute == null)
1390 if (converterAttribute.ConstructorArguments[0].ArgumentType == typeof(string))
1391 return (string)converterAttribute.ConstructorArguments[0].Value;
1392 if (converterAttribute.ConstructorArguments[0].ArgumentType == typeof(Type))
1393 return ((Type)converterAttribute.ConstructorArguments[0].Value).AssemblyQualifiedName;
1397 internal MethodInfo GetImplicitConversionOperator(Type onType, Type fromType, Type toType)
1400 var mi = onType.GetRuntimeMethod("op_Implicit", new[] { fromType });
1402 var bindingFlags = BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy;
1403 var mi = onType.GetMethod("op_Implicit", bindingFlags, null, new[] { fromType }, null);
1405 if (mi == null) return null;
1406 if (!mi.IsSpecialName) return null;
1407 if (!mi.IsPublic) return null;
1408 if (!mi.IsStatic) return null;
1409 if (!toType.IsAssignableFrom(mi.ReturnType)) return null;
1414 internal Animation(float durationSeconds) : this(Interop.Animation.New(durationSeconds), true)
1416 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1420 internal Animation(Animation handle) : this(Interop.Animation.NewAnimation(Animation.getCPtr(handle)), true)
1422 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1425 internal Animation Assign(Animation rhs)
1427 Animation ret = new Animation(Interop.Animation.Assign(SwigCPtr, Animation.getCPtr(rhs)), false);
1428 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1432 internal void SetDuration(float seconds)
1434 Interop.Animation.SetDuration(SwigCPtr, seconds);
1435 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1438 internal float GetDuration()
1440 float ret = Interop.Animation.GetDuration(SwigCPtr);
1441 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1445 internal void SetLooping(bool looping)
1447 Interop.Animation.SetLooping(SwigCPtr, looping);
1448 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1451 internal void SetLoopCount(int count)
1453 Interop.Animation.SetLoopCount(SwigCPtr, count);
1454 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1457 internal int GetLoopCount()
1459 int ret = Interop.Animation.GetLoopCount(SwigCPtr);
1460 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1464 internal int GetCurrentLoop()
1466 int ret = Interop.Animation.GetCurrentLoop(SwigCPtr);
1467 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1471 internal bool IsLooping()
1473 bool ret = Interop.Animation.IsLooping(SwigCPtr);
1474 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1478 internal void SetEndAction(Animation.EndActions action)
1480 Interop.Animation.SetEndAction(SwigCPtr, (int)action);
1481 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1484 internal Animation.EndActions GetEndAction()
1486 Animation.EndActions ret = (Animation.EndActions)Interop.Animation.GetEndAction(SwigCPtr);
1487 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1491 internal void SetDisconnectAction(Animation.EndActions disconnectAction)
1493 Interop.Animation.SetDisconnectAction(SwigCPtr, (int)disconnectAction);
1494 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1497 internal Animation.EndActions GetDisconnectAction()
1499 Animation.EndActions ret = (Animation.EndActions)Interop.Animation.GetDisconnectAction(SwigCPtr);
1500 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1504 internal void SetDefaultAlphaFunction(AlphaFunction alpha)
1506 Interop.Animation.SetDefaultAlphaFunction(SwigCPtr, AlphaFunction.getCPtr(alpha));
1507 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1510 internal AlphaFunction GetDefaultAlphaFunction()
1512 AlphaFunction ret = new AlphaFunction(Interop.Animation.GetDefaultAlphaFunction(SwigCPtr), true);
1513 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1517 internal void SetCurrentProgress(float progress)
1519 Interop.Animation.SetCurrentProgress(SwigCPtr, progress);
1520 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1523 internal float GetCurrentProgress()
1525 float ret = Interop.Animation.GetCurrentProgress(SwigCPtr);
1526 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1530 internal void SetSpeedFactor(float factor)
1532 Interop.Animation.SetSpeedFactor(SwigCPtr, factor);
1533 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1536 internal float GetSpeedFactor()
1538 float ret = Interop.Animation.GetSpeedFactor(SwigCPtr);
1539 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1543 internal void SetPlayRange(Vector2 range)
1545 Interop.Animation.SetPlayRange(SwigCPtr, Vector2.getCPtr(range));
1546 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1549 internal Vector2 GetPlayRange()
1551 Vector2 ret = new Vector2(Interop.Animation.GetPlayRange(SwigCPtr), true);
1552 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1556 internal Animation.States GetState()
1558 Animation.States ret = (Animation.States)Interop.Animation.GetState(SwigCPtr);
1559 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1563 internal AnimationSignal FinishedSignal()
1565 AnimationSignal ret = new AnimationSignal(Interop.Animation.FinishedSignal(SwigCPtr), false);
1566 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1570 internal AnimationSignal ProgressReachedSignal()
1572 AnimationSignal ret = new AnimationSignal(Interop.Animation.ProgressReachedSignal(SwigCPtr), false);
1573 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1577 internal void AnimateBy(Property target, PropertyValue relativeValue, AlphaFunction alpha)
1581 Interop.Animation.AnimateBy(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(relativeValue));
1585 Interop.Animation.AnimateByAlphaFunction(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(relativeValue), AlphaFunction.getCPtr(alpha));
1587 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1590 internal void AnimateBy(Property target, PropertyValue relativeValue, AlphaFunction alpha, TimePeriod period)
1594 Interop.Animation.AnimateByTimePeriod(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(relativeValue), TimePeriod.getCPtr(period));
1598 Interop.Animation.AnimateBy(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(relativeValue), AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period));
1600 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1603 internal void AnimateTo(Property target, PropertyValue destinationValue, AlphaFunction alpha)
1607 Interop.Animation.AnimateTo(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(destinationValue));
1611 Interop.Animation.AnimateToAlphaFunction(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(destinationValue), AlphaFunction.getCPtr(alpha));
1613 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1616 internal void AnimateTo(Property target, PropertyValue destinationValue, AlphaFunction alpha, TimePeriod period)
1620 Interop.Animation.AnimateToTimePeriod(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(destinationValue), TimePeriod.getCPtr(period));
1624 Interop.Animation.AnimateTo(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(destinationValue), AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period));
1626 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1630 internal void AnimateByIntPtr(Property target, global::System.IntPtr relativeValueIntPtr, AlphaFunction alpha)
1634 Interop.Animation.AnimateBy(SwigCPtr, Property.getCPtr(target), relativeValueIntPtr);
1638 Interop.Animation.AnimateByAlphaFunction(SwigCPtr, Property.getCPtr(target), relativeValueIntPtr, AlphaFunction.getCPtr(alpha));
1640 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1643 internal void AnimateByIntPtr(Property target, global::System.IntPtr relativeValueIntPtr, AlphaFunction alpha, TimePeriod period)
1647 Interop.Animation.AnimateByTimePeriod(SwigCPtr, Property.getCPtr(target), relativeValueIntPtr, TimePeriod.getCPtr(period));
1651 Interop.Animation.AnimateBy(SwigCPtr, Property.getCPtr(target), relativeValueIntPtr, AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period));
1653 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1656 internal void AnimateToIntPtr(Property target, global::System.IntPtr destinationValueIntPtr, AlphaFunction alpha)
1660 Interop.Animation.AnimateTo(SwigCPtr, Property.getCPtr(target), destinationValueIntPtr);
1664 Interop.Animation.AnimateToAlphaFunction(SwigCPtr, Property.getCPtr(target), destinationValueIntPtr, AlphaFunction.getCPtr(alpha));
1666 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1669 internal void AnimateToIntPtr(Property target, global::System.IntPtr destinationValueIntPtr, AlphaFunction alpha, TimePeriod period)
1673 Interop.Animation.AnimateToTimePeriod(SwigCPtr, Property.getCPtr(target), destinationValueIntPtr, TimePeriod.getCPtr(period));
1677 Interop.Animation.AnimateTo(SwigCPtr, Property.getCPtr(target), destinationValueIntPtr, AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period));
1679 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1682 internal void AnimateBetween(Property target, KeyFrames keyFrames)
1684 Interop.Animation.AnimateBetween(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames));
1685 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1688 internal void AnimateBetween(Property target, KeyFrames keyFrames, AlphaFunction alpha)
1690 Interop.Animation.AnimateBetweenAlphaFunction(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), AlphaFunction.getCPtr(alpha));
1691 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1694 internal void AnimateBetween(Property target, KeyFrames keyFrames, AlphaFunction alpha, Animation.Interpolation interpolation)
1698 Interop.Animation.AnimateBetween(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), (int)interpolation);
1702 Interop.Animation.AnimateBetweenAlphaFunctionInterpolation(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), AlphaFunction.getCPtr(alpha), (int)interpolation);
1704 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1707 internal void AnimateBetween(Property target, KeyFrames keyFrames, TimePeriod period)
1709 Interop.Animation.AnimateBetweenTimePeriod(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), TimePeriod.getCPtr(period));
1710 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1713 internal void AnimateBetween(Property target, KeyFrames keyFrames, AlphaFunction alpha, TimePeriod period)
1715 Interop.Animation.AnimateBetween(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period));
1716 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1719 internal void AnimateBetween(Property target, KeyFrames keyFrames, AlphaFunction alpha, TimePeriod period, Animation.Interpolation interpolation)
1723 Interop.Animation.AnimateBetweenTimePeriodInterpolation(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), TimePeriod.getCPtr(period), (int)interpolation);
1727 Interop.Animation.AnimateBetween(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period), (int)interpolation);
1729 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1732 internal void Animate(View view, Path path, Vector3 forward)
1734 Interop.Animation.Animate(SwigCPtr, View.getCPtr(view), Path.getCPtr(path), Vector3.getCPtr(forward));
1735 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1738 internal void Animate(View view, Path path, Vector3 forward, AlphaFunction alpha)
1740 Interop.Animation.AnimateAlphaFunction(SwigCPtr, View.getCPtr(view), Path.getCPtr(path), Vector3.getCPtr(forward), AlphaFunction.getCPtr(alpha));
1741 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1744 internal void Animate(View view, Path path, Vector3 forward, TimePeriod period)
1746 Interop.Animation.AnimateTimePeriod(SwigCPtr, View.getCPtr(view), Path.getCPtr(path), Vector3.getCPtr(forward), TimePeriod.getCPtr(period));
1747 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1750 internal void Animate(View view, Path path, Vector3 forward, AlphaFunction alpha, TimePeriod period)
1752 Interop.Animation.Animate(SwigCPtr, View.getCPtr(view), Path.getCPtr(path), Vector3.getCPtr(forward), AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period));
1753 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1756 internal void Show(View view, float delaySeconds)
1758 Interop.Animation.Show(SwigCPtr, View.getCPtr(view), delaySeconds);
1759 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1762 internal void Hide(View view, float delaySeconds)
1764 Interop.Animation.Hide(SwigCPtr, View.getCPtr(view), delaySeconds);
1765 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1769 /// To make animation instance be disposed.
1771 /// <since_tizen> 3 </since_tizen>
1772 protected override void Dispose(DisposeTypes type)
1779 if (animationFinishedEventHandler != null)
1781 AnimationSignal finishedSignal = FinishedSignal();
1782 finishedSignal?.Disconnect(finishedCallbackOfNative);
1783 finishedSignal?.Dispose();
1784 animationFinishedEventHandler = null;
1787 if (animationProgressReachedEventCallback != null)
1789 AnimationSignal progressReachedSignal = ProgressReachedSignal();
1790 progressReachedSignal?.Disconnect(animationProgressReachedEventCallback);
1791 progressReachedSignal?.Dispose();
1792 animationProgressReachedEventCallback = null;
1798 /// This will not be public opened.
1799 [EditorBrowsable(EditorBrowsableState.Never)]
1800 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1802 if (swigCPtr.Handle == IntPtr.Zero || Disposed)
1804 Tizen.Log.Fatal("NUI", $"[ERROR] Animation ReleaseSwigCPtr()! IntPtr=0x{swigCPtr.Handle:X} Disposed={Disposed}");
1807 Interop.Animation.DeleteAnimation(swigCPtr);
1810 private void OnFinished(IntPtr data)
1812 if (animationFinishedEventHandler != null)
1814 //here we send all data to user event handlers
1815 animationFinishedEventHandler(this, null);
1819 private void OnProgressReached(IntPtr data)
1821 if (animationProgressReachedEventHandler != null)
1823 //here we send all data to user event handlers
1824 animationProgressReachedEventHandler(this, null);
1828 private float MilliSecondsToSeconds(int millisec)
1830 return (float)millisec / 1000.0f;
1833 private int SecondsToMilliSeconds(float sec)
1835 return (int)(sec * 1000);