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 HelloWorldTest
24 class Example : NUIApplication
26 private Animation _animation;
27 private TextLabel _text;
31 public Example() : base()
35 public Example(string stylesheet) : base(stylesheet)
39 public Example(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode)
43 protected override void OnCreate()
49 public void Initialize()
51 Stage stage = Stage.Instance;
52 stage.BackgroundColor = Color.White;
53 stage.Touch += OnStageTouched;
54 stage.Key += OnStageKeyEvent;
56 _text = new TextLabel("Hello NUI World");
57 _text.ParentOrigin = ParentOrigin.Center;
58 _text.AnchorPoint = AnchorPoint.Center;
59 _text.HorizontalAlignment = "CENTER";
60 _text.PointSize = 32.0f;
61 _text.TextColor = Color.Magenta;
62 stage.GetDefaultLayer().Add(_text);
65 _view.Size = new Size(100, 100, 100);
67 Tizen.Log.Debug("NUI", "[1]_view SizeWidth=" + _view.SizeWidth);
69 _animation = new Animation
73 _animation.AnimateTo(_text, "Orientation", new Rotation(new Radian(new Degree(180.0f)), PositionAxis.X), 0, 500);
74 _animation.AnimateTo(_text, "Orientation", new Rotation(new Radian(new Degree(0.0f)), PositionAxis.X), 500, 1000);
75 _animation.AnimateBy(_text, "ScaleX", 3.0f, 1000, 1500);
76 _animation.AnimateBy(_text, "ScaleY", 4.0f, 1500, 2000);
77 _animation.EndAction = Animation.EndActions.Discard;
78 _animation.Finished += AnimationFinished;
81 Tizen.Log.Debug("NUI", "[2]_view SizeWidth=" + _view.SizeWidth);
84 public void AnimationFinished(object sender, EventArgs e)
86 Tizen.Log.Debug("NUI", "AnimationFinished()! cnt=" + (cnt));
89 Tizen.Log.Debug("NUI", "Duration= " + _animation.Duration + "EndAction= " + _animation.EndAction);
92 Tizen.Log.Debug("NUI", "[3]_view SizeWidth=" + _view.SizeWidth);
95 public void OnStageKeyEvent(object sender, Stage.KeyEventArgs e)
97 if (e.Key.State == Key.StateType.Down)
99 if (e.Key.KeyPressedName == "Up")
103 _animation.Finished += AnimationFinished;
105 Tizen.Log.Debug("NUI", "AnimationFinished added!");
108 else if (e.Key.KeyPressedName == "Down")
112 _animation.Finished -= AnimationFinished;
114 Tizen.Log.Debug("NUI", "AnimationFinished removed!");
120 public void OnStageTouched(object sender, Stage.TouchEventArgs e)
122 if (e.Touch.GetState(0) == PointStateType.Down)
126 //_animation.Stop(Dali.Constants.Animation.EndAction.Stop);
127 //_animation.Reset();
134 static void _Main(string[] args)
136 //Console.WriteLine("Main() called!");
137 Example example = new Example();