b132c11cd10e23ee97c9e1906533a491becbbda5
[platform/core/csapi/tizenfx.git] / test / NUITizenGallery / Examples / BrushViewerTest / BrushViewerTest.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 BrushViewerTestPage : View
24     {
25         public BrushViewerTestPage()
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             BrushViewer.RemoveVisual("radialGradient");
43             BrushViewer.RemoveVisual("linearGradient");
44             BrushViewer.BackgroundColor = new Color(1f, 0f, 0f, 1f);
45         }
46
47         public void OnClickedLinear(object sender, ClickedEventArgs args)
48         {
49             ///Create new visual view and gradient visual instances
50             GradientVisual gradientVisualMap1 = new GradientVisual();
51
52             PropertyArray stopColor = new PropertyArray();
53             stopColor.Add(new PropertyValue(new Vector4(255.0f, 0.0f, 0.0f, 255.0f) / 255.0f));
54             stopColor.Add(new PropertyValue(new Vector4(0.0f, 255.0f, 0.0f, 255.0f) / 255.0f));
55
56             gradientVisualMap1.StartPosition = new Vector2(0.0f, 0.0f);
57             gradientVisualMap1.EndPosition = new Vector2(0.3f, 0.3f);
58             gradientVisualMap1.StopColor = stopColor;
59             gradientVisualMap1.Origin = Visual.AlignType.TopBegin;
60
61             BrushViewer.RemoveVisual("radialGradient");
62             BrushViewer.AddVisual("linearGradient", gradientVisualMap1);
63         }
64
65         public void OnClickedRadial(object sender, ClickedEventArgs args)
66         {
67             GradientVisual gradientVisualMap1 = new GradientVisual();
68
69             PropertyArray stopColor = new PropertyArray();
70             stopColor.Add(new PropertyValue(new Vector4(255.0f, 0.0f, 0.0f, 255.0f) / 255.0f));
71             stopColor.Add(new PropertyValue(new Vector4(0.0f, 255.0f, 0.0f, 255.0f) / 255.0f));
72
73             gradientVisualMap1.Center = new Vector2(0.0f, 0.0f);
74             gradientVisualMap1.Radius = 0.5f;
75             gradientVisualMap1.StopColor = stopColor;
76             gradientVisualMap1.Origin = Visual.AlignType.TopBegin;
77
78             BrushViewer.RemoveVisual("linearGradient");
79             BrushViewer.AddVisual("radialGradient", gradientVisualMap1);
80         }
81     }
82 }