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 * @brief Event for the finished signal which can be used to subscribe or unsubscribe the event handler.
88 * The finished signal is emitted when an animation's animations have finished.
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 * @brief Event for the ProgressReached signal, which can be used to subscribe or unsubscribe the event handler.
120 * The ProgressReached signal is emitted when the animation has reached a given progress percentage, this is set in the api SetProgressNotification.
122 /// <since_tizen> 3 </since_tizen>
123 public event EventHandler ProgressReached
127 if (animationProgressReachedEventHandler == null)
129 animationProgressReachedEventCallback = OnProgressReached;
130 AnimationSignal progressReachedSignal = ProgressReachedSignal();
131 progressReachedSignal?.Connect(animationProgressReachedEventCallback);
132 progressReachedSignal?.Dispose();
135 animationProgressReachedEventHandler += value;
139 animationProgressReachedEventHandler -= value;
141 AnimationSignal progressReachedSignal = ProgressReachedSignal();
142 if (animationProgressReachedEventHandler == null && progressReachedSignal?.Empty() == false)
144 progressReachedSignal?.Disconnect(animationProgressReachedEventCallback);
146 progressReachedSignal.Dispose();
151 /// Enumeration for what to do when the animation ends, stopped, or destroyed.
153 /// <since_tizen> 3 </since_tizen>
154 [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1717:Only FlagsAttribute enums should have plural names")]
155 public enum EndActions
158 /// When the animation ends, the animated property values are saved.
162 /// When the animation ends, the animated property values are forgotten.
166 /// If the animation is stopped, the animated property values are saved as if the animation had run to completion, otherwise behaves like cancel.
172 /// Enumeration for what interpolation method to use on key-frame animations.
174 /// <since_tizen> 3 </since_tizen>
175 public enum Interpolation
178 /// Values in between key frames are interpolated using a linear polynomial. (Default)
182 /// Values in between key frames are interpolated using a cubic polynomial.
188 /// Enumeration for what state the animation is in.
190 /// <remarks>Calling Reset() on this class will not reset the animation. It will call the BaseHandle.Reset() which drops the object handle.</remarks>
191 /// <since_tizen> 3 </since_tizen>
192 [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1717:Only FlagsAttribute enums should have plural names")]
196 /// The animation has stopped.
200 /// The animation is playing.
204 /// The animation is paused.
210 /// Gets or sets the duration in milliseconds of the animation.
211 /// This duration is applied to the animations are added after the Duration is set.
215 /// animation.AnimateTo(actor, "position", destination);
216 /// animation.Duration = 500; // This duration 500 is only applied to the size animation.
217 /// animation.AnimateTo(actor, "size", size);
220 /// <since_tizen> 3 </since_tizen>
225 SetDuration(MilliSecondsToSeconds(value));
229 return SecondsToMilliSeconds(GetDuration());
234 /// Gets or sets the default alpha function for the animation.
235 /// This DefaultAlphaFunction is only applied to the animations are added after the DefaultAlphaFunction is set.
239 /// animation.AnimateTo(actor, "position", destination);
240 /// animation.DefaultAlphaFunction = newAlphaFunction; // This newAlphaFunction is applied only for the size animation.
241 /// animation.AnimateTo(actor, "size", size);
244 /// <since_tizen> 3 </since_tizen>
245 public AlphaFunction DefaultAlphaFunction
249 SetDefaultAlphaFunction(value);
253 AlphaFunction ret = GetDefaultAlphaFunction();
259 /// Queries the state of the animation.
261 /// <since_tizen> 3 </since_tizen>
271 /// Set: Enables looping for a specified number of repeats. A zero is the same as Looping = true; i.e., repeat forever.<br />
272 /// This property resets the looping value and should not be used with the Looping property.<br />
273 /// Setting this parameter does not cause the animation to Play().<br />
274 /// Get: Gets the loop count. A zero is the same as Looping = true; i.e., repeat forever.<br />
275 /// The loop count is initially 1 for play once.<br />
277 /// <since_tizen> 3 </since_tizen>
286 int ret = GetLoopCount();
292 /// Gets or sets the status of whether the animation will loop.<br />
293 /// This property resets the loop count and should not be used with the LoopCount property.<br />
294 /// Setting this parameter does not cause the animation to Play().<br />
296 /// <since_tizen> 3 </since_tizen>
305 bool ret = IsLooping();
312 /// Gets or sets the end action of the animation.<br />
313 /// This action is performed when the animation ends or if it is stopped.<br />
314 /// The default end action is cancel.<br />
316 /// <since_tizen> 3 </since_tizen>
317 public EndActions EndAction
325 return GetEndAction();
330 /// Gets the current loop count.<br />
331 /// A value 0 indicating the current loop count when looping.<br />
333 /// <since_tizen> 3 </since_tizen>
334 public int CurrentLoop
338 return GetCurrentLoop();
343 /// Gets or sets the disconnect action.<br />
344 /// If any of the animated property owners are disconnected from the stage while the animation is being played, then this action is performed.<br />
345 /// The default action is cancel.<br />
347 /// <since_tizen> 3 </since_tizen>
348 public EndActions DisconnectAction
352 Interop.Animation.SetDisconnectAction(SwigCPtr, (int)value);
353 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
357 Animation.EndActions ret = (Animation.EndActions)Interop.Animation.GetDisconnectAction(SwigCPtr);
358 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
365 /// Gets or sets the progress of the animation.<br />
366 /// The animation will play (or continue playing) from this point.<br />
367 /// The progress must be in the 0-1 interval or in the play range interval if defined<br />
368 /// otherwise, it will be ignored.<br />
370 /// <since_tizen> 3 </since_tizen>
371 public float CurrentProgress
375 Interop.Animation.SetCurrentProgress(SwigCPtr, value);
376 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
380 float ret = Interop.Animation.GetCurrentProgress(SwigCPtr);
381 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
387 /// Gets or sets specifications of a speed factor for the animation.<br />
388 /// The speed factor is a multiplier of the normal velocity of the animation.<br />
389 /// Values between [0, 1] will slow down the animation and values above one will speed up the animation.<br />
390 /// It is also possible to specify a negative multiplier to play the animation in reverse.<br />
392 /// <since_tizen> 3 </since_tizen>
393 public float SpeedFactor
397 Interop.Animation.SetSpeedFactor(SwigCPtr, value);
398 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
402 float ret = Interop.Animation.GetSpeedFactor(SwigCPtr);
403 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
409 /// Gets or sets the playing range.<br />
410 /// Animation will play between the values specified. Both values (range.x and range.y ) should be between 0-1,
411 /// otherwise they will be ignored. If the range provided is not in proper order (minimum, maximum ), it will be reordered.<br />
413 /// <since_tizen> 3 </since_tizen>
414 public RelativeVector2 PlayRange
418 Interop.Animation.SetPlayRange(SwigCPtr, Vector2.getCPtr(value));
419 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
423 Vector2 ret = new Vector2(Interop.Animation.GetPlayRange(SwigCPtr), true);
424 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
431 /// Gets or sets the progress notification marker which triggers the ProgressReachedSignal.<br />
432 /// Percentage of animation progress should be greater than 0 and less than 1, for example, 0.3 for 30% <br />
433 /// One notification can be set on each animation.
435 /// <since_tizen> 3 </since_tizen>
436 public float ProgressNotification
440 Interop.Animation.SetProgressNotification(SwigCPtr, value);
441 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
445 float ret = Interop.Animation.GetProgressNotification(SwigCPtr);
446 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
452 /// Gets or sets the properties of the animation.
454 //ToDo : will raise deprecated-ACR, [Obsolete("Deprecated in API9, will be removed in API11, Use PropertyList instead")]
455 [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "This API will be deprecated, so suppressing the warning for now")]
456 public string[] Properties
469 /// Gets or sets the destination value for each property of the animation.
471 //ToDo : will raise deprecated-ACR, [Obsolete("Deprecated in API9, will be removed in API11, Use DestValueList instead")]
472 [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "This API will be deprecated, so suppressing the warning for now")]
473 public string[] DestValue
486 /// Gets or sets the start time for each property of the animation.
488 //ToDo : will raise deprecated-ACR, [Obsolete("Deprecated in API9, will be removed in API11, Use StartTimeList instead")]
489 [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "This API will be deprecated, so suppressing the warning for now")]
490 public int[] StartTime
503 /// Gets or sets the end time for each property of the animation.
505 //ToDo : will raise deprecated-ACR, [Obsolete("Deprecated in API9, will be removed in API11, Use EndTimeList instead")]
506 [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "This API will be deprecated, so suppressing the warning for now")]
520 /// Get the list of the properties of the animation.
522 [EditorBrowsable(EditorBrowsableState.Never)]
523 public IList<string> PropertyList
527 if (null == propertyList)
529 propertyList = new List<string>();
537 /// Get the list of the destination value for each property of the animation.
539 [EditorBrowsable(EditorBrowsableState.Never)]
540 public IList<string> DestValueList
544 if (null == destValueList)
546 destValueList = new List<string>();
549 return destValueList;
554 /// Get the list of the start time for each property of the animation.
556 [EditorBrowsable(EditorBrowsableState.Never)]
557 public IList<int> StartTimeList
561 if (null == startTimeList)
563 startTimeList = new List<int>();
566 return startTimeList;
571 /// Get the list of end time for each property of the animation.
573 [EditorBrowsable(EditorBrowsableState.Never)]
574 public IList<int> EndTimeList
578 if (null == endTimeList)
580 endTimeList = new List<int>();
587 private bool DisableAnimation
591 if (disableAnimation.HasValue == false)
593 string type = Environment.GetEnvironmentVariable("PlatformSmartType");
595 disableAnimation = true;
597 disableAnimation = false;
599 return disableAnimation.Value;
604 /// Downcasts a handle to animation handle.<br />
605 /// If handle points to an animation object, the downcast produces a valid handle.<br />
606 /// If not, the returned handle is left uninitialized.<br />
608 /// <param name="handle">Handle to an object.</param>
609 /// <returns>Handle to an animation object or an uninitialized handle.</returns>
610 /// <exception cref="ArgumentNullException"> Thrown when handle is null. </exception>
611 internal static Animation DownCast(BaseHandle handle)
615 throw new ArgumentNullException(nameof(handle));
617 Animation ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as Animation;
618 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
623 /// Stops the animation.
625 /// <param name="action">The end action can be set.</param>
626 /// <since_tizen> 3 </since_tizen>
627 public void Stop(EndActions action = EndActions.Cancel)
629 SetEndAction(action);
630 Interop.Animation.Stop(SwigCPtr);
631 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
635 /// Animates a property value by a relative amount.<br />
637 /// <param name="target">The target animatable object to animate.</param>
638 /// <param name="property">The target property to animate.</param>
639 /// <param name="relativeValue">The property value will change by this amount.</param>
640 /// <param name="alphaFunction">The alpha function to apply.</param>
641 /// <exception cref="ArgumentNullException"> Thrown when target or property or relativeValue is null. </exception>
642 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given relativeValue is invalid format. </exception>
643 /// This will not be public opened.
644 [EditorBrowsable(EditorBrowsableState.Never)]
645 public void AnimateBy(Animatable target, string property, object relativeValue, AlphaFunction alphaFunction = null)
649 throw new ArgumentNullException(nameof(target));
651 if (property == null)
653 throw new ArgumentNullException(nameof(property));
655 if (relativeValue == null)
657 throw new ArgumentNullException(nameof(relativeValue));
660 using (var result = PropertyHelper.Search(target, property))
664 throw new ArgumentException("string property is invalid");
667 var current = result;
668 while (current != null)
671 var targetValueIntPtr = current.RefineValueIntPtr(relativeValue);
672 if (targetValueIntPtr == global::System.IntPtr.Zero)
674 throw new ArgumentException("Invalid " + nameof(relativeValue));
676 AnimateByIntPtr(current.Property, targetValueIntPtr, alphaFunction);
677 Interop.PropertyValue.DeletePropertyValueIntPtr(targetValueIntPtr);
678 current = current.NextResult;
684 /// Animates a property value by a relative amount.<br />
686 /// <param name="target">The target animatable object to animate.</param>
687 /// <param name="property">The target property to animate.</param>
688 /// <param name="relativeValue">The property value will change by this amount.</param>
689 /// <param name="startTime">The start time of the animation.</param>
690 /// <param name="endTime">The end time of the animation.</param>
691 /// <param name="alphaFunction">The alpha function to apply.</param>
692 /// <exception cref="ArgumentNullException"> Thrown when target or property or relativeValue is null. </exception>
693 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given relativeValue is invalid format. </exception>
694 /// This will not be public opened.
695 [EditorBrowsable(EditorBrowsableState.Never)]
696 public void AnimateBy(Animatable target, string property, object relativeValue, int startTime, int endTime, AlphaFunction alphaFunction = null)
700 throw new ArgumentNullException(nameof(target));
702 if (property == null)
704 throw new ArgumentNullException(nameof(property));
706 if (relativeValue == null)
708 throw new ArgumentNullException(nameof(relativeValue));
711 using (var result = PropertyHelper.Search(target, property))
715 throw new ArgumentException("string property is invalid");
718 var current = result;
719 using (var time = new TimePeriod(startTime, endTime - startTime))
720 while (current != null)
723 var targetValueIntPtr = current.RefineValueIntPtr(relativeValue);
724 if (targetValueIntPtr == global::System.IntPtr.Zero)
726 throw new ArgumentException("Invalid " + nameof(relativeValue));
728 AnimateByIntPtr(current.Property, targetValueIntPtr, alphaFunction, time);
729 Interop.PropertyValue.DeletePropertyValueIntPtr(targetValueIntPtr);
730 current = current.NextResult;
736 /// Animates a property value by a relative amount.<br />
738 /// <param name="target">The target object to animate.</param>
739 /// <param name="property">The target property to animate.</param>
740 /// <param name="relativeValue">The property value will change by this amount.</param>
741 /// <param name="alphaFunction">The alpha function to apply.</param>
742 /// <exception cref="ArgumentNullException"> Thrown when target or property or relativeValue is null. </exception>
743 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given relativeValue is invalid format. </exception>
744 /// <since_tizen> 3 </since_tizen>
745 public void AnimateBy(View target, string property, object relativeValue, AlphaFunction alphaFunction = null)
747 AnimateBy(target as Animatable, property, relativeValue, alphaFunction);
751 /// Animates a property value by a relative amount.<br />
753 /// <param name="target">The target object to animate.</param>
754 /// <param name="property">The target property to animate.</param>
755 /// <param name="relativeValue">The property value will change by this amount.</param>
756 /// <param name="startTime">The start time of the animation.</param>
757 /// <param name="endTime">The end time of the animation.</param>
758 /// <param name="alphaFunction">The alpha function to apply.</param>
759 /// <exception cref="ArgumentNullException"> Thrown when target or property or relativeValue is null. </exception>
760 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given relativeValue is invalid format. </exception>
761 /// <since_tizen> 3 </since_tizen>
762 public void AnimateBy(View target, string property, object relativeValue, int startTime, int endTime, AlphaFunction alphaFunction = null)
764 AnimateBy(target as Animatable, property, relativeValue, startTime, endTime, alphaFunction);
768 /// Animates a property to a destination value.<br />
770 /// <param name="target">The target animatable object to animate.</param>
771 /// <param name="property">The target property to animate.</param>
772 /// <param name="destinationValue">The destination value.</param>
773 /// <param name="alphaFunction">The alpha function to apply.</param>
774 /// <exception cref="ArgumentNullException"> Thrown when target or property or destinationValue is null. </exception>
775 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given destinationValue is invalid format. </exception>
776 /// This will not be public opened.
777 [EditorBrowsable(EditorBrowsableState.Never)]
778 public void AnimateTo(Animatable target, string property, object destinationValue, AlphaFunction alphaFunction = null)
782 throw new ArgumentNullException(nameof(target));
784 if (property == null)
786 throw new ArgumentNullException(nameof(property));
788 if (destinationValue == null)
790 throw new ArgumentNullException(nameof(destinationValue));
793 using (var result = PropertyHelper.Search(target, property))
797 throw new ArgumentException("string property is invalid");
800 var current = result;
801 while (current != null)
804 var targetValueIntPtr = current.RefineValueIntPtr(destinationValue);
805 if (targetValueIntPtr == global::System.IntPtr.Zero)
807 throw new ArgumentException("Invalid " + nameof(destinationValue));
809 AnimateToIntPtr(current.Property, targetValueIntPtr, alphaFunction);
810 Interop.PropertyValue.DeletePropertyValueIntPtr(targetValueIntPtr);
811 current = current.NextResult;
817 /// Animates a property to a destination value.<br />
819 /// <param name="target">The target animatable object to animate.</param>
820 /// <param name="property">The target property to animate.</param>
821 /// <param name="destinationValue">The destination value.</param>
822 /// <param name="startTime">The start time of the animation.</param>
823 /// <param name="endTime">The end time of the animation.</param>
824 /// <param name="alphaFunction">The alpha function to apply.</param>
825 /// <exception cref="ArgumentNullException"> Thrown when target or property or destinationValue is null. </exception>
826 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given destinationValue is invalid format. </exception>
827 /// This will not be public opened.
828 [EditorBrowsable(EditorBrowsableState.Never)]
829 public void AnimateTo(Animatable target, string property, object destinationValue, int startTime, int endTime, AlphaFunction alphaFunction = null)
833 throw new ArgumentNullException(nameof(target));
835 if (property == null)
837 throw new ArgumentNullException(nameof(property));
839 if (destinationValue == null)
841 throw new ArgumentNullException(nameof(destinationValue));
844 using (var result = PropertyHelper.Search(target, property))
848 throw new ArgumentException("string property is invalid");
851 var current = result;
852 using (var time = new TimePeriod(startTime, endTime - startTime))
853 while (current != null)
855 #if NUI_ANIMATION_PROPERTY_CHANGE_1
856 var targetValueIntPtr = current.RefineValueIntPtr(destinationValue);
857 if (targetValueIntPtr == global::System.IntPtr.Zero)
859 throw new ArgumentException("Invalid " + nameof(destinationValue));
861 AnimateToIntPtr(current.Property, targetValueIntPtr, alphaFunction, time);
862 Interop.PropertyValue.DeletePropertyValueIntPtr(targetValueIntPtr);
864 var targetValue = current.RefineValue(destinationValue) ?? throw new ArgumentException("Invalid " + nameof(destinationValue));
865 AnimateTo(current.Property, targetValue, alphaFunction, time);
866 targetValue.Dispose();
868 current = current.NextResult;
874 /// Animates a property to a destination value.<br />
876 /// <param name="target">The target object to animate.</param>
877 /// <param name="property">The target property to animate.</param>
878 /// <param name="destinationValue">The destination value.</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 /// <since_tizen> 3 </since_tizen>
883 public void AnimateTo(View target, string property, object destinationValue, AlphaFunction alphaFunction = null)
885 AnimateTo(target as Animatable, property, destinationValue, alphaFunction);
889 /// Animates a property to a destination value.<br />
891 /// <param name="target">The target object to animate.</param>
892 /// <param name="property">The target property to animate.</param>
893 /// <param name="destinationValue">The destination value.</param>
894 /// <param name="startTime">The start time of the animation.</param>
895 /// <param name="endTime">The end time of the animation.</param>
896 /// <param name="alphaFunction">The alpha function to apply.</param>
897 /// <exception cref="ArgumentNullException"> Thrown when target or property or destinationValue is null. </exception>
898 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given destinationValue is invalid format. </exception>
899 /// <since_tizen> 3 </since_tizen>
900 public void AnimateTo(View target, string property, object destinationValue, int startTime, int endTime, AlphaFunction alphaFunction = null)
902 AnimateTo(target as Animatable, property, destinationValue, startTime, endTime, alphaFunction);
906 /// Animates one or more properties to a destination value.<br />
908 /// <param name="target">The target object to animate.</param>
909 /// <exception cref="ArgumentNullException"> Thrown when target is null. </exception>
910 public void PlayAnimateTo(View target)
914 throw new ArgumentNullException(nameof(target));
919 if (null != propertyList && null != destValueList && null != startTimeList && null != endTimeList)
921 if (propertyList.Count == destValueList.Count
923 startTimeList.Count == endTimeList.Count
925 propertyList.Count == startTimeList.Count)
927 int count = propertyList.Count;
928 for (int index = 0; index < count; index++)
930 var elementType = target.GetType();
931 PropertyInfo propertyInfo = elementType.GetProperties().FirstOrDefault(fi => fi.Name == propertyList[index]);
933 if (propertyInfo != null)
935 object destinationValue = ConvertTo(destValueList[index], propertyInfo.PropertyType);
937 if (destinationValue != null)
939 AnimateTo(target, propertyList[index], destinationValue, startTimeList[index], endTimeList[index]);
948 if (properties.Length == destValue.Length && startTime.Length == endTime.Length && properties.Length == startTime.Length)
950 int length = properties.Length;
951 for (int index = 0; index < length; index++)
953 //object destinationValue = _destValue[index];
954 var elementType = target.GetType();
955 PropertyInfo propertyInfo = elementType.GetProperties().FirstOrDefault(fi => fi.Name == properties[index]);
956 //var propertyInfo = elementType.GetRuntimeProperties().FirstOrDefault(p => p.Name == localName);
957 if (propertyInfo != null)
959 object destinationValue = ConvertTo(destValue[index], propertyInfo.PropertyType);
961 if (destinationValue != null)
963 AnimateTo(target, properties[index], destinationValue, startTime[index], endTime[index]);
973 /// Animates a property between keyframes.
975 /// <param name="target">The target animatable object to animate.</param>
976 /// <param name="property">The target property to animate.</param>
977 /// <param name="keyFrames">The set of time or value pairs between which to animate.</param>
978 /// <param name="interpolation">The method used to interpolate between values.</param>
979 /// <param name="alphaFunction">The alpha function to apply.</param>
980 /// <exception cref="ArgumentNullException"> Thrown when target or property or keyFrames is null. </exception>
981 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given keyFrames has invalid value. </exception>
982 /// This will not be public opened.
983 [EditorBrowsable(EditorBrowsableState.Never)]
984 public void AnimateBetween(Animatable target, string property, KeyFrames keyFrames, Interpolation interpolation = Interpolation.Linear, AlphaFunction alphaFunction = null)
988 throw new ArgumentNullException(nameof(target));
990 if (property == null)
992 throw new ArgumentNullException(nameof(property));
994 if (keyFrames == null)
996 throw new ArgumentNullException(nameof(keyFrames));
999 using (var result = PropertyHelper.Search(target, property))
1003 throw new ArgumentException("string property is invalid");
1006 var current = result;
1007 while (current != null)
1009 // NOTE Do not dispose keyFrames object returned by GetRefinedKeyFrames() here.
1010 AnimateBetween(current.Property, current.RefineKeyFrames(keyFrames) ?? throw new ArgumentException("Invalid " + nameof(keyFrames)), alphaFunction, interpolation);
1011 current = current.NextResult;
1017 /// Animates a property between keyframes.
1019 /// <param name="target">The target animatable object to animate</param>
1020 /// <param name="property">The target property to animate</param>
1021 /// <param name="keyFrames">The set of time/value pairs between which to animate</param>
1022 /// <param name="startTime">The start time of animation in milliseconds.</param>
1023 /// <param name="endTime">The end time of animation in milliseconds.</param>
1024 /// <param name="interpolation">The method used to interpolate between values.</param>
1025 /// <param name="alphaFunction">The alpha function to apply.</param>
1026 /// <exception cref="ArgumentNullException"> Thrown when target or property or keyFrames is null. </exception>
1027 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given keyFrames has invalid value. </exception>
1028 /// This will not be public opened.
1029 [EditorBrowsable(EditorBrowsableState.Never)]
1030 public void AnimateBetween(Animatable target, string property, KeyFrames keyFrames, int startTime, int endTime, Interpolation interpolation = Interpolation.Linear, AlphaFunction alphaFunction = null)
1034 throw new ArgumentNullException(nameof(target));
1036 if (property == null)
1038 throw new ArgumentNullException(nameof(property));
1040 if (keyFrames == null)
1042 throw new ArgumentNullException(nameof(keyFrames));
1045 using (var result = PropertyHelper.Search(target, property))
1049 throw new ArgumentException("string property is invalid");
1052 var current = result;
1053 using (var time = new TimePeriod(startTime, endTime - startTime))
1054 while (current != null)
1056 // NOTE Do not dispose keyFrames object returned by GetRefinedKeyFrames() here.
1057 AnimateBetween(current.Property, current.RefineKeyFrames(keyFrames) ?? throw new ArgumentException("Invalid " + nameof(keyFrames)), alphaFunction, time, interpolation);
1058 current = current.NextResult;
1064 /// Animates a property between keyframes.
1066 /// <param name="target">The target object to animate.</param>
1067 /// <param name="property">The target property to animate.</param>
1068 /// <param name="keyFrames">The set of time or value pairs between which to animate.</param>
1069 /// <param name="interpolation">The method used to interpolate between values.</param>
1070 /// <param name="alphaFunction">The alpha function to apply.</param>
1071 /// <exception cref="ArgumentNullException"> Thrown when target or property or keyFrames is null. </exception>
1072 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given keyFrames has invalid value. </exception>
1073 /// <since_tizen> 3 </since_tizen>
1074 public void AnimateBetween(View target, string property, KeyFrames keyFrames, Interpolation interpolation = Interpolation.Linear, AlphaFunction alphaFunction = null)
1076 AnimateBetween(target as Animatable, property, keyFrames, interpolation, alphaFunction);
1080 /// Animates a property between keyframes.
1082 /// <param name="target">The target object to animate</param>
1083 /// <param name="property">The target property to animate</param>
1084 /// <param name="keyFrames">The set of time/value pairs between which to animate</param>
1085 /// <param name="startTime">The start time of animation in milliseconds.</param>
1086 /// <param name="endTime">The end time of animation in milliseconds.</param>
1087 /// <param name="interpolation">The method used to interpolate between values.</param>
1088 /// <param name="alphaFunction">The alpha function to apply.</param>
1089 /// <exception cref="ArgumentNullException"> Thrown when target or property or keyFrames is null. </exception>
1090 /// <exception cref="ArgumentException"> Thrown when it failed to find a property from given string or the given keyFrames has invalid value. </exception>
1091 /// <since_tizen> 3 </since_tizen>
1092 public void AnimateBetween(View target, string property, KeyFrames keyFrames, int startTime, int endTime, Interpolation interpolation = Interpolation.Linear, AlphaFunction alphaFunction = null)
1094 AnimateBetween(target as Animatable, property, keyFrames, startTime, endTime, interpolation, alphaFunction);
1098 /// Animates the view's position and orientation through a predefined path.<br />
1099 /// The view will rotate to orient the supplied forward vector with the path's tangent.<br />
1100 /// If forward is the zero vector then no rotation will happen.<br />
1102 /// <param name="view">The view to animate.</param>
1103 /// <param name="path">It defines position and orientation.</param>
1104 /// <param name="forward">The vector (in local space coordinate system) will be oriented with the path's tangent direction.</param>
1105 /// <param name="alphaFunction">The alpha function to apply.</param>
1106 /// <since_tizen> 3 </since_tizen>
1107 public void AnimatePath(View view, Path path, Vector3 forward, AlphaFunction alphaFunction = null)
1109 if (alphaFunction == null)
1111 Animate(view, path, forward);
1115 Animate(view, path, forward, alphaFunction);
1120 /// Animates the view's position and orientation through a predefined path.<br />
1121 /// The view will rotate to orient the supplied forward vector with the path's tangent.<br />
1122 /// If forward is the zero vector then no rotation will happen.<br />
1124 /// <param name="view">The view to animate.</param>
1125 /// <param name="path">It defines position and orientation.</param>
1126 /// <param name="forward">The vector (in local space coordinate system) will be oriented with the path's tangent direction.</param>
1127 /// <param name="startTime">The start time of the animation.</param>
1128 /// <param name="endTime">The end time of the animation.</param>
1129 /// <param name="alphaFunction">The alpha function to apply.</param>
1130 /// <since_tizen> 3 </since_tizen>
1131 public void AnimatePath(View view, Path path, Vector3 forward, int startTime, int endTime, AlphaFunction alphaFunction = null)
1133 TimePeriod time = new TimePeriod(startTime, endTime - startTime);
1134 if (alphaFunction == null)
1136 Animate(view, path, forward, time);
1140 Animate(view, path, forward, alphaFunction, time);
1146 /// Creates an initialized animation.<br />
1147 /// The animation will not loop.<br />
1148 /// The default end action is "Cancel".<br />
1149 /// The default alpha function is linear.<br />
1151 /// <since_tizen> 3 </since_tizen>
1152 public Animation() : this(Interop.Animation.New(0.0f), true)
1154 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1158 /// Plays the animation.
1160 /// <since_tizen> 3 </since_tizen>
1163 Interop.Animation.Play(SwigCPtr);
1164 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1166 if (DisableAnimation == true)
1167 Stop(EndActions.StopFinal);
1171 /// Plays the animation from a given point.<br />
1172 /// The progress must be in the 0-1 interval or in the play range interval if defined,
1173 /// otherwise, it will be ignored.<br />
1175 /// <param name="progress">A value between [0,1], or between the play range if specified, from where the animation should start playing.</param>
1176 /// <since_tizen> 3 </since_tizen>
1177 public void PlayFrom(float progress)
1179 Interop.Animation.PlayFrom(SwigCPtr, progress);
1180 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1184 /// Plays the animation after a given delay time.<br/>
1185 /// The delay time is not included in the looping time.<br/>
1186 /// When the delay time is a negative value, it would treat as play immediately.<br/>
1188 /// <param name="delayMilliseconds">The delay time.</param>
1189 /// <since_tizen> 4 </since_tizen>
1190 public void PlayAfter(int delayMilliseconds)
1192 Interop.Animation.PlayAfter(SwigCPtr, MilliSecondsToSeconds(delayMilliseconds));
1193 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1197 /// Pauses the animation.
1199 /// <since_tizen> 3 </since_tizen>
1202 Interop.Animation.Pause(SwigCPtr);
1203 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1207 /// Stops the animation.
1209 /// <since_tizen> 3 </since_tizen>
1212 Interop.Animation.Stop(SwigCPtr);
1213 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1217 /// Clears the animation.<br />
1218 /// This disconnects any objects that were being animated, effectively stopping the animation.<br />
1220 /// <since_tizen> 3 </since_tizen>
1223 Interop.Animation.Clear(SwigCPtr);
1224 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1227 internal object ConvertTo(object value, Type toType)
1229 Func<object> getConverter = () =>
1231 string converterTypeName = GetTypeConverterTypeName(toType.GetTypeInfo().CustomAttributes);
1232 if (converterTypeName == null)
1235 Type convertertype = Type.GetType(converterTypeName);
1236 return Activator.CreateInstance(convertertype);
1239 return ConvertTo(value, toType, getConverter);
1242 internal object ConvertTo(object value, Type toType, Func<object> getConverter)
1247 var str = value as string;
1250 //If there's a [TypeConverter], use it
1251 object converter = getConverter?.Invoke();
1252 var xfTypeConverter = converter as Tizen.NUI.Binding.TypeConverter;
1253 if (xfTypeConverter != null)
1254 return value = xfTypeConverter.ConvertFromInvariantString(str);
1255 var converterType = converter?.GetType();
1256 if (converterType != null)
1258 var convertFromStringInvariant = converterType.GetRuntimeMethod("ConvertFromInvariantString",
1259 new[] { typeof(string) });
1260 if (convertFromStringInvariant != null)
1261 return value = convertFromStringInvariant.Invoke(converter, new object[] { str });
1264 //If the type is nullable, as the value is not null, it's safe to assume we want the built-in conversion
1265 if (toType.GetTypeInfo().IsGenericType && toType.GetGenericTypeDefinition() == typeof(Nullable<>))
1266 toType = Nullable.GetUnderlyingType(toType);
1268 //Obvious Built-in conversions
1269 if (toType.GetTypeInfo().IsEnum)
1270 return Enum.Parse(toType, str, true);
1271 if (toType == typeof(SByte))
1272 return SByte.Parse(str, CultureInfo.InvariantCulture);
1273 if (toType == typeof(Int16))
1274 return Int16.Parse(str, CultureInfo.InvariantCulture);
1275 if (toType == typeof(Int32))
1276 return Int32.Parse(str, CultureInfo.InvariantCulture);
1277 if (toType == typeof(Int64))
1278 return Int64.Parse(str, CultureInfo.InvariantCulture);
1279 if (toType == typeof(Byte))
1280 return Byte.Parse(str, CultureInfo.InvariantCulture);
1281 if (toType == typeof(UInt16))
1282 return UInt16.Parse(str, CultureInfo.InvariantCulture);
1283 if (toType == typeof(UInt32))
1284 return UInt32.Parse(str, CultureInfo.InvariantCulture);
1285 if (toType == typeof(UInt64))
1286 return UInt64.Parse(str, CultureInfo.InvariantCulture);
1287 if (toType == typeof(Single))
1288 return Single.Parse(str, CultureInfo.InvariantCulture);
1289 if (toType == typeof(Double))
1290 return Double.Parse(str, CultureInfo.InvariantCulture);
1291 if (toType == typeof(Boolean))
1292 return Boolean.Parse(str);
1293 if (toType == typeof(TimeSpan))
1294 return TimeSpan.Parse(str, CultureInfo.InvariantCulture);
1295 if (toType == typeof(DateTime))
1296 return DateTime.Parse(str, CultureInfo.InvariantCulture);
1297 if (toType == typeof(Char))
1300 _ = Char.TryParse(str, out c);
1303 if (toType == typeof(String) && str.StartsWith("{}", StringComparison.Ordinal))
1304 return str.Substring(2);
1305 if (toType == typeof(String))
1307 if (toType == typeof(Decimal))
1308 return Decimal.Parse(str, CultureInfo.InvariantCulture);
1311 //if the value is not assignable and there's an implicit conversion, convert
1312 if (value != null && !toType.IsAssignableFrom(value.GetType()))
1314 var opImplicit = GetImplicitConversionOperator(value.GetType(), value.GetType(), toType)
1315 ?? GetImplicitConversionOperator(toType, value.GetType(), toType);
1316 //var opImplicit = value.GetType().GetImplicitConversionOperator(fromType: value.GetType(), toType: toType)
1317 // ?? toType.GetImplicitConversionOperator(fromType: value.GetType(), toType: toType);
1319 if (opImplicit != null)
1321 value = opImplicit.Invoke(null, new[] { value });
1329 internal string GetTypeConverterTypeName(IEnumerable<CustomAttributeData> attributes)
1331 var converterAttribute =
1332 attributes.FirstOrDefault(cad => Tizen.NUI.Binding.TypeConverterAttribute.TypeConvertersType.Contains(cad.AttributeType.FullName));
1333 if (converterAttribute == null)
1335 if (converterAttribute.ConstructorArguments[0].ArgumentType == typeof(string))
1336 return (string)converterAttribute.ConstructorArguments[0].Value;
1337 if (converterAttribute.ConstructorArguments[0].ArgumentType == typeof(Type))
1338 return ((Type)converterAttribute.ConstructorArguments[0].Value).AssemblyQualifiedName;
1342 internal MethodInfo GetImplicitConversionOperator(Type onType, Type fromType, Type toType)
1345 var mi = onType.GetRuntimeMethod("op_Implicit", new[] { fromType });
1347 var bindingFlags = BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy;
1348 var mi = onType.GetMethod("op_Implicit", bindingFlags, null, new[] { fromType }, null);
1350 if (mi == null) return null;
1351 if (!mi.IsSpecialName) return null;
1352 if (!mi.IsPublic) return null;
1353 if (!mi.IsStatic) return null;
1354 if (!toType.IsAssignableFrom(mi.ReturnType)) return null;
1359 internal Animation(float durationSeconds) : this(Interop.Animation.New(durationSeconds), true)
1361 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1365 internal Animation(Animation handle) : this(Interop.Animation.NewAnimation(Animation.getCPtr(handle)), true)
1367 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1370 internal Animation Assign(Animation rhs)
1372 Animation ret = new Animation(Interop.Animation.Assign(SwigCPtr, Animation.getCPtr(rhs)), false);
1373 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1377 internal void SetDuration(float seconds)
1379 Interop.Animation.SetDuration(SwigCPtr, seconds);
1380 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1383 internal float GetDuration()
1385 float ret = Interop.Animation.GetDuration(SwigCPtr);
1386 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1390 internal void SetLooping(bool looping)
1392 Interop.Animation.SetLooping(SwigCPtr, looping);
1393 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1396 internal void SetLoopCount(int count)
1398 Interop.Animation.SetLoopCount(SwigCPtr, count);
1399 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1402 internal int GetLoopCount()
1404 int ret = Interop.Animation.GetLoopCount(SwigCPtr);
1405 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1409 internal int GetCurrentLoop()
1411 int ret = Interop.Animation.GetCurrentLoop(SwigCPtr);
1412 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1416 internal bool IsLooping()
1418 bool ret = Interop.Animation.IsLooping(SwigCPtr);
1419 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1423 internal void SetEndAction(Animation.EndActions action)
1425 Interop.Animation.SetEndAction(SwigCPtr, (int)action);
1426 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1429 internal Animation.EndActions GetEndAction()
1431 Animation.EndActions ret = (Animation.EndActions)Interop.Animation.GetEndAction(SwigCPtr);
1432 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1436 internal void SetDisconnectAction(Animation.EndActions disconnectAction)
1438 Interop.Animation.SetDisconnectAction(SwigCPtr, (int)disconnectAction);
1439 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1442 internal Animation.EndActions GetDisconnectAction()
1444 Animation.EndActions ret = (Animation.EndActions)Interop.Animation.GetDisconnectAction(SwigCPtr);
1445 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1449 internal void SetDefaultAlphaFunction(AlphaFunction alpha)
1451 Interop.Animation.SetDefaultAlphaFunction(SwigCPtr, AlphaFunction.getCPtr(alpha));
1452 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1455 internal AlphaFunction GetDefaultAlphaFunction()
1457 AlphaFunction ret = new AlphaFunction(Interop.Animation.GetDefaultAlphaFunction(SwigCPtr), true);
1458 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1462 internal void SetCurrentProgress(float progress)
1464 Interop.Animation.SetCurrentProgress(SwigCPtr, progress);
1465 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1468 internal float GetCurrentProgress()
1470 float ret = Interop.Animation.GetCurrentProgress(SwigCPtr);
1471 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1475 internal void SetSpeedFactor(float factor)
1477 Interop.Animation.SetSpeedFactor(SwigCPtr, factor);
1478 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1481 internal float GetSpeedFactor()
1483 float ret = Interop.Animation.GetSpeedFactor(SwigCPtr);
1484 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1488 internal void SetPlayRange(Vector2 range)
1490 Interop.Animation.SetPlayRange(SwigCPtr, Vector2.getCPtr(range));
1491 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1494 internal Vector2 GetPlayRange()
1496 Vector2 ret = new Vector2(Interop.Animation.GetPlayRange(SwigCPtr), true);
1497 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1501 internal Animation.States GetState()
1503 Animation.States ret = (Animation.States)Interop.Animation.GetState(SwigCPtr);
1504 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1508 internal AnimationSignal FinishedSignal()
1510 AnimationSignal ret = new AnimationSignal(Interop.Animation.FinishedSignal(SwigCPtr), false);
1511 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1515 internal AnimationSignal ProgressReachedSignal()
1517 AnimationSignal ret = new AnimationSignal(Interop.Animation.ProgressReachedSignal(SwigCPtr), false);
1518 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1522 internal void AnimateBy(Property target, PropertyValue relativeValue, AlphaFunction alpha)
1526 Interop.Animation.AnimateBy(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(relativeValue));
1530 Interop.Animation.AnimateByAlphaFunction(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(relativeValue), AlphaFunction.getCPtr(alpha));
1532 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1535 internal void AnimateBy(Property target, PropertyValue relativeValue, AlphaFunction alpha, TimePeriod period)
1539 Interop.Animation.AnimateByTimePeriod(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(relativeValue), TimePeriod.getCPtr(period));
1543 Interop.Animation.AnimateBy(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(relativeValue), AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period));
1545 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1548 internal void AnimateTo(Property target, PropertyValue destinationValue, AlphaFunction alpha)
1552 Interop.Animation.AnimateTo(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(destinationValue));
1556 Interop.Animation.AnimateToAlphaFunction(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(destinationValue), AlphaFunction.getCPtr(alpha));
1558 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1561 internal void AnimateTo(Property target, PropertyValue destinationValue, AlphaFunction alpha, TimePeriod period)
1565 Interop.Animation.AnimateToTimePeriod(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(destinationValue), TimePeriod.getCPtr(period));
1569 Interop.Animation.AnimateTo(SwigCPtr, Property.getCPtr(target), PropertyValue.getCPtr(destinationValue), AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period));
1571 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1575 internal void AnimateByIntPtr(Property target, global::System.IntPtr relativeValueIntPtr, AlphaFunction alpha)
1579 Interop.Animation.AnimateBy(SwigCPtr, Property.getCPtr(target), relativeValueIntPtr);
1583 Interop.Animation.AnimateByAlphaFunction(SwigCPtr, Property.getCPtr(target), relativeValueIntPtr, AlphaFunction.getCPtr(alpha));
1585 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1588 internal void AnimateByIntPtr(Property target, global::System.IntPtr relativeValueIntPtr, AlphaFunction alpha, TimePeriod period)
1592 Interop.Animation.AnimateByTimePeriod(SwigCPtr, Property.getCPtr(target), relativeValueIntPtr, TimePeriod.getCPtr(period));
1596 Interop.Animation.AnimateBy(SwigCPtr, Property.getCPtr(target), relativeValueIntPtr, AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period));
1598 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1601 internal void AnimateToIntPtr(Property target, global::System.IntPtr destinationValueIntPtr, AlphaFunction alpha)
1605 Interop.Animation.AnimateTo(SwigCPtr, Property.getCPtr(target), destinationValueIntPtr);
1609 Interop.Animation.AnimateToAlphaFunction(SwigCPtr, Property.getCPtr(target), destinationValueIntPtr, AlphaFunction.getCPtr(alpha));
1611 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1614 internal void AnimateToIntPtr(Property target, global::System.IntPtr destinationValueIntPtr, AlphaFunction alpha, TimePeriod period)
1618 Interop.Animation.AnimateToTimePeriod(SwigCPtr, Property.getCPtr(target), destinationValueIntPtr, TimePeriod.getCPtr(period));
1622 Interop.Animation.AnimateTo(SwigCPtr, Property.getCPtr(target), destinationValueIntPtr, AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period));
1624 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1627 internal void AnimateBetween(Property target, KeyFrames keyFrames)
1629 Interop.Animation.AnimateBetween(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames));
1630 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1633 internal void AnimateBetween(Property target, KeyFrames keyFrames, AlphaFunction alpha)
1635 Interop.Animation.AnimateBetweenAlphaFunction(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), AlphaFunction.getCPtr(alpha));
1636 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1639 internal void AnimateBetween(Property target, KeyFrames keyFrames, AlphaFunction alpha, Animation.Interpolation interpolation)
1643 Interop.Animation.AnimateBetween(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), (int)interpolation);
1647 Interop.Animation.AnimateBetweenAlphaFunctionInterpolation(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), AlphaFunction.getCPtr(alpha), (int)interpolation);
1649 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1652 internal void AnimateBetween(Property target, KeyFrames keyFrames, TimePeriod period)
1654 Interop.Animation.AnimateBetweenTimePeriod(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), TimePeriod.getCPtr(period));
1655 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1658 internal void AnimateBetween(Property target, KeyFrames keyFrames, AlphaFunction alpha, TimePeriod period)
1660 Interop.Animation.AnimateBetween(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period));
1661 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1664 internal void AnimateBetween(Property target, KeyFrames keyFrames, AlphaFunction alpha, TimePeriod period, Animation.Interpolation interpolation)
1668 Interop.Animation.AnimateBetweenTimePeriodInterpolation(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), TimePeriod.getCPtr(period), (int)interpolation);
1672 Interop.Animation.AnimateBetween(SwigCPtr, Property.getCPtr(target), KeyFrames.getCPtr(keyFrames), AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period), (int)interpolation);
1674 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1677 internal void Animate(View view, Path path, Vector3 forward)
1679 Interop.Animation.Animate(SwigCPtr, View.getCPtr(view), Path.getCPtr(path), Vector3.getCPtr(forward));
1680 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1683 internal void Animate(View view, Path path, Vector3 forward, AlphaFunction alpha)
1685 Interop.Animation.AnimateAlphaFunction(SwigCPtr, View.getCPtr(view), Path.getCPtr(path), Vector3.getCPtr(forward), AlphaFunction.getCPtr(alpha));
1686 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1689 internal void Animate(View view, Path path, Vector3 forward, TimePeriod period)
1691 Interop.Animation.AnimateTimePeriod(SwigCPtr, View.getCPtr(view), Path.getCPtr(path), Vector3.getCPtr(forward), TimePeriod.getCPtr(period));
1692 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1695 internal void Animate(View view, Path path, Vector3 forward, AlphaFunction alpha, TimePeriod period)
1697 Interop.Animation.Animate(SwigCPtr, View.getCPtr(view), Path.getCPtr(path), Vector3.getCPtr(forward), AlphaFunction.getCPtr(alpha), TimePeriod.getCPtr(period));
1698 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1701 internal void Show(View view, float delaySeconds)
1703 Interop.Animation.Show(SwigCPtr, View.getCPtr(view), delaySeconds);
1704 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1707 internal void Hide(View view, float delaySeconds)
1709 Interop.Animation.Hide(SwigCPtr, View.getCPtr(view), delaySeconds);
1710 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1714 /// To make animation instance be disposed.
1716 /// <since_tizen> 3 </since_tizen>
1717 protected override void Dispose(DisposeTypes type)
1724 if (animationFinishedEventHandler != null)
1726 AnimationSignal finishedSignal = FinishedSignal();
1727 finishedSignal?.Disconnect(finishedCallbackOfNative);
1728 finishedSignal?.Dispose();
1729 animationFinishedEventHandler = null;
1732 if (animationProgressReachedEventCallback != null)
1734 AnimationSignal progressReachedSignal = ProgressReachedSignal();
1735 progressReachedSignal?.Disconnect(animationProgressReachedEventCallback);
1736 progressReachedSignal?.Dispose();
1737 animationProgressReachedEventCallback = null;
1743 /// This will not be public opened.
1744 [EditorBrowsable(EditorBrowsableState.Never)]
1745 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1747 if (swigCPtr.Handle == IntPtr.Zero || this.HasBody() == false)
1749 Tizen.Log.Fatal("NUI", $"[ERROR] Animation ReleaseSwigCPtr()! IntPtr=0x{swigCPtr.Handle:X} HasBody={this.HasBody()}");
1752 Interop.Animation.DeleteAnimation(swigCPtr);
1755 private void OnFinished(IntPtr data)
1757 if (animationFinishedEventHandler != null)
1759 //here we send all data to user event handlers
1760 animationFinishedEventHandler(this, null);
1764 private void OnProgressReached(IntPtr data)
1766 if (animationProgressReachedEventHandler != null)
1768 //here we send all data to user event handlers
1769 animationProgressReachedEventHandler(this, null);
1773 private float MilliSecondsToSeconds(int millisec)
1775 return (float)millisec / 1000.0f;
1778 private int SecondsToMilliSeconds(float sec)
1780 return (int)(sec * 1000);