Add comments, nui 0.2.31 upgrade
[platform/core/csapi/nui.git] / NUISamples / NUISamples.TizenTV / examples / test1.cs
1 // Copyright (c) 2017 Samsung Electronics Co., Ltd.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15
16 using System;
17 using System.Runtime.InteropServices;
18 using Tizen.NUI;
19 using System.Collections.Generic;
20
21
22 // 1) sibling order test
23 namespace Test1
24 {
25     class Example : NUIApplication
26     {
27         public Example() : base()
28         {
29         }
30
31         public Example(string stylesheet) : base(stylesheet)
32         {
33         }
34
35         public Example(string stylesheet, WindowMode windowMode) : base(stylesheet, windowMode)
36         {
37         }
38
39         protected override void OnCreate()
40         {
41             base.OnCreate();
42             Initialize();
43         }
44
45         Stage _stage;
46         public void Initialize()
47         {
48             _stage = Stage.Instance;
49             _stage.BackgroundColor = Color.White;
50
51             // 1) sibling order test
52             SiblingTest();
53
54
55         }
56
57         public void SiblingTest()
58         {
59             View _prev = null;
60             Position2D _myPos = new Position2D(100, 100);
61             List<View> list_view = new List<View>();
62             TextLabel _txt = new TextLabel();
63
64             for (int i = 0; i < 10; i++)
65             {
66                 View _view0 = new PushButton();
67                 PushButton _view = _view0 as PushButton;
68
69                 _view.Name = "sibling" + i;
70                 _view.MinimumSize = new Size2D(100, 50);
71                 _view.LabelText = "sibling" + i;
72                 _view.ParentOrigin = ParentOrigin.TopLeft;
73                 _view.AnchorPoint = AnchorPoint.TopLeft;
74                 _view.Position2D = _myPos + new Position2D(20 * i, 10 * i);
75                 _view.Clicked += (sender, ee) =>
76                 {
77                     View curr = sender as View;
78                     Tizen.Log.Debug("NUI", "clicked curr view name=" + curr.Name + "  sibling=" + curr.SiblingOrder);
79                     curr.RaiseToTop();
80                     if (_prev)
81                     {
82                         _prev.LowerToBottom();
83                         Tizen.Log.Debug("NUI", "raise on top is called!curr sibling=" + curr.SiblingOrder + " prev name=" + _prev.Name + " sibling=" + _prev.SiblingOrder);
84                     }
85                     _prev = curr;
86                     _txt.Text = "on top: " + curr.Name + ", sibling order=" + curr.SiblingOrder;
87                     return true;
88                 };
89                 list_view.Add(_view);
90             }
91
92             for (int i = 0; i < 10; i++)
93             {
94                 _stage.GetDefaultLayer().Add(list_view[i]);
95                 Tizen.Log.Debug("NUI", list_view[i].Name + "'s sibling order=" + list_view[i].SiblingOrder);
96             }
97
98             _txt.ParentOrigin = ParentOrigin.TopLeft;
99             _txt.AnchorPoint = AnchorPoint.TopLeft;
100             _txt.Text = "on top: sibling#, sibling order=?";
101             _txt.Position2D = _myPos + new Position2D(-50, 200);
102             _txt.TextColor = Color.Blue;
103             _stage.GetDefaultLayer().Add(_txt);
104         }
105
106         [STAThread]
107         static void _Main(string[] args)
108         {
109             Example example = new Example();
110             example.Run(args);
111         }
112     }
113 }