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.UIComponents;
22 using Tizen.NUI.BaseComponents;
23 using Tizen.NUI.Constants;
25 namespace HelloWorldTest
27 class Example : NUIApplication
29 private Animation _animation;
30 private TextLabel _text;
34 public Example() : base()
38 public Example(string stylesheet) : base(stylesheet)
42 public Example(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode)
46 protected override void OnCreate()
52 public void Initialize()
54 Window window = Window.Instance;
55 window.BackgroundColor = Color.White;
56 window.TouchEvent += OnWindowTouched;
57 window.KeyEvent += OnWindowKeyEvent;
59 TextLabel pixelLabel = new TextLabel("Test Pixel Size 32.0f");
60 pixelLabel.Position2D = new Position2D(10, 10);
61 pixelLabel.PixelSize = 32.0f;
62 window.GetDefaultLayer().Add(pixelLabel);
64 TextLabel pointLabel = new TextLabel("Test Point Size 32.0f");
65 pointLabel.Position2D = new Position2D(10, 100);
66 pointLabel.PointSize = 32.0f;
67 window.GetDefaultLayer().Add(pointLabel);
69 TextLabel ellipsis = new TextLabel("Ellipsis of TextLabel is enabled.");
70 ellipsis.Size2D = new Size2D(100, 100);
71 ellipsis.Position2D = new Position2D(10, 250);
72 ellipsis.PointSize = 20.0f;
73 ellipsis.Ellipsis = true;
74 window.GetDefaultLayer().Add(ellipsis);
76 TextLabel autoScrollStopMode = new TextLabel("AutoScrollStopMode is finish-loop.");
77 autoScrollStopMode.Size2D = new Size2D(400, 100);
78 autoScrollStopMode.Position2D = new Position2D(10, 400);
79 autoScrollStopMode.PointSize = 15.0f;
80 autoScrollStopMode.AutoScrollStopMode = AutoScrollStopMode.FinishLoop;
81 //autoScrollStopMode.AutoScrollLoopDelay = 10.0f;
82 autoScrollStopMode.EnableAutoScroll = true;
83 window.GetDefaultLayer().Add(autoScrollStopMode);
85 _text = new TextLabel("Hello NUI World");
86 _text.ParentOrigin = ParentOrigin.Center;
87 _text.AnchorPoint = AnchorPoint.Center;
88 _text.HorizontalAlignment = HorizontalAlignment.Center;
89 _text.PointSize = 32.0f;
90 _text.TextColor = Color.Magenta;
91 window.GetDefaultLayer().Add(_text);
94 _view.Size = new Size(100, 100, 100);
96 Tizen.Log.Debug("NUI", "[1]_view SizeWidth=" + _view.SizeWidth);
98 _animation = new Animation
102 _animation.AnimateTo(_text, "Orientation", new Rotation(new Radian(new Degree(180.0f)), PositionAxis.X), 0, 500);
103 _animation.AnimateTo(_text, "Orientation", new Rotation(new Radian(new Degree(0.0f)), PositionAxis.X), 500, 1000);
104 _animation.AnimateBy(_text, "ScaleX", 3, 1000, 1500);
105 _animation.AnimateBy(_text, "ScaleY", 4.0f, 1500, 2000);
106 _animation.EndAction = Animation.EndActions.Discard;
107 _animation.Finished += AnimationFinished;
109 _view.SizeWidth = 50;
110 Tizen.Log.Debug("NUI", "[2]_view SizeWidth=" + _view.SizeWidth);
113 public void AnimationFinished(object sender, EventArgs e)
115 Tizen.Log.Debug("NUI", "AnimationFinished()! cnt=" + (cnt));
118 Tizen.Log.Debug("NUI", "Duration= " + _animation.Duration + "EndAction= " + _animation.EndAction);
120 _view.SizeWidth = 50;
121 Tizen.Log.Debug("NUI", "[3]_view SizeWidth=" + _view.SizeWidth);
124 public void OnWindowKeyEvent(object sender, Window.KeyEventArgs e)
126 if (e.Key.State == Key.StateType.Down)
128 if (e.Key.KeyPressedName == "Up")
132 _animation.Finished += AnimationFinished;
134 Tizen.Log.Debug("NUI", "AnimationFinished added!");
137 else if (e.Key.KeyPressedName == "Down")
141 _animation.Finished -= AnimationFinished;
143 Tizen.Log.Debug("NUI", "AnimationFinished removed!");
149 public void OnWindowTouched(object sender, Window.TouchEventArgs e)
151 if (e.Touch.GetState(0) == PointStateType.Down)
155 //_animation.Stop(Dali.Constants.Animation.EndAction.Stop);
156 //_animation.Reset();
163 static void _Main(string[] args)
165 //Tizen.Log.Debug("NUI", "Main() called!");
166 Example example = new Example();