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.
19 using Tizen.NUI.BaseComponents;
20 using Tizen.NUI.Components;
22 namespace NUITizenGallery
24 public partial class BoxViewTest3Page : ContentPage
26 public BoxViewTest3Page()
28 InitializeComponent();
33 private void Subscribe()
35 red.ValueChanged += OnSliderValueChanged;
36 green.ValueChanged += OnSliderValueChanged;
37 blue.ValueChanged += OnSliderValueChanged;
38 alpha.ValueChanged += OnSliderValueChanged;
41 private void Unsubscribe()
43 red.ValueChanged -= OnSliderValueChanged;
44 green.ValueChanged -= OnSliderValueChanged;
45 blue.ValueChanged -= OnSliderValueChanged;
46 alpha.ValueChanged -= OnSliderValueChanged;
49 private void OnSliderValueChanged(object sender, SliderValueChangedEventArgs e)
54 private void ApplyColor()
56 float r = red.CurrentValue / 255f;
57 float g = green.CurrentValue / 255f;
58 float b = blue.CurrentValue / 255f;
59 float a = alpha.CurrentValue / 255f;
61 colorBox.BackgroundColor = new Color(r, g, b, a);
62 preColorBox.BackgroundColor = new Color(r * a, g * a, b * a, a);
64 output.Text = String.Format("R={0:000}, G={1:000}, B={2:000}, A={3:000}", r * 255f, g * 255f, b * 255f, a * 255f);
67 protected override void Dispose(DisposeTypes type)
74 if (type == DisposeTypes.Explicit)
77 RemoveAllChildren(true);
83 private void RemoveAllChildren(bool dispose = false)
85 RecursiveRemoveChildren(this, dispose);
88 private void RecursiveRemoveChildren(View parent, bool dispose)
95 int maxChild = (int)parent.ChildCount;
96 for (int i = maxChild - 1; i >= 0; --i)
98 View child = parent.GetChildAt((uint)i);
104 RecursiveRemoveChildren(child, dispose);
105 parent.Remove(child);