2 * Copyright (c) 2017 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;
58 window.Resized += (obj, e) =>
60 Tizen.Log.Debug("NUI", "Height: " + e.WindowSize.Height);
61 Tizen.Log.Debug("NUI", "Width: " + e.WindowSize.Width);
64 TextLabel pixelLabel = new TextLabel("Test Pixel Size 32.0f");
65 pixelLabel.Position2D = new Position2D(10, 10);
66 pixelLabel.PixelSize = 32.0f;
67 window.Add(pixelLabel);
69 TextLabel pointLabel = new TextLabel("Test Point Size 32.0f");
70 pointLabel.Position2D = new Position2D(10, 100);
71 pointLabel.PointSize = 32.0f;
72 window.Add(pointLabel);
74 TextLabel ellipsis = new TextLabel("Ellipsis of TextLabel is enabled.");
75 ellipsis.Size2D = new Size2D(100, 100);
76 ellipsis.Position2D = new Position2D(10, 250);
77 ellipsis.PointSize = 20.0f;
78 ellipsis.Ellipsis = true;
81 TextLabel autoScrollStopMode = new TextLabel("AutoScrollStopMode is finish-loop.");
82 autoScrollStopMode.Size2D = new Size2D(400, 100);
83 autoScrollStopMode.Position2D = new Position2D(10, 400);
84 autoScrollStopMode.PointSize = 15.0f;
85 autoScrollStopMode.AutoScrollStopMode = AutoScrollStopMode.FinishLoop;
86 //autoScrollStopMode.AutoScrollLoopDelay = 10.0f;
87 autoScrollStopMode.EnableAutoScroll = true;
88 window.Add(autoScrollStopMode);
90 _text = new TextLabel("Hello NUI World");
91 _text.ParentOrigin = ParentOrigin.Center;
92 _text.PivotPoint = PivotPoint.Center;
93 _text.HorizontalAlignment = HorizontalAlignment.Center;
94 _text.PointSize = 32.0f;
95 _text.TextColor = Color.Magenta;
99 _view.Size2D = new Size2D(100, 100);
100 _view.SizeWidth = 50;
101 Tizen.Log.Debug("NUI", "[1]_view SizeWidth=" + _view.SizeWidth);
103 _animation = new Animation
107 _animation.AnimateTo(_text, "Orientation", new Rotation(new Radian(new Degree(180.0f)), PositionAxis.X), 0, 500);
108 _animation.AnimateTo(_text, "Orientation", new Rotation(new Radian(new Degree(0.0f)), PositionAxis.X), 500, 1000);
109 _animation.AnimateBy(_text, "ScaleX", 3, 1000, 1500);
110 _animation.AnimateBy(_text, "ScaleY", 4.0f, 1500, 2000);
111 _animation.EndAction = Animation.EndActions.Discard;
112 _animation.Finished += AnimationFinished;
114 _view.SizeWidth = 50;
115 Tizen.Log.Debug("NUI", "[2]_view SizeWidth=" + _view.SizeWidth);
118 public void AnimationFinished(object sender, EventArgs e)
120 Tizen.Log.Debug("NUI", "AnimationFinished()! cnt=" + (cnt));
123 Tizen.Log.Debug("NUI", "Duration= " + _animation.Duration + "EndAction= " + _animation.EndAction);
125 _view.SizeWidth = 50;
126 Tizen.Log.Debug("NUI", "[3]_view SizeWidth=" + _view.SizeWidth);
129 public void OnWindowKeyEvent(object sender, Window.KeyEventArgs e)
131 if (e.Key.State == Key.StateType.Down)
133 if (e.Key.KeyPressedName == "Up")
137 _animation.Finished += AnimationFinished;
139 Tizen.Log.Debug("NUI", "AnimationFinished added!");
142 else if (e.Key.KeyPressedName == "Down")
146 _animation.Finished -= AnimationFinished;
148 Tizen.Log.Debug("NUI", "AnimationFinished removed!");
154 public void OnWindowTouched(object sender, Window.TouchEventArgs e)
156 if (e.Touch.GetState(0) == PointStateType.Down)
160 //_animation.Stop(Dali.Constants.Animation.EndAction.Stop);
161 //_animation.Reset();
168 static void _Main(string[] args)
170 //Tizen.Log.Debug("NUI", "Main() called!");
171 Example example = new Example();