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 NUI.Application _application;
28 private Animation _animation;
29 private TextLabel _text;
31 public Example(NUI.Application application)
33 _application = application;
34 _application.Initialized += Initialize;
37 public void Initialize(object source, EventArgs e)
39 Console.WriteLine("Customized Application Initialize event handler");
40 Stage stage = Stage.Instance;
41 stage.BackgroundColor = Color.White;
42 stage.TouchEvent += OnStageTouched;
44 // Add a _text label to the stage
45 _text = new TextLabel("Hello Mono World");
46 _text.ParentOrigin = ParentOrigin.Center;
47 _text.AnchorPoint = AnchorPoint.Center;
48 _text.HorizontalAlignment = "CENTER";
49 _text.PointSize = 32.0f;
50 _text.TextColor = Color.Magenta;
54 // Callback for _animation finished signal handling
55 public void AnimationFinished(object sender, EventArgs e)
57 Console.WriteLine("AnimationFinished()!");
60 Console.WriteLine("Duration= " + _animation.Duration);
61 Console.WriteLine("EndAction= " + _animation.EndAction);
65 // Callback for stage touched signal handling
66 public void OnStageTouched(object sender, Stage.TouchEventArgs e)
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
75 //_animation.Stop(Dali.Constants.Animation.EndAction.Stop);
79 _animation = new Animation {
83 TargetProperty = "Orientation",
84 Destination = new Quaternion( new Radian( new Degree( 180.0f ) ), Vect3.Xaxis)
86 _animation.AnimateTo(_text);
88 _animation.StartTime = 500;
89 _animation.EndTime = 1000;
90 _animation.TargetProperty = "Orientation";
91 _animation.Destination = new Quaternion( new Radian( new Degree( 0.0f ) ), Vect3.Xaxis );
92 _animation.AnimateTo(_text);
94 _animation.StartTime = 1000;
95 _animation.EndTime = 1500;
96 _animation.TargetProperty = "ScaleX";
97 _animation.Destination = 3.0f;
98 _animation.AnimateBy(_text);
100 _animation.StartTime = 1500;
101 _animation.EndTime = 2000;
102 _animation.TargetProperty = "ScaleY";
103 _animation.Destination = 4.0f;
104 _animation.AnimateBy(_text);
106 _animation.EndAction = Animation.EndActions.Discard;
108 // Connect the signal callback for animaiton finished signal
109 _animation.Finished += AnimationFinished;
111 // Play the _animation
117 public void MainLoop()
119 _application.MainLoop ();
123 /// The main entry point for the application.
126 static void Main(string[] args)
128 Console.WriteLine ("Main() called!");
130 Example example = new Example(Application.NewApplication());