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.
21 namespace HelloTestExample
23 class Example : NUIApplication
25 private void LOG(string _str)
27 Tizen.Log.Debug("NUI-APP", _str);
28 //Console.WriteLine("[NUI-APP]" + _str);
31 private Animation _animation;
32 private TextLabel _text;
35 public Example() : base()
39 public Example(string stylesheet) : base(stylesheet)
43 public Example(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode)
47 private void Initialize()
49 LOG("Customized Application Initialize event handler");
50 _stage = Stage.Instance;
51 _stage.Touch += OnStageTouched;
52 _stage.Key += OnStageKeyEvent;
54 // Add a _text label to the stage
55 _text = new TextLabel("Hello NUI World");
56 _text.ParentOrigin = ParentOrigin.Center;
57 _text.AnchorPoint = AnchorPoint.Center;
58 _text.HorizontalAlignment = "CENTER";
59 _text.PointSize = 32.0f;
60 _text.TextColor = Color.Magenta;
61 _stage.GetDefaultLayer().Add(_text);
63 _animation = new Animation
68 LOG("[1]_text PositionX =" + _text.PositionX + " SizeHeight=" + _text.SizeHeight);
70 _animation.AnimateTo(_text, "PositionX", _text.PositionX + 200.0f);
71 _animation.AnimateTo(_text, "SizeHeight", _text.SizeHeight + 200.0f);
73 LOG("[2]_text PositionX =" + _text.PositionX + " SizeHeight=" + _text.SizeHeight);
75 _animation.AnimateTo(_text, "Orientation", new Rotation(new Radian(new Degree(180.0f)), Vector3.XAxis), 0, 500);
76 _animation.AnimateTo(_text, "Orientation", new Rotation(new Radian(new Degree(0.0f)), Vector3.XAxis), 500, 1000);
77 _animation.EndAction = Animation.EndActions.Discard;
80 public void OnStageKeyEvent(object sender, Stage.KeyEventArgs e)
82 if (e.Key.State == Key.StateType.Down)
84 if (e.Key.KeyPressedName == "Up")
88 _animation.Finished += AnimationFinished;
89 LOG("AnimationFinished added!");
92 else if (e.Key.KeyPressedName == "Down")
96 _animation.Finished -= AnimationFinished;
97 LOG("AnimationFinished removed!");
103 // Callback for _animation finished signal handling
104 public void AnimationFinished(object sender, EventArgs e)
106 LOG("AnimationFinished()!");
109 LOG("Duration= " + _animation.Duration);
110 LOG("EndAction= " + _animation.EndAction);
112 LOG("[4]_text PositionX =" + _text.PositionX + " SizeHeight=" + _text.SizeHeight);
115 // Callback for stage touched signal handling
116 public void OnStageTouched(object sender, Stage.TouchEventArgs e)
118 // Only animate the _text label when touch down happens
119 if (e.Touch.GetState(0) == PointStateType.Down)
121 LOG("Customized Stage Touch event handler");
123 // Play the _animation
126 LOG("[3]_text PositionX =" + _text.PositionX + " SizeHeight=" + _text.SizeHeight);
130 protected override void OnCreate()
137 static void Main(string[] args)
139 Example example = new Example();