[NUI] Change for Size2D property to own internalSize2D which is cashed to prevent...
[platform/core/csapi/tizenfx.git] / test / NUITizenGallery / Examples / KeyboardTest / KeyboardTest1Page.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;
18 using Tizen.NUI.BaseComponents;
19 using Tizen.NUI.Binding;
20 using Tizen.NUI.Components;
21
22 namespace NUITizenGallery
23 {
24     public partial class KeyboardTest1Page : ContentPage
25     {
26         public KeyboardTest1Page()
27         {
28             InitializeComponent();
29             dateTimeKeyboardButton.Command = new Command(() => SetOutputMethod(InputMethod.PanelLayoutType.Datetime));
30             emailKeyboardButton.Command = new Command(() => SetOutputMethod(InputMethod.PanelLayoutType.Email));
31             emoticonKeyboardButton.Command = new Command(() => SetOutputMethod(InputMethod.PanelLayoutType.Emoticon));
32             hexKeyboardButton.Command = new Command(() => SetOutputMethod(InputMethod.PanelLayoutType.HEX));
33             ipLayoutKeyboardButton.Command = new Command(() => SetOutputMethod(InputMethod.PanelLayoutType.IP));
34             monthKeyboardButton.Command = new Command(() => SetOutputMethod(InputMethod.PanelLayoutType.Month));
35             normalKeyboardButton.Command = new Command(() => SetOutputMethod(InputMethod.PanelLayoutType.Normal));
36             numberKeyboardButton.Command = new Command(() => SetOutputMethod(InputMethod.PanelLayoutType.Number));
37             numberOnlyKeyboardButton.Command = new Command(() => SetOutputMethod(InputMethod.PanelLayoutType.NumberOnly));
38             passworKeyboarddButton.Command = new Command(() => SetOutputMethod(InputMethod.PanelLayoutType.Password));
39             phoneNumberKeyboardButton.Command = new Command(() => SetOutputMethod(InputMethod.PanelLayoutType.PhoneNumber));
40             terminalKeyboardButton.Command = new Command(() => SetOutputMethod(InputMethod.PanelLayoutType.Terminal));
41             urlKeyboarddButton.Command = new Command(() => SetOutputMethod(InputMethod.PanelLayoutType.URL));
42         }
43
44         private void SetOutputMethod(InputMethod.PanelLayoutType inputLayoutType)
45         {
46             InputMethod im = new InputMethod();
47             im.PanelLayout = inputLayoutType;
48             textField.InputMethodSettings = im.OutputMap;
49         }
50
51         protected override void Dispose(DisposeTypes type)
52         {
53             if (Disposed)
54             {
55                 return;
56             }
57
58             if (type == DisposeTypes.Explicit)
59             {
60                 RemoveAllChildren(true);
61             }
62
63             base.Dispose(type);
64         }
65
66         private void RemoveAllChildren(bool dispose = false)
67         {
68             RecursiveRemoveChildren(this, dispose);
69         }
70
71         private void RecursiveRemoveChildren(View parent, bool dispose)
72         {
73             if (parent == null)
74             {
75                 return;
76             }
77
78             int maxChild = (int)parent.ChildCount;
79             for (int i = maxChild - 1; i >= 0; --i)
80             {
81                 View child = parent.GetChildAt((uint)i);
82                 if (child == null)
83                 {
84                     continue;
85                 }
86                 RecursiveRemoveChildren(child, dispose);
87                 parent.Remove(child);
88                 if (dispose)
89                 {
90                     child.Dispose();
91                 }
92             }
93         }
94     }
95 }