rename cs file of testcase
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Samples / Tizen.NUI.Samples / Samples / ScrollableBaseOutOfBoundSample.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4 using Tizen.NUI.BaseComponents;
5
6 namespace Tizen.NUI.Samples
7 {
8     public class ScrollableBaseOutOfBoundSample : IExample
9     {
10         private View root;
11         private Components.ScrollableBase mScrollableBase = null;
12         private TextLabel[] items;
13
14         public void Activate()
15         {
16             Window window = NUIApplication.GetDefaultWindow();
17             root = new View()
18             {
19                 Size = new Size(1920, 1080),
20                 BackgroundColor = new Color(0.7f, 0.9f, 0.8f, 1.0f),
21             };
22             root.Layout = new LinearLayout()
23             {
24                 LinearOrientation = LinearLayout.Orientation.Vertical
25             };
26             window.Add(root);
27
28             CreateScrollableBase();
29         }
30
31         private void CreateScrollableBase()
32         {
33             mScrollableBase = new Components.ScrollableBase()
34             {
35                 Position = new Position(300, 100),
36                 Size = new Size(400, 300),
37                 ScrollingDirection = Components.ScrollableBase.Direction.Vertical,
38             };
39             mScrollableBase.ScrollOutOfBound += OnScrollOutOfBound;
40
41             items = new TextLabel[5];
42             for (int i = 0; i < 5; i++)
43             {
44                 items[i] = new TextLabel
45                 {
46                     Position = new Position(0, i * 100),
47                     Size = new Size(800, 100),
48                     PointSize = 12.0f,
49                     TextColor = Color.Black,
50                 };
51                 if (i % 2 == 0)
52                 {
53                     items[i].BackgroundColor = Color.White;
54                 }
55                 else
56                 {
57                     items[i].BackgroundColor = Color.Cyan;
58                 }
59                 mScrollableBase.Add(items[i]);
60             }
61             root.Add(mScrollableBase);
62         }
63
64         private void OnScrollOutOfBound(object sender, Components.ScrollOutOfBoundEventArgs e)
65         {
66             if (e.ScrollableBound == Components.ScrollOutOfBoundEventArgs.Bound.Top)
67             {
68                 items[0].Text = "Reached at the top.";
69             }
70             else
71             {
72                 items[4].Text = "Reached at the bottom.";
73             }
74         }
75
76         public void Deactivate()
77         {
78             for (int i = 0; i < 5; i++)
79             {
80                 if (items[i] != null)
81                 {
82                     mScrollableBase.Remove(items[i]);
83                     items[i].Dispose();
84                 }
85             }
86             if (mScrollableBase != null)
87             {
88                 root.Remove(mScrollableBase);
89                 mScrollableBase.Dispose();
90             }
91             root.Dispose();
92         }
93     }
94 }