Merge "[Telephony] Sample App implementation."
[platform/core/csapi/tizenfx.git] / test / ElmSharp.Test / TC / ImageTest2.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.IO;
19
20 namespace ElmSharp.Test
21 {
22     public class ImageTest2 : TestCaseBase
23     {
24         public override string TestName => "ImageTest2";
25         public override string TestDescription => "To test basic operation of Image";
26
27         Image image;
28         Label lbInfo;
29
30         public override void Run(Window window)
31         {
32             Conformant conformant = new Conformant(window);
33             conformant.Show();
34             Box box = new Box(window);
35             conformant.SetContent(box);
36             box.Show();
37
38             Box buttonBox1 = new Box(window) {
39                 IsHorizontal = true,
40                 AlignmentX = -1,
41                 AlignmentY = 0,
42             };
43             buttonBox1.Show();
44
45             Button btnFile1 = new Button(window) {
46                 Text = "Blue",
47                 AlignmentX = -1,
48                 AlignmentY = -1,
49                 WeightX = 1,
50                 WeightY = 1
51             };
52             btnFile1.Show();
53
54             Button btnFile2 = new Button(window) {
55                 Text = "Default",
56                 AlignmentX = -1,
57                 AlignmentY = -1,
58                 WeightX = 1,
59                 WeightY = 1
60             };
61             btnFile2.Show();
62
63             Button btnFile3 = new Button(window) {
64                 Text = "Aspect",
65                 AlignmentX = -1,
66                 AlignmentY = -1,
67                 WeightX = 1,
68                 WeightY = 1
69             };
70             btnFile3.Show();
71
72             Button btnFile4 = new Button(window) {
73                 Text = "Rotate",
74                 AlignmentX = -1,
75                 AlignmentY = -1,
76                 WeightX = 1,
77                 WeightY = 1
78             };
79             btnFile4.Show();
80
81             buttonBox1.PackEnd(btnFile1);
82             buttonBox1.PackEnd(btnFile2);
83             buttonBox1.PackEnd(btnFile3);
84             buttonBox1.PackEnd(btnFile4);
85
86             lbInfo = new Label(window) {
87                 Color = Color.White,
88                 AlignmentX = -1,
89                 AlignmentY = 0,
90                 WeightX = 1
91             };
92             lbInfo.Show();
93
94             image = new Image(window) {
95                 IsFixedAspect = true,
96                 AlignmentX = -1,
97                 AlignmentY = -1,
98                 WeightX = 1,
99                 WeightY = 1
100             };
101             image.Show();
102             image.Load(Path.Combine(TestRunner.ResourceDir, "picture.png"));
103             image.Clicked += (s, e) =>
104             {
105                 Console.WriteLine("Image has been clicked. (IsFixedAspect = {0}", image.IsFixedAspect);
106                 image.IsFixedAspect = image.IsFixedAspect == true ? false : true;
107             };
108
109             btnFile1.Clicked += (s, e) => { image.BackgroundColor = Color.Blue; UpdateLabelText(image.BackgroundColor.ToString()); };
110             btnFile2.Clicked += (s, e) => { image.BackgroundColor = Color.Default; UpdateLabelText(image.BackgroundColor.ToString()); };
111             btnFile3.Clicked += (s, e) => { image.IsFixedAspect = image.IsFixedAspect == true ? false : true; };
112             btnFile4.Clicked += (s, e) => { image.Orientation = image.Orientation == ImageOrientation.None ? ImageOrientation.Rotate270 : ImageOrientation.None; };
113
114             box.PackEnd(buttonBox1);
115             box.PackEnd(lbInfo);
116             box.PackEnd(image);
117         }
118
119         void UpdateLabelText(string text)
120         {
121             lbInfo.Text = "<span color=#ffffff font_size=20> BackgroundColor => " + text + "</span>";
122         }
123     }
124 }