2 * Copyright(c) 2021 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 using Tizen.NUI.BaseComponents;
18 using Tizen.NUI.Components;
21 namespace NUITizenGallery
23 public partial class BrushViewerTestPage : View
25 public BrushViewerTestPage()
27 InitializeComponent();
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;
35 ButtonSolid.Clicked += OnClickedSolid;
36 ButtonGradientLinear.Clicked += OnClickedLinear;
37 ButtonGradientRadial.Clicked += OnClickedRadial;
40 public void OnClickedSolid(object sender, ClickedEventArgs args)
42 BrushViewer.RemoveVisual("radialGradient");
43 BrushViewer.RemoveVisual("linearGradient");
44 BrushViewer.BackgroundColor = new Color(1f, 0f, 0f, 1f);
47 public void OnClickedLinear(object sender, ClickedEventArgs args)
49 ///Create new visual view and gradient visual instances
50 GradientVisual gradientVisualMap1 = new GradientVisual();
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));
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;
61 BrushViewer.RemoveVisual("radialGradient");
62 BrushViewer.AddVisual("linearGradient", gradientVisualMap1);
65 public void OnClickedRadial(object sender, ClickedEventArgs args)
67 GradientVisual gradientVisualMap1 = new GradientVisual();
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));
73 gradientVisualMap1.Center = new Vector2(0.0f, 0.0f);
74 gradientVisualMap1.Radius = 0.5f;
75 gradientVisualMap1.StopColor = stopColor;
76 gradientVisualMap1.Origin = Visual.AlignType.TopBegin;
78 BrushViewer.RemoveVisual("linearGradient");
79 BrushViewer.AddVisual("radialGradient", gradientVisualMap1);