Merge "[Telephony] Sample App implementation."
[platform/core/csapi/tizenfx.git] / test / ElmSharp.Test / TC / GenGridTest1.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 GenGridTest1 : TestCaseBase
23     {
24         public override string TestName => "GenGridTest1";
25         public override string TestDescription => "To test basic operation of GenGrid";
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                 HorizontalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Invisible,
42                 VerticalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Invisible
43             };
44
45             GenItemClass defaultClass = new GenItemClass("default")
46             {
47                 GetTextHandler = (obj, part) =>
48                 {
49                     Color item = (Color)obj;
50                     return String.Format("#{0:X}{1:X}{2:X}", item.R, item.G, item.B);
51                 },
52                 GetContentHandler = (obj, part) =>
53                 {
54                     Color item = (Color)obj;
55                     Console.WriteLine("{0} part create requested", part);
56                     if (part == "elm.swallow.icon")
57                     {
58                         var colorbox = new Rectangle(window)
59                         {
60                             Color = item
61                         };
62                         return colorbox;
63                     }
64                     return null;
65                 }
66             };
67
68             var rnd = new Random();
69             for (int i = 0; i < 10; i++)
70             {
71                 int r = rnd.Next(255);
72                 int g = rnd.Next(255);
73                 int b = rnd.Next(255);
74                 Color color = Color.FromRgb(r, g, b);
75                 var griditem = grid.Append(defaultClass, color);
76                 griditem.SetTooltipText("AAAAAA");
77                 //griditem.TooltipStyle = "transparent";
78
79                 griditem.TooltipContentDelegate = () => { return new Button(window); };
80
81             }
82
83             grid.Show();
84             conformant.SetContent(grid);
85         }
86
87         private void List_ItemSelected(object sender, GenListItemEventArgs e)
88         {
89             Console.WriteLine("{0} Item was selected", (string)(e.Item.Data));
90         }
91     }
92 }