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 public Example(string stylesheet):base(stylesheet)
59 public Example(string stylesheet, Dali.Application.WINDOW_MODE windowMode):base(stylesheet, windowMode)
63 private void Initialize()
65 // Connect the signal callback for stage touched signal
66 TouchCallbackDelegate stageTouchedCallback = new TouchCallbackDelegate(OnStageTouched);
67 stage.TouchSignal().Connect(stageTouchedCallback);
69 // Add a _text label to the stage
70 _text = new TextLabel("Hello Mono World");
71 _text.ParentOrigin = NDalic.ParentOriginCenter;
72 _text.AnchorPoint = NDalic.AnchorPointCenter;
73 _text.HorizontalAlignment = "CENTER";
74 _text.PointSize = 32.0f;
79 // Callback for _animation finished signal handling
80 private void AnimationFinished(IntPtr data)
82 Animation _animation = Animation.GetAnimationFromPtr( data );
83 Console.WriteLine("Animation finished: duration = " + _animation.GetDuration());
86 // Callback for stage touched signal handling
87 private void OnStageTouched(IntPtr data)
89 TouchData touchData = TouchData.GetTouchDataFromPtr( data );
91 // Only animate the _text label when touch down happens
92 if (touchData.GetState(0) == PointStateType.DOWN)
94 // Create a new _animation
100 _animation = new Animation(1.0f); // 1 second of duration
102 _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));
103 _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));
105 // Connect the signal callback for animaiton finished signal
106 AnimationCallbackDelegate animFinishedDelegate = new AnimationCallbackDelegate(AnimationFinished);
107 _animation.FinishedSignal().Connect(animFinishedDelegate);
109 // Play the _animation
115 /// The main entry point for the application.
119 static void Main(string[] args)
121 Console.WriteLine("Hello mono world.");
122 //Example example = new Example();
123 //Example example = new Example("stylesheet");
124 Example example = new Example("stylesheet", Dali.Application.WINDOW_MODE.TRANSPARENT);