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;
21 using Tizen.Applications;
23 //------------------------------------------------------------------------------
24 // <manual-generated />
26 // This file can only run on Tizen target. You should compile it with DaliApplication.cs, and
27 // add tizen c# application related library as reference.
28 //------------------------------------------------------------------------------
29 namespace MyCSharpExample
31 class Example : DaliApplication
33 protected override void OnCreate()
39 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
40 delegate void CallbackDelegate(IntPtr data);
42 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
43 delegate void TouchCallbackDelegate(IntPtr data);
45 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
46 delegate void AnimationCallbackDelegate(IntPtr data);
48 private Animation _animation;
49 private TextLabel _text;
51 public Example():base()
55 private void Initialize()
57 // Connect the signal callback for stage touched signal
58 TouchCallbackDelegate stageTouchedCallback = new TouchCallbackDelegate(OnStageTouched);
59 stage.TouchSignal().Connect(stageTouchedCallback);
61 // Add a _text label to the stage
62 _text = new TextLabel("Hello Mono World");
63 _text.ParentOrigin = NDalic.ParentOriginCenter;
64 _text.AnchorPoint = NDalic.AnchorPointCenter;
65 _text.HorizontalAlignment = "CENTER";
66 _text.PointSize = 32.0f;
71 // Callback for _animation finished signal handling
72 private void AnimationFinished(IntPtr data)
74 Animation _animation = Animation.GetAnimationFromPtr( data );
75 Console.WriteLine("Animation finished: duration = " + _animation.GetDuration());
78 // Callback for stage touched signal handling
79 private void OnStageTouched(IntPtr data)
81 TouchData touchData = TouchData.GetTouchDataFromPtr( data );
83 // Only animate the _text label when touch down happens
84 if (touchData.GetState(0) == PointStateType.DOWN)
86 // Create a new _animation
92 _animation = new Animation(1.0f); // 1 second of duration
94 _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));
95 _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));
97 // Connect the signal callback for animaiton finished signal
98 AnimationCallbackDelegate animFinishedDelegate = new AnimationCallbackDelegate(AnimationFinished);
99 _animation.FinishedSignal().Connect(animFinishedDelegate);
101 // Play the _animation
107 /// The main entry point for the application.
111 static void Main(string[] args)
113 Console.WriteLine("Hello mono world.");
114 Example example = new Example();