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;
21 using Tizen.NUI.Extension.Test;
23 namespace HelloWorldTest
25 class Example : NUIApplication
27 private Animation _animation;
28 private TextLabel _text;
32 public Example() : base()
36 public Example(string stylesheet) : base(stylesheet)
40 public Example(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode)
44 protected override void OnCreate()
50 public void Initialize()
52 InternalSetting.DefaultParentOriginAsTopLeft = false;
53 Stage stage = Stage.Instance;
54 stage.BackgroundColor = Color.White;
55 stage.Touch += OnStageTouched;
56 stage.Key += OnStageKeyEvent;
58 _text = new TextLabel("Hello NUI World");
59 _text.ParentOrigin = ParentOrigin.Center;
60 _text.AnchorPoint = AnchorPoint.Center;
61 _text.HorizontalAlignment = "CENTER";
62 _text.PointSize = 32.0f;
63 _text.TextColor = Color.Magenta;
64 stage.GetDefaultLayer().Add(_text);
67 _view.Size = new Size(100, 100, 100);
69 Tizen.Log.Debug("NUI", "[1]_view SizeWidth=" + _view.SizeWidth);
71 _animation = new Animation
75 _animation.AnimateTo(_text, "Orientation", new Rotation(new Radian(new Degree(180.0f)), PositionAxis.X), 0, 500);
76 _animation.AnimateTo(_text, "Orientation", new Rotation(new Radian(new Degree(0.0f)), PositionAxis.X), 500, 1000);
77 _animation.AnimateBy(_text, "ScaleX", 3.0f, 1000, 1500);
78 _animation.AnimateBy(_text, "ScaleY", 4.0f, 1500, 2000);
79 _animation.EndAction = Animation.EndActions.Discard;
80 _animation.Finished += AnimationFinished;
83 Tizen.Log.Debug("NUI", "[2]_view SizeWidth=" + _view.SizeWidth);
85 ActorTest _actorExt = new ActorTest();
86 Actor _actor1 = _actorExt.CreateActor();
87 if(_actor1) Tizen.Log.Debug("NUI", "FriendAssembly Test _actor1 name = " + _actor1.Name);
88 else Tizen.Log.Debug("NUI", "FriendAssembly Test _actor1 is NULL!");
92 public void AnimationFinished(object sender, EventArgs e)
94 Tizen.Log.Debug("NUI", "AnimationFinished()! cnt=" + (cnt));
97 Tizen.Log.Debug("NUI", "Duration= " + _animation.Duration + "EndAction= " + _animation.EndAction);
100 Tizen.Log.Debug("NUI", "[3]_view SizeWidth=" + _view.SizeWidth);
103 public void OnStageKeyEvent(object sender, Stage.KeyEventArgs e)
105 if (e.Key.State == Key.StateType.Down)
107 if (e.Key.KeyPressedName == "Up")
111 _animation.Finished += AnimationFinished;
113 Tizen.Log.Debug("NUI", "AnimationFinished added!");
116 else if (e.Key.KeyPressedName == "Down")
120 _animation.Finished -= AnimationFinished;
122 Tizen.Log.Debug("NUI", "AnimationFinished removed!");
128 public void OnStageTouched(object sender, Stage.TouchEventArgs e)
130 if (e.Touch.GetState(0) == PointStateType.Down)
134 //_animation.Stop(Dali.Constants.Animation.EndAction.Stop);
135 //_animation.Reset();
142 static void _Main(string[] args)
144 //Tizen.Log.Debug("NUI", "Main() called!");
145 Example example = new Example();