[NUI] sync with https://github.com/nui-dali/NUITizenGallery
[platform/core/csapi/tizenfx.git] / test / NUITizenGallery / Examples / BrushTest / BrushBackgroundTestPage.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 BrushBackgroundTestPage : ContentPage
24     {
25         public BrushBackgroundTestPage()
26         {
27             InitializeComponent();
28
29             ButtonSolid.Clicked += OnClickedSolid;
30             ButtonGradientLinear.Clicked += OnClickedLinear;
31             ButtonGradientRadial.Clicked += OnClickedRadial;
32         }
33
34         public void OnClickedSolid(object sender, ClickedEventArgs args)
35         {
36             ContentView.BackgroundColor = Color.Red;
37         }
38
39         public void OnClickedLinear(object sender, ClickedEventArgs args)
40         {
41             PropertyArray stopColor = new PropertyArray();
42             stopColor.Add(new PropertyValue(new Vector4(255.0f, 0.0f, 0.0f, 255.0f) / 255.0f));
43             stopColor.Add(new PropertyValue(new Vector4(0.0f, 255.0f, 0.0f, 255.0f) / 255.0f));
44
45             GradientVisual linearGradient = new GradientVisual();
46             linearGradient.StopColor = stopColor;
47             linearGradient.StartPosition = new Vector2(0.0f, 0.0f);
48             linearGradient.EndPosition = new Vector2(0.3f, 0.3f);
49             linearGradient.Origin = Visual.AlignType.TopBegin;
50
51             ContentView.Background = linearGradient.OutputVisualMap;
52         }
53
54         public void OnClickedRadial(object sender, ClickedEventArgs args)
55         {
56             PropertyArray stopColor = new PropertyArray();
57             stopColor.Add(new PropertyValue(new Vector4(255.0f, 0.0f, 0.0f, 255.0f) / 255.0f));
58             stopColor.Add(new PropertyValue(new Vector4(0.0f, 255.0f, 0.0f, 255.0f) / 255.0f));
59
60             GradientVisual radialGradient = new GradientVisual();
61             radialGradient.Center = new Vector2(0.0f, 0.0f);
62             radialGradient.Radius = 0.5f;
63             radialGradient.StopColor = stopColor;
64             radialGradient.Origin = Visual.AlignType.TopBegin;
65
66             ContentView.Background = radialGradient.OutputVisualMap;
67         }
68     }
69 }