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;
23 namespace MyCSharpExample
27 private Dali.Application _application;
29 private Animation _animation;
30 private TextLabel _text;
32 public Example(Dali.Application application)
34 _application = application;
35 _application.Initialized += Initialize;
38 public void Initialize(object source, AUIApplicationInitEventArgs e)
40 Console.WriteLine("Customized Application Initialize event handler");
41 Stage stage = Stage.GetCurrent();
42 stage.BackgroundColor = new Dali.CSharp.Color(Dali.CSharp.Colors.Red);
44 stage.Touched += OnStageTouched;
46 // Add a _text label to the stage
47 _text = new TextLabel("Hello Mono World");
48 _text.ParentOrigin = new Position(NDalic.ParentOriginCenter);
49 _text.AnchorPoint = new Position(NDalic.AnchorPointCenter);
50 _text.HorizontalAlignment = "CENTER";
51 _text.PointSize = 32.0f;
56 // Callback for _animation finished signal handling
57 public void AnimationFinished(object source, Animation.FinishedEventArgs e)
59 Console.WriteLine("Customized Animation Finished Event handler");
60 Console.WriteLine("Animation finished: duration = " + e.Animation.Duration);
61 Console.WriteLine("End Action = " + e.Animation.GetEndAction());
64 // Callback for stage touched signal handling
65 public void OnStageTouched(object source, Stage.TouchEventArgs e)
67 //TouchData touchData = TouchData.GetTouchDataFromPtr( data );
69 // Only animate the _text label when touch down happens
70 if( e.TouchData.GetState(0) == PointStateType.DOWN )
72 Console.WriteLine("Customized Stage Touch event handler");
73 // Create a new _animation
79 _animation = new Animation(1.0f); // 1 second of duration
81 _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));
83 _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));
85 // Connect the signal callback for animaiton finished signal
86 _animation.Finished += AnimationFinished;
88 // Play the _animation
91 Console.WriteLine("Looping:" + _animation.Looping);
95 public void MainLoop()
97 _application.MainLoop ();
101 /// The main entry point for the application.
105 static void Main(string[] args)
107 Console.WriteLine ("Hello Mono World");
109 Example example = new Example(Application.NewApplication());