2 * Copyright (c) 2016 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.
19 using System.Runtime.InteropServices;
22 namespace MyCSharpExample
26 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
27 delegate void CallbackDelegate(IntPtr data);
29 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
30 delegate void TouchCallbackDelegate(IntPtr data);
32 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
33 delegate void AnimationCallbackDelegate(IntPtr data);
35 private Dali.Application _application;
37 private Animation _animation;
38 private TextLabel _text;
40 public Example(Dali.Application application)
42 _application = application;
43 _application.Initialized += new Dali.AUIApplicationInitEventHandler(Initialize);
46 public void Initialize(object source, AUIApplicationInitEventArgs e)
48 Console.WriteLine("Customized Application Initialize event handler");
49 Stage stage = Stage.GetCurrent();
50 stage.BackgroundColor = NDalic.WHITE;
52 stage.Touched += new Dali.Stage.TouchEventHandler(OnStageTouched);
54 // Add a _text label to the stage
55 _text = new TextLabel("Hello Mono World");
56 _text.ParentOrigin = NDalic.ParentOriginCenter;
57 _text.AnchorPoint = NDalic.AnchorPointCenter;
58 _text.HorizontalAlignment = "CENTER";
59 _text.PointSize = 32.0f;
64 // Callback for _animation finished signal handling
65 public void AnimationFinished(object source, Animation.FinishedEventArgs e)
67 Console.WriteLine("Customized Animation Finished Event handler");
68 Console.WriteLine("Animation finished: duration = " + e.Animation.Duration);
71 // Callback for stage touched signal handling
72 public void OnStageTouched(object source, Stage.TouchEventArgs e)
74 //TouchData touchData = TouchData.GetTouchDataFromPtr( data );
76 // Only animate the _text label when touch down happens
77 if( e.TouchData.GetState(0) == PointStateType.DOWN )
79 Console.WriteLine("Customized Stage Touch event handler");
80 // Create a new _animation
86 _animation = new Animation(1.0f); // 1 second of duration
88 _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));
89 _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));
91 // Connect the signal callback for animaiton finished signal
92 _animation.Finished += new Dali.Animation.FinishedEventHandler(AnimationFinished);
94 // Play the _animation
99 public void MainLoop()
101 _application.MainLoop ();
105 /// The main entry point for the application.
109 static void Main(string[] args)
111 Console.WriteLine ("Hello Mono World");
113 Example example = new Example(Application.NewApplication());