8114f1c25ec764803fbd7d28aaaa2a17886473c8
[platform/core/csapi/tizenfx.git] / test / NUITizenGallery / Examples / PerformanceTest2 / PerformanceTest2.xaml.cs
1 /*
2  * Copyright(c) 2021 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17 using Tizen.NUI;
18 using Tizen.NUI.BaseComponents;
19 using Tizen.NUI.Components;
20
21 namespace NUITizenGallery
22 {
23     public partial class PerformanceTest2Page : View
24     {
25         private int TestItems = 50;
26         private int ScrollTime = 5000;
27
28         public PerformanceTest2Page()
29         {
30             InitializeComponent();
31
32             //Application Linear Layout
33             LinearLayout layout = new LinearLayout();
34             layout.LinearOrientation = LinearLayout.Orientation.Vertical;
35             layout.LinearAlignment = LinearLayout.Alignment.Center;
36             layout.Padding = new Extents(5, 5, 5, 5);
37             layout.CellPadding = new Size2D(5, 5);
38
39             this.Layout = layout;
40             StartButton.Clicked += OnButtonScrollClicked;
41
42             //Create List for Labels
43             LabelsListView = new ScrollableBase();
44             LabelsListView.BackgroundColor = Color.White;
45             LabelsListView.Size2D = new Size2D(700, 1200);
46
47             //Set linead layout for scrollable widget
48             LinearLayout scrollLayout = new LinearLayout();
49             scrollLayout.LinearOrientation = LinearLayout.Orientation.Vertical;
50             scrollLayout.LinearAlignment = LinearLayout.Alignment.Center;
51             scrollLayout.CellPadding = new Size2D(5, 5);
52             LabelsListView.Layout = scrollLayout;
53             LabelsListView.ScrollDuration = ScrollTime;
54             this.Add(LabelsListView);
55
56             var items = new ListItemTitleSwitch[TestItems];
57             for (int i = 0; i < TestItems; i++) {
58                 items[i] = new ListItemTitleSwitch("item: " + i.ToString());
59                 LabelsListView.Add(items[i]);
60             }
61         }
62
63         private void OnButtonScrollClicked(object sender, ClickedEventArgs args)
64         {
65             LabelsListView.ScrollToIndex(49);
66         }
67     }
68 }