[NUI] integration from DevelNUI to master (#3309)
[platform/core/csapi/tizenfx.git] / test / NUITizenGallery / Examples / BrushComponentsTest / BrushComponentsTest.xaml.cs
1 /*
2  * Copyright(c) 2021 Samsung Electronics Co., Ltd.
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 Tizen.NUI.BaseComponents;
18 using Tizen.NUI.Components;
19 using Tizen.NUI;
20
21 namespace NUITizenGallery
22 {
23     public partial class BrushComponentsTestPage : View
24     {
25         public BrushComponentsTestPage()
26         {
27             InitializeComponent();
28
29             LinearLayout pageLayout = new LinearLayout();
30             pageLayout.LinearOrientation = LinearLayout.Orientation.Vertical;
31             pageLayout.CellPadding = new Size2D(10, 10);
32             pageLayout.Padding = new Extents(10, 10, 10, 10);
33             this.Layout = pageLayout;
34
35             ButtonSolid.Clicked += OnClickedSolid;
36             ButtonGradientLinear.Clicked += OnClickedLinear;
37             ButtonGradientRadial.Clicked += OnClickedRadial;
38         }
39
40         public void OnClickedSolid(object sender, ClickedEventArgs args) 
41         {
42             ViewTest1.BackgroundColor = Color.Red;
43             ViewTest2.BackgroundColor = Color.Red;
44             ViewTest3.BackgroundColor = Color.Red;
45         }
46
47         public void OnClickedLinear(object sender, ClickedEventArgs args) 
48         {
49             PropertyArray stopColor = new PropertyArray();
50             stopColor.Add(new PropertyValue(new Vector4(255.0f, 0.0f, 0.0f, 255.0f) / 255.0f));
51             stopColor.Add(new PropertyValue(new Vector4(0.0f, 255.0f, 0.0f, 255.0f) / 255.0f));
52
53             GradientVisual linearGradient = new GradientVisual();
54             linearGradient.StopColor = stopColor;
55             linearGradient.StartPosition = new Vector2(0.0f, 0.0f);
56             linearGradient.EndPosition = new Vector2(0.3f, 0.3f);
57             linearGradient.Origin = Visual.AlignType.TopBegin;
58
59             ViewTest1.Background = linearGradient.OutputVisualMap;
60             ViewTest2.Background = linearGradient.OutputVisualMap;
61             ViewTest3.Background = linearGradient.OutputVisualMap;
62         }
63
64         public void OnClickedRadial(object sender, ClickedEventArgs args) 
65         {
66             PropertyArray stopColor = new PropertyArray();
67             stopColor.Add(new PropertyValue(new Vector4(255.0f, 0.0f, 0.0f, 255.0f) / 255.0f));
68             stopColor.Add(new PropertyValue(new Vector4(0.0f, 255.0f, 0.0f, 255.0f) / 255.0f));
69
70             GradientVisual radialGradient = new GradientVisual();
71             radialGradient.Center = new Vector2(0.0f, 0.0f);
72             radialGradient.Radius = 0.5f;
73             radialGradient.StopColor = stopColor;
74             radialGradient.Origin = Visual.AlignType.TopBegin;
75
76             ViewTest1.Background = radialGradient.OutputVisualMap;
77             ViewTest2.Background = radialGradient.OutputVisualMap;
78             ViewTest3.Background = radialGradient.OutputVisualMap;
79         }
80     }
81 }