Merge "[Telephony] Sample App implementation."
[platform/core/csapi/tizenfx.git] / test / ElmSharp.Test / TC / SliderTest1.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 System.Linq;
20 using System.Text;
21 using System.Threading.Tasks;
22
23 namespace ElmSharp.Test
24 {
25     class SliderTest1 : TestCaseBase
26     {
27         public override string TestName => "SliderTest1";
28         public override string TestDescription => "To test basic operation of Slider";
29
30         public override void Run(Window window)
31         {
32             Conformant conformant = new Conformant(window);
33             conformant.Show();
34             Table table = new Table(window);
35             conformant.SetContent(table);
36             table.Show();
37
38             Slider sld1 = new Slider(window)
39             {
40                 Text = "Slider Test",
41                 IndicatorFormat = "%1.2f meters",
42                 Minimum = 0.0,
43                 Maximum = 100.0,
44                 Value = 0.1,
45                 AlignmentX = -1,
46                 AlignmentY = 0.5,
47                 WeightX = 1,
48                 WeightY = 1,
49                 IsIndicatorFocusable = true
50             };
51
52             Button btn = new Button(window)
53             {
54                 AlignmentX = -1,
55                 AlignmentY = 0,
56                 WeightX = 1,
57                 WeightY = 1,
58                 Text = "Set IsIndicatorFocusable"
59             };
60             btn.Clicked += (s, e) =>
61             {
62                 if (sld1.IsIndicatorFocusable)
63                 {
64                     sld1.IsIndicatorFocusable = false;
65                 }
66                 else
67                 {
68                     sld1.IsIndicatorFocusable = true;
69                 }
70             };
71
72             Button btn2 = new Button(window)
73             {
74                 AlignmentX = -1,
75                 AlignmentY = 0,
76                 WeightX = 1,
77                 WeightY = 1,
78                 Text = "Set IndicatorVisibleMode"
79             };
80             btn2.Clicked += (s, e) =>
81             {
82                 if (sld1.IndicatorVisibleMode == SliderIndicatorVisibleMode.Default)
83                 {
84                     sld1.IndicatorVisibleMode = SliderIndicatorVisibleMode.Always;
85                     btn2.Text = "Always";
86                 }
87                 else if (sld1.IndicatorVisibleMode == SliderIndicatorVisibleMode.Always)
88                 {
89                     sld1.IndicatorVisibleMode = SliderIndicatorVisibleMode.OnFocus;
90                     btn2.Text = "OnFocus";
91                 }
92                 else if (sld1.IndicatorVisibleMode == SliderIndicatorVisibleMode.OnFocus)
93                 {
94                     sld1.IndicatorVisibleMode = SliderIndicatorVisibleMode.None;
95                     btn2.Text = "None";
96                 }
97                 else
98                 {
99                     sld1.IndicatorVisibleMode = SliderIndicatorVisibleMode.Default;
100                     btn2.Text = "Default";
101                 }
102             };
103
104             Label lb1 = new Label(window)
105             {
106                 AlignmentX = -1,
107                 AlignmentY = 0,
108                 WeightX = 1,
109                 WeightY = 1
110             };
111
112             table.Pack(sld1, 1, 1, 2, 1);
113             table.Pack(btn, 1, 2, 2, 1);
114             table.Pack(btn2, 1, 3, 2, 1);
115             table.Pack(lb1, 1, 4, 2, 1);
116
117             sld1.Show();
118             btn.Show();
119             lb1.Show();
120             btn2.Show();
121
122             sld1.ValueChanged += (s, e) =>
123             {
124                 lb1.Text = string.Format("Value Changed: {0}", sld1.Value);
125                 lb1.EdjeObject["elm.text"].TextStyle = "DEFAULT='color=#ffffff'";
126             };
127         }
128     }
129 }