Merge "[Telephony] Sample App implementation."
[platform/core/csapi/tizenfx.git] / test / ElmSharp.Test / TC / FocusAutoScrollModeTest.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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 System;
18 using ElmSharp;
19
20 namespace ElmSharp.Test
21 {
22     public class FocusAutoScrollModeTest : TestCaseBase
23     {
24         public override string TestName => "FocusAutoScrollModeTest";
25         public override string TestDescription => "To test basic operation of Elementary.FocusAutoScrollMode";
26
27         public override void Run(Window window)
28         {
29             Conformant conformant = new Conformant(window);
30             conformant.Show();
31             GenGrid grid = new GenGrid(window)
32             {
33                 AlignmentX = -1,
34                 AlignmentY = -1,
35                 WeightX = 1,
36                 WeightY = 1,
37                 ItemAlignmentX = -1,
38                 ItemAlignmentY = -1,
39                 ItemWidth = window.ScreenSize.Width / 3,
40                 ItemHeight = window.ScreenSize.Width / 3,
41             };
42
43             GenItemClass defaultClass = new GenItemClass("default")
44             {
45                 GetTextHandler = (obj, part) =>
46                 {
47                     Color item = (Color)obj;
48                     return String.Format("#{0:X}{1:X}{2:X}", item.R, item.G, item.B);
49                 },
50                 GetContentHandler = (obj, part) =>
51                 {
52                     Color item = (Color)obj;
53                     if (part == "elm.swallow.icon")
54                     {
55                         var colorbox = new Rectangle(window)
56                         {
57                             Color = item
58                         };
59                         return colorbox;
60                     }
61                     return null;
62                 }
63
64             };
65
66             GenGridItem firstitem = null;
67             GenGridItem lastitem = null;
68
69             var rnd = new Random();
70             for (int i = 0; i < 102; i++)
71             {
72                 int r = rnd.Next(255);
73                 int g = rnd.Next(255);
74                 int b = rnd.Next(255);
75                 Color color = Color.FromRgb(r, g, b);
76                 var item = grid.Append(defaultClass, color);
77                 if (i == 0)
78                     firstitem = item;
79                 if (i == 101)
80                     lastitem = item;
81             }
82             grid.Show();
83             Box box = new Box(window)
84             {
85                 AlignmentX = -1,
86                 AlignmentY = -1,
87                 WeightX = 1,
88                 WeightY = 1,
89             };
90             box.Show();
91             conformant.SetContent(box);
92
93             box.PackEnd(grid);
94
95             Button show = new Button(window)
96             {
97                 Text = "Show",
98                 AlignmentX = -1,
99                 WeightX = 1,
100             };
101             Button none = new Button(window)
102             {
103                 Text = "None",
104                 AlignmentX = -1,
105                 WeightX = 1,
106             };
107             Button bringIn = new Button(window)
108             {
109                 Text = "BringIn",
110                 AlignmentX = -1,
111                 WeightX = 1,
112             };
113
114             show.Clicked += (s, e) =>
115             {
116                 Elementary.FocusAutoScrollMode = FocusAutoScrollMode.Show;
117                 Console.WriteLine("FocusAutoScrollMode : {0}", Elementary.FocusAutoScrollMode);
118             };
119             none.Clicked += (s, e) =>
120             {
121                 Elementary.FocusAutoScrollMode = FocusAutoScrollMode.None;
122                 Console.WriteLine("FocusAutoScrollMode : {0}", Elementary.FocusAutoScrollMode);
123             };
124             bringIn.Clicked += (s, e) =>
125             {
126                 Elementary.FocusAutoScrollMode = FocusAutoScrollMode.BringIn;
127                 Console.WriteLine("FocusAutoScrollMode : {0}", Elementary.FocusAutoScrollMode);
128             };
129
130             show.Show();
131             none.Show();
132             bringIn.Show();
133
134             box.PackEnd(show);
135             box.PackEnd(none);
136             box.PackEnd(bringIn);
137
138             grid.ItemActivated += Grid_ItemActivated;
139             grid.ItemSelected += Grid_ItemSelected;
140             grid.ItemUnselected += Grid_ItemUnselected;
141             grid.ItemRealized += Grid_ItemRealized;
142             grid.ItemUnrealized += Grid_ItemUnrealized;
143             grid.ItemPressed += Grid_ItemPressed;
144             grid.ItemReleased += Grid_ItemReleased;
145             grid.ItemLongPressed += Grid_ItemLongPressed;
146             grid.ItemDoubleClicked += Grid_ItemDoubleClicked;
147         }
148
149         private void Grid_ItemDoubleClicked(object sender, GenGridItemEventArgs e)
150         {
151             Color color = (Color)e.Item.Data;
152             Console.WriteLine("#{0:X}{1:X}{2:X} is Double clicked", color.R, color.G, color.B);
153         }
154
155         private void Grid_ItemLongPressed(object sender, GenGridItemEventArgs e)
156         {
157             Color color = (Color)e.Item.Data;
158             Console.WriteLine("#{0:X}{1:X}{2:X} is LongPressed", color.R, color.G, color.B);
159         }
160
161         private void Grid_ItemReleased(object sender, GenGridItemEventArgs e)
162         {
163             Color color = (Color)e.Item.Data;
164             Console.WriteLine("#{0:X}{1:X}{2:X} is Released", color.R, color.G, color.B);
165         }
166
167         private void Grid_ItemPressed(object sender, GenGridItemEventArgs e)
168         {
169             Color color = (Color)e.Item.Data;
170             Console.WriteLine("#{0:X}{1:X}{2:X} is Pressed", color.R, color.G, color.B);
171         }
172
173         private void Grid_ItemUnselected(object sender, GenGridItemEventArgs e)
174         {
175             Color color = (Color)e.Item.Data;
176             Console.WriteLine("#{0:X}{1:X}{2:X} is Unselected", color.R, color.G, color.B);
177         }
178
179         private void Grid_ItemRealized(object sender, GenGridItemEventArgs e)
180         {
181             Color color = (Color)e.Item.Data;
182             Console.WriteLine("#{0:X}{1:X}{2:X} is Realized", color.R, color.G, color.B);
183         }
184
185         private void Grid_ItemUnrealized(object sender, GenGridItemEventArgs e)
186         {
187             Color color = (Color)e.Item.Data;
188             Console.WriteLine("#{0:X}{1:X}{2:X} is Unrealized", color.R, color.G, color.B);
189         }
190
191         private void Grid_ItemSelected(object sender, GenGridItemEventArgs e)
192         {
193             Color color = (Color)e.Item.Data;
194             Console.WriteLine("#{0:X}{1:X}{2:X} is Selected", color.R, color.G, color.B);
195         }
196
197         private void Grid_ItemActivated(object sender, GenGridItemEventArgs e)
198         {
199             Color color = (Color)e.Item.Data;
200             Console.WriteLine("#{0:X}{1:X}{2:X} is Activated", color.R, color.G, color.B);
201         }
202     }
203 }