1 using System.Collections.Generic;
2 using System.ComponentModel;
5 using System.Reflection;
6 using Tizen.NUI.BaseComponents;
7 using Tizen.NUI.Binding;
9 using static Tizen.NUI.Animation;
13 /// <since_tizen> 5 </since_tizen>
14 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
15 [EditorBrowsable(EditorBrowsableState.Never)]
16 public class AnimationBehavior
18 private string _key = null;
19 /// <since_tizen> 5 </since_tizen>
20 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
21 [EditorBrowsable(EditorBrowsableState.Never)]
34 private string _property = null;
36 /// <since_tizen> 5 </since_tizen>
37 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
38 [EditorBrowsable(EditorBrowsableState.Never)]
39 public string Property
51 private string _destValue = null;
53 /// <since_tizen> 5 </since_tizen>
54 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
55 [EditorBrowsable(EditorBrowsableState.Never)]
56 public string DestValue
68 private int _startTime = -1;
70 /// <since_tizen> 5 </since_tizen>
71 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
72 [EditorBrowsable(EditorBrowsableState.Never)]
85 private int _endTime = -1;
87 /// <since_tizen> 5 </since_tizen>
88 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
89 [EditorBrowsable(EditorBrowsableState.Never)]
103 /// <since_tizen> 5 </since_tizen>
104 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
105 [EditorBrowsable(EditorBrowsableState.Never)]
106 public class Transition : Animation
110 /// <since_tizen> 5 </since_tizen>
111 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
112 [EditorBrowsable(EditorBrowsableState.Never)]
125 private Dictionary<string, AnimationBehavior> behaviors = new Dictionary<string, AnimationBehavior>();
127 /// <since_tizen> 5 </since_tizen>
128 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
129 [EditorBrowsable(EditorBrowsableState.Never)]
130 public AnimationBehavior[] Behaviors
136 foreach (AnimationBehavior behavior in value)
138 behaviors.Add(behavior.Key, behavior);
144 /// <since_tizen> 5 </since_tizen>
145 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
146 [EditorBrowsable(EditorBrowsableState.Never)]
147 public void AnimateTo(View instance, string behaviorKey)
149 AnimationBehavior behavior = null;
150 behaviors.TryGetValue(behaviorKey, out behavior);
152 if (null != behavior)
154 var elementType = instance.GetType();
155 PropertyInfo propertyInfo = elementType.GetProperties().FirstOrDefault(fi => fi.Name == behavior.Property);
157 if (propertyInfo != null)
159 object destinationValue = ConvertTo(behavior.DestValue, propertyInfo.PropertyType);
161 if (destinationValue != null)
163 if (0 <= behavior.StartTime)
165 AnimateTo(instance, behavior.Property, destinationValue, behavior.StartTime, behavior.EndTime);
169 AnimateTo(instance, behavior.Property, destinationValue);
176 throw new XamlParseException(string.Format("Behaviors don't have key {0}", behaviorKey), new XmlLineInfo());
180 /// <since_tizen> 5 </since_tizen>
181 /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
182 [EditorBrowsable(EditorBrowsableState.Never)]
183 public void AnimateBy(View instance, string behaviorKey)
185 AnimationBehavior behavior = null;
186 behaviors.TryGetValue(behaviorKey, out behavior);
188 if (null != behavior)
190 var elementType = instance.GetType();
191 PropertyInfo propertyInfo = elementType.GetProperties().FirstOrDefault(fi => fi.Name == behavior.Property);
193 if (propertyInfo != null)
195 object destinationValue = ConvertTo(behavior.DestValue, propertyInfo.PropertyType);
197 if (destinationValue != null)
199 if (0 <= behavior.StartTime)
201 AnimateBy(instance, behavior.Property, destinationValue, behavior.StartTime, behavior.EndTime);
205 AnimateBy(instance, behavior.Property, destinationValue);
212 throw new XamlParseException(string.Format("Behaviors don't have key {0}", behaviorKey), new XmlLineInfo());