Add SetFormatCallback in MultiButtonEntry
[platform/core/csapi/tizenfx.git] / test / ElmSharp.Test / TC / MultibuttonEntryTest2.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 System.Collections.Generic;
19 using ElmSharp;
20
21 namespace ElmSharp.Test
22 {
23     class MultiButtonEntryTest2 : TestCaseBase
24     {
25         public override string TestName => "MultiButtonEntryTest2";
26         public override string TestDescription => "To test basic operation of MultiButtonEntry";
27
28         bool _setCallback = false;
29
30         public override void Run(Window window)
31         {
32             Background bg = new Background(window);
33             bg.Color = Color.White;
34             bg.Move(0, 0);
35             bg.Resize(window.ScreenSize.Width, window.ScreenSize.Height);
36             bg.Show();
37
38             MultiButtonEntry mbe = new MultiButtonEntry(window)
39             {
40                 IsEditable = true,
41                 IsExpanded = true,
42                 Text = "To: "
43             };
44
45             mbe.Append("Append1");
46             mbe.Append("Append2");
47             mbe.Append("Append3");
48             mbe.Append("Append4");
49             mbe.Append("Append5");
50             mbe.Append("Append6");
51             mbe.Append("Append7");
52             mbe.Append("Append8");
53             mbe.Append("Append9");
54             mbe.Append("Append10");
55             mbe.Append("Append11");
56             mbe.Append("Append12");
57
58             Label label1 = new Label(window)
59             {
60                 Text = "MultiButtonEntry Test",
61                 Color = Color.Blue
62             };
63
64             var expandButton = new Button(window)
65             {
66                 Text = "IsExpanded",
67                 AlignmentX = -1,
68                 WeightX = 1,
69             };
70
71             var formatButton = new Button(window)
72             {
73                 Text = "format",
74                 AlignmentX = -1,
75                 WeightX = 1,
76             };
77
78             expandButton.Clicked += (sender, e) =>
79             {
80                 mbe.IsExpanded = !mbe.IsExpanded;
81             };
82
83             formatButton.Clicked += (sender, e) =>
84             {
85                 if (_setCallback)
86                 {
87                     mbe.SetFormatCallback(null);
88                     _setCallback = false;
89                 }
90                 else
91                 {
92                     mbe.SetFormatCallback((count) => { return "(" + count + ")"; });
93                     _setCallback = true;
94                 }
95             };
96
97             label1.Resize(600, 100);
98             label1.Move(50, 50);
99             label1.Show();
100
101             mbe.Resize(600, 600);
102             mbe.Move(0, 100);
103             mbe.Show();
104
105             expandButton.Resize(200, 100);
106             expandButton.Move(50, 700);
107             expandButton.Show();
108
109             formatButton.Resize(200, 100);
110             formatButton.Move(300, 700);
111             formatButton.Show();
112         }
113     }
114 }