DALi C# binding - Write pure C# Color & Position classes and use typemaps to do the...
[platform/core/uifw/dali-toolkit.git] / plugins / dali-swig / examples / hello-world.cs
index 28fd1dd..df298cc 100755 (executable)
 using System;
 using System.Runtime.InteropServices;
 using Dali;
+using Dali.CSharp;
 
 namespace MyCSharpExample
 {
     class Example
     {
-        [UnmanagedFunctionPointer(CallingConvention.StdCall)]
-        delegate void CallbackDelegate(IntPtr data);
-
-        [UnmanagedFunctionPointer(CallingConvention.StdCall)]
-        delegate void TouchCallbackDelegate(IntPtr data);
-
-        [UnmanagedFunctionPointer(CallingConvention.StdCall)]
-        delegate void AnimationCallbackDelegate(IntPtr data);
-
         private Dali.Application _application;
 
         private Animation _animation;
@@ -47,14 +39,14 @@ namespace MyCSharpExample
         {
             Console.WriteLine("Customized Application Initialize event handler");
             Stage stage = Stage.GetCurrent();
-            stage.BackgroundColor = NDalic.WHITE;
+            stage.BackgroundColor = new Dali.CSharp.Color(Dali.CSharp.Colors.Red);
 
-           stage.Touched += OnStageTouched;
+            stage.Touched += OnStageTouched;
 
             // Add a _text label to the stage
             _text = new TextLabel("Hello Mono World");
-            _text.ParentOrigin = NDalic.ParentOriginCenter;
-            _text.AnchorPoint = NDalic.AnchorPointCenter;
+            _text.ParentOrigin = new Position(NDalic.ParentOriginCenter);
+            _text.AnchorPoint = new Position(NDalic.AnchorPointCenter);
             _text.HorizontalAlignment = "CENTER";
             _text.PointSize = 32.0f;
 
@@ -66,6 +58,7 @@ namespace MyCSharpExample
         {
             Console.WriteLine("Customized Animation Finished Event handler");
             Console.WriteLine("Animation finished: duration = " + e.Animation.Duration);
+            Console.WriteLine("End Action = " + e.Animation.GetEndAction());
         }
 
         // Callback for stage touched signal handling
@@ -85,14 +78,17 @@ namespace MyCSharpExample
 
                 _animation = new Animation(1.0f); // 1 second of duration
 
-                _animation.AnimateTo(new Property(_text, Actor.Property.ORIENTATION), new Property.Value(new Quaternion( new Radian( new Degree( 180.0f ) ), Vector3.XAXIS )), new AlphaFunction(AlphaFunction.BuiltinFunction.LINEAR), new TimePeriod(0.0f, 0.5f));
-                _animation.AnimateTo(new Property(_text, Actor.Property.ORIENTATION), new Property.Value(new Quaternion( new Radian( new Degree( 0.0f ) ), Vector3.XAXIS )), new AlphaFunction(AlphaFunction.BuiltinFunction.LINEAR), new TimePeriod(0.5f, 0.5f));
+               _animation.AnimateTo(_text, Animation.Orientation, new Quaternion( new Radian( new Degree( 180.0f ) ), Vector3.XAXIS ), new AlphaFunction(Dali.Constants.AlphaFunction.BuiltinFunction.Linear), new TimePeriod(0.0f, 0.5f));
+
+               _animation.AnimateTo(_text, Animation.Orientation, new Quaternion( new Radian( new Degree( 0.0f ) ), Vector3.XAXIS ), new AlphaFunction(Dali.Constants.AlphaFunction.BuiltinFunction.Linear), new TimePeriod(0.5f, 0.5f));
 
                 // Connect the signal callback for animaiton finished signal
                 _animation.Finished += AnimationFinished;
 
                 // Play the _animation
                 _animation.Play();
+
+                Console.WriteLine("Looping:" + _animation.Looping);
             }
         }