[NUI] Change for Size2D property to own internalSize2D which is cashed to prevent...
[platform/core/csapi/tizenfx.git] / test / NUITizenGallery / Examples / GridTest / GridTest3Page.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 System;
18 using Tizen.NUI;
19 using Tizen.NUI.BaseComponents;
20 using Tizen.NUI.Components;
21
22 namespace NUITizenGallery
23 {
24     public partial class GridTest3Page : ContentPage
25     {
26         public GridTest3Page()
27         {
28             InitializeComponent();
29             var btnStyle = new ButtonStyle();
30             var btnStyle1 = new ButtonStyle();
31             var btnStyle2 = new ButtonStyle();
32             var btnStyle3 = new ButtonStyle();
33             btnStyle.BackgroundColor = new Selector<Tizen.NUI.Color>
34             {
35                 Normal = Tizen.NUI.Color.Blue,
36                 Pressed = Tizen.NUI.Color.DarkBlue,
37             };
38             btnStyle1.BackgroundColor = new Selector<Tizen.NUI.Color>
39             {
40                 Normal = Tizen.NUI.Color.Red,
41                 Pressed = Tizen.NUI.Color.DarkRed,
42             };
43             btnStyle2.BackgroundColor = new Selector<Tizen.NUI.Color>
44             {
45                 Normal = Tizen.NUI.Color.LightSeaGreen,
46                 Pressed = Tizen.NUI.Color.SeaGreen,
47             };
48             btnStyle3.BackgroundColor = new Selector<Tizen.NUI.Color>
49             {
50                 Normal = Tizen.NUI.Color.Yellow,
51                 Pressed = Tizen.NUI.Color.Orange,
52             };
53
54             btnClear.ApplyStyle(btnStyle);
55             btnUp.ApplyStyle(btnStyle);
56             btnProc.ApplyStyle(btnStyle);
57             btnDiv.ApplyStyle(btnStyle);
58             btnMultiply.ApplyStyle(btnStyle);
59             btnMinus.ApplyStyle(btnStyle);
60             btnPlus.ApplyStyle(btnStyle);
61             btnDot.ApplyStyle(btnStyle3);
62             btnEqual.ApplyStyle(btnStyle1);
63             btn0.ApplyStyle(btnStyle2);
64             btn1.ApplyStyle(btnStyle2);
65             btn2.ApplyStyle(btnStyle2);
66             btn3.ApplyStyle(btnStyle2);
67             btn4.ApplyStyle(btnStyle2);
68             btn5.ApplyStyle(btnStyle2);
69             btn6.ApplyStyle(btnStyle2);
70             btn7.ApplyStyle(btnStyle2);
71             btn8.ApplyStyle(btnStyle2);
72             btn9.ApplyStyle(btnStyle2);
73         }
74         protected override void Dispose(DisposeTypes type)
75         {
76             if (Disposed)
77             {
78                 return;
79             }
80
81             if (type == DisposeTypes.Explicit)
82             {
83                 RemoveAllChildren(true);
84             }
85
86             base.Dispose(type);
87         }
88
89         private void RemoveAllChildren(bool dispose = false)
90         {
91             RecursiveRemoveChildren(this, dispose);
92         }
93
94         private void RecursiveRemoveChildren(View parent, bool dispose)
95         {
96             if (parent == null)
97             {
98                 return;
99             }
100
101             int maxChild = (int)parent.ChildCount;
102             for (int i = maxChild - 1; i >= 0; --i)
103             {
104                 View child = parent.GetChildAt((uint)i);
105                 if (child == null)
106                 {
107                     continue;
108                 }
109
110                 RecursiveRemoveChildren(child, dispose);
111                 parent.Remove(child);
112                 if (dispose)
113                 {
114                     child.Dispose();
115                 }
116             }
117         }
118     }
119 }
120