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 private Dali.Application _application;
28 private Animation _animation;
29 private TextLabel _text;
31 public Example(Dali.Application application)
33 _application = application;
34 _application.Initialized += Initialize;
37 public void Initialize(object source, AUIApplicationInitEventArgs e)
39 Console.WriteLine("Customized Application Initialize event handler");
40 Stage stage = Stage.GetCurrent();
41 stage.BackgroundColor = new Color("white");
43 stage.Touched += OnStageTouched;
45 // Add a _text label to the stage
46 _text = new TextLabel("Hello Mono World");
47 _text.ParentOrigin = NDalic.ParentOriginCenter;
48 _text.AnchorPoint = NDalic.AnchorPointCenter;
49 _text.HorizontalAlignment = "CENTER";
50 _text.PointSize = 32.0f;
55 // Callback for _animation finished signal handling
56 public void AnimationFinished(object source, Animation.FinishedEventArgs e)
58 Console.WriteLine("Customized Animation Finished Event handler");
59 Console.WriteLine("Animation finished: duration = " + e.Animation.Duration);
60 Console.WriteLine("End Action = " + e.Animation.GetEndAction());
63 // Callback for stage touched signal handling
64 public void OnStageTouched(object source, Stage.TouchEventArgs e)
66 //TouchData touchData = TouchData.GetTouchDataFromPtr( data );
68 // Only animate the _text label when touch down happens
69 if( e.TouchData.GetState(0) == PointStateType.DOWN )
71 Console.WriteLine("Customized Stage Touch event handler");
72 // Create a new _animation
78 _animation = new Animation(1.0f); // 1 second of duration
80 _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));
82 _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));
84 // Connect the signal callback for animaiton finished signal
85 _animation.Finished += AnimationFinished;
87 // Play the _animation
90 Console.WriteLine("Looping:" + _animation.Looping);
94 public void MainLoop()
96 _application.MainLoop ();
100 /// The main entry point for the application.
104 static void Main(string[] args)
106 Console.WriteLine ("Hello Mono World");
108 Example example = new Example(Application.NewApplication());