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.
20 using Tizen.NUI.BaseComponents;
22 namespace HelloWorldTest
24 class Example : NUIApplication
26 private Animation _animation;
27 private TextLabel _text;
31 protected override void OnCreate()
39 public void Initialize()
41 Window window = Window.Instance;
42 window.BackgroundColor = Color.White;
43 window.TouchEvent += OnWindowTouched;
44 window.KeyEvent += OnWindowKeyEvent;
45 window.Resized += (obj, e) =>
47 NUILog.Debug("Height: " + e.WindowSize.Height);
48 NUILog.Debug("Width: " + e.WindowSize.Width);
51 pixelLabel = new TextLabel("Test Pixel Size 32.0f");
52 pixelLabel.Position2D = new Position2D(10, 10);
53 pixelLabel.PixelSize = 32.0f;
54 window.Add(pixelLabel);
56 pointLabel = new TextLabel("Test Point Size 32.0f");
57 pointLabel.Position2D = new Position2D(10, 100);
58 pointLabel.PointSize = 32.0f;
59 window.Add(pointLabel);
61 TextLabel ellipsis = new TextLabel("Ellipsis of TextLabel is enabled.");
62 ellipsis.Size2D = new Size2D(100, 100);
63 ellipsis.Position2D = new Position2D(10, 250);
64 ellipsis.PointSize = 20.0f;
65 ellipsis.Ellipsis = true;
68 TextLabel autoScrollStopMode = new TextLabel("AutoScrollStopMode is finish-loop.");
69 autoScrollStopMode.Size2D = new Size2D(400, 100);
70 autoScrollStopMode.Position2D = new Position2D(10, 400);
71 autoScrollStopMode.PointSize = 15.0f;
72 autoScrollStopMode.AutoScrollStopMode = AutoScrollStopMode.FinishLoop;
73 autoScrollStopMode.AutoScrollLoopDelay = 10.0f;
74 autoScrollStopMode.EnableAutoScroll = true;
75 window.Add(autoScrollStopMode);
77 _text = new TextLabel("Hello NUI World");
78 _text.Position2D = new Position2D(10, 500);
79 _text.HorizontalAlignment = HorizontalAlignment.Center;
80 _text.PointSize = 20.0f;
81 _text.TextColor = Color.Magenta;
85 _view.Size2D = new Size2D(100, 100);
87 NUILog.Debug("[1]_view SizeWidth=" + _view.SizeWidth);
89 _animation = new Animation
93 _animation.AnimateTo(_text, "Orientation", new Rotation(new Radian(new Degree(180.0f)), PositionAxis.X), 0, 500);
94 _animation.AnimateTo(_text, "Orientation", new Rotation(new Radian(new Degree(0.0f)), PositionAxis.X), 500, 1000);
95 _animation.AnimateBy(_text, "ScaleX", 3, 1000, 1500);
96 _animation.AnimateBy(_text, "ScaleY", 4.0f, 1500, 2000);
97 _animation.EndAction = Animation.EndActions.Discard;
98 _animation.Finished += AnimationFinished;
100 _view.SizeWidth = 50;
101 NUILog.Debug("[2]_view SizeWidth=" + _view.SizeWidth);
\r
103 TextLabelLineWrapModeTest();
\r
106 public void AnimationFinished(object sender, EventArgs e)
108 NUILog.Debug("AnimationFinished()! cnt=" + (cnt));
111 NUILog.Debug("Duration= " + _animation.Duration + "EndAction= " + _animation.EndAction);
113 _view.SizeWidth = 50;
114 NUILog.Debug("[3]_view SizeWidth=" + _view.SizeWidth);
118 public void OnWindowKeyEvent(object sender, Window.KeyEventArgs e)
120 NUILog.Debug("e.Key.KeyPressedName=" + e.Key.KeyPressedName);
\r
122 if (e.Key.State == Key.StateType.Down)
124 if (e.Key.KeyPressedName == "Up")
128 _animation.Finished += AnimationFinished;
130 NUILog.Debug("AnimationFinished added!");
132 pointLabel.TextColorAnimatable = Color.Blue;
\r
133 pixelLabel.TextColorAnimatable = Color.Blue;
\r
135 NUILog.Debug($"LineWrapMode 1st={ myTextLabel?.LineWrapMode} 2nd={ myTextLabel2?.LineWrapMode}");
137 else if (e.Key.KeyPressedName == "Down")
141 _animation.Finished -= AnimationFinished;
143 NUILog.Debug("AnimationFinished removed!");
145 pointLabel.TextColorAnimatable = Color.Red;
\r
146 pixelLabel.TextColorAnimatable = Color.Red;
\r
148 Window.Instance.SetClass($"Window.SetClass() Test #{win_test++}", "");
149 NUILog.Debug($"Check with enlightenment_info -topwins ! Window.SetClass() Test #{win_test}");
151 else if (e.Key.KeyPressedName == "Return")
154 NUILog.Debug("_animation play here!");
\r
159 public void OnWindowTouched(object sender, Window.TouchEventArgs e)
161 if (e.Touch.GetState(0) == PointStateType.Down)
167 private TextLabel myTextLabel;
\r
168 private TextLabel myTextLabel2;
\r
169 public void TextLabelLineWrapModeTest()
\r
171 NUILog.Debug("WrapModeTest START!");
\r
172 myTextLabel = new TextLabel();
\r
173 myTextLabel.Position2D = new Position2D(10, 600);
\r
174 myTextLabel.Size2D = new Size2D(400, 100);
\r
175 myTextLabel.BackgroundColor = Color.Blue;
\r
176 myTextLabel.PointSize = 20;
\r
177 myTextLabel.TextColor = Color.White;
\r
178 myTextLabel.MultiLine = true;
\r
179 myTextLabel.LineWrapMode = LineWrapMode.Character;
\r
180 myTextLabel.Text = $"[LineWrapMode.Character] hello my name is ABCDEFGHI, it is very very long beautiful hansome awesome name.";
\r
181 Window.Instance.GetDefaultLayer().Add(myTextLabel);
\r
183 myTextLabel2 = new TextLabel();
\r
184 myTextLabel2.Position2D = new Position2D(10, 800);
\r
185 myTextLabel2.Size2D = new Size2D(400, 100);
\r
186 myTextLabel2.BackgroundColor = Color.Blue;
\r
187 myTextLabel2.PointSize = 20;
\r
188 myTextLabel2.TextColor = Color.White;
\r
189 myTextLabel2.MultiLine = true;
\r
190 myTextLabel2.LineWrapMode = LineWrapMode.Word;
\r
191 myTextLabel2.Text = $"[LineWrapMode.Word] hello my name is ABCDEFGHI, it is very very long beautiful hansome awesome name.";
\r
192 Window.Instance.GetDefaultLayer().Add(myTextLabel2);
\r
194 NUILog.Debug($"LineWrapMode 1st={ myTextLabel?.LineWrapMode} 2nd={ myTextLabel2?.LineWrapMode}");
\r
198 static void _Main(string[] args)
200 Example example = new Example();