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;
28 private Animation _animation;
29 private TextLabel _text;
32 public Example(Dali.Application application)
34 _application = application;
35 _application.Initialized += Initialize;
38 public void Initialize(object source, NUIApplicationInitEventArgs e)
40 Console.WriteLine("Customized Application Initialize event handler");
41 _stage = Stage.Instance;
42 _stage.BackgroundColor = Color.White;
43 _stage.Touch += OnStageTouched;
45 // Add a _text label to the stage
46 _text = new TextLabel("Hello Mono World");
47 _text.ParentOrigin = ParentOrigin.Center;
48 _text.AnchorPoint = AnchorPoint.Center;
49 _text.HorizontalAlignment = "CENTER";
50 _text.PointSize = 32.0f;
51 _text.TextColor = Color.Magenta;
54 _animation = new Animation
58 TargetProperty = "Orientation",
59 Destination = new Rotation(new Radian(new Degree(180.0f)), Vect3.Xaxis)
61 _animation.AnimateTo(_text);
63 _animation.StartTime = 500;
64 _animation.EndTime = 1000;
65 _animation.TargetProperty = "Orientation";
66 _animation.Destination = new Rotation(new Radian(new Degree(0.0f)), Vect3.Xaxis);
67 _animation.AnimateTo(_text);
69 _animation.StartTime = 1000;
70 _animation.EndTime = 1500;
71 _animation.TargetProperty = "ScaleX";
72 _animation.Destination = 3.0f;
73 _animation.AnimateBy(_text);
75 _animation.StartTime = 1500;
76 _animation.EndTime = 2000;
77 _animation.TargetProperty = "ScaleY";
78 _animation.Destination = 4.0f;
79 _animation.AnimateBy(_text);
81 _animation.EndAction = Animation.EndActions.Discard;
83 // Connect the signal callback for animaiton finished signal
84 _animation.Finished += AnimationFinished;
87 // Callback for _animation finished signal handling
88 public void AnimationFinished(object sender, EventArgs e)
90 Console.WriteLine("AnimationFinished()!");
93 Console.WriteLine("Duration= " + _animation.Duration);
94 Console.WriteLine("EndAction= " + _animation.EndAction);
98 // Callback for stage touched signal handling
99 public void OnStageTouched(object sender, Stage.TouchEventArgs e)
101 // Only animate the _text label when touch down happens
102 if (e.Touch.GetState(0) == PointStateType.DOWN)
104 Console.WriteLine("Customized Stage Touch event handler");
106 // Create a new _animation
111 // Play the _animation
116 public void MainLoop()
118 _application.MainLoop();
122 /// The main entry point for the application.
125 static void Main(string[] args)
127 Console.WriteLine("Main() called!");
129 Example example = new Example(Application.NewApplication());