[NUI] Support SetProperty by using string name for Animatable
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Animation / Animatable.cs
index 7ce4779..4d83bbc 100755 (executable)
@@ -37,7 +37,7 @@ namespace Tizen.NUI
 
         }
 
-        internal Animatable(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.Handle.Upcast(cPtr), cMemoryOwn)
+        internal Animatable(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
         {
         }
 
@@ -137,6 +137,28 @@ namespace Tizen.NUI
         }
 
         /// <summary>
+        /// Sets the value of an existing property.
+        /// </summary>
+        /// <param name="name">The index of the property.</param>
+        /// <param name="propertyValue">The new value of the property.</param>
+        /// This will not be public opened.
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void SetProperty(string name, PropertyValue propertyValue)
+        {
+            var propertyName = LowerFirstLetter(name);
+            Property property = new Property(this, propertyName);
+            if (property.propertyIndex == Property.InvalidIndex)
+            {
+                Tizen.Log.Error("NUI", "Invalid property name\n");
+            }
+            else
+            {
+                Tizen.NUI.Object.SetProperty(SwigCPtr, property.propertyIndex, propertyValue);
+            }
+            property.Dispose();
+        }
+
+        /// <summary>
         /// Registers a new animatable property.
         /// </summary>
         /// <param name="name">The name of the property.</param>
@@ -214,11 +236,6 @@ namespace Tizen.NUI
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
 
-        internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Animatable obj)
-        {
-            return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
-        }
-
         internal uint GetPropertyCount()
         {
             uint ret = Interop.HandleInternal.HandleGetPropertyCount(SwigCPtr);
@@ -245,6 +262,13 @@ namespace Tizen.NUI
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
         }
 
+        private static string LowerFirstLetter(string original)
+        {
+            StringBuilder sb = new StringBuilder(original);
+            sb[0] = (char)(sb[0] | 0x20);
+            return sb.ToString();
+        }
+
         /// This will not be public opened.
         [EditorBrowsable(EditorBrowsableState.Never)]
         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)