b5a07e3d62af5200ce7a7ac7a667b03ff53e0509
[platform/core/csapi/tizenfx.git] / test / NUITizenGallery / Examples / AlertDialogTest / AlertDialogTestPage.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.Components;
20
21 namespace NUITizenGallery
22 {
23     public partial class AlertDialogTestPage : ContentPage
24     {
25         public AlertDialogTestPage()
26         {
27             InitializeComponent();
28
29             buttonOneAction.Clicked += ButtonOneActionClicked;
30             buttonTwoActions.Clicked += ButtonTwoActionsClicked;
31             buttonNoTitle.Clicked += ButtonNoTitleClicked;
32             buttonNoMessage.Clicked += ButtonNoMessageClicked;
33             buttonTwoAlertDialog.Clicked += ButtonTwoAlertDialogClicked;
34             buttonNewAlertDialog.Clicked += ButtonNewAlertDialogClicked;
35             count = 0;
36         }
37
38         private int count;
39
40         private void ButtonOneActionClicked(object sender, ClickedEventArgs args)
41         {
42             var button = new Button()
43             {
44                 Text = "OK",
45             };
46
47             button.Clicked += (object s, ClickedEventArgs a) =>
48             {
49                 Navigator?.Pop();
50             };
51
52             DialogPage.ShowAlertDialog("Title", "Message", button);
53         }
54
55         private void ButtonTwoActionsClicked(object sender, ClickedEventArgs args)
56         {
57             var button = new Button()
58             {
59                 Text = "Cancel",
60             };
61
62             button.Clicked += (object s, ClickedEventArgs a) =>
63             {
64                 Navigator?.Pop();
65             };
66
67             var button2 = new Button()
68             {
69                 Text = "OK",
70             };
71
72             button2.Clicked += (object s, ClickedEventArgs a) =>
73             {
74                 Navigator?.Pop();
75             };
76
77             DialogPage.ShowAlertDialog("Title", "Message", button, button2);
78         }
79
80         private void ButtonNoTitleClicked(object sender, ClickedEventArgs args)
81         {
82             var button = new Button()
83             {
84                 Text = "Cancel",
85             };
86
87             button.Clicked += (object s, ClickedEventArgs a) =>
88             {
89                 Navigator?.Pop();
90             };
91
92             var button2 = new Button()
93             {
94                 Text = "OK",
95             };
96
97             button2.Clicked += (object s, ClickedEventArgs a) =>
98             {
99                 Navigator?.Pop();
100             };
101
102             DialogPage.ShowAlertDialog(null, "Message", button, button2);
103         }
104
105         private void ButtonNoMessageClicked(object sender, ClickedEventArgs args)
106         {
107             var button = new Button()
108             {
109                 Text = "Cancel",
110             };
111
112             button.Clicked += (object s, ClickedEventArgs a) =>
113             {
114                 Navigator?.Pop();
115             };
116
117             var button2 = new Button()
118             {
119                 Text = "OK",
120             };
121
122             button2.Clicked += (object s, ClickedEventArgs a) =>
123             {
124                 Navigator?.Pop();
125             };
126
127             DialogPage.ShowAlertDialog("Title", null, button, button2);
128         }
129
130         private void ButtonTwoAlertDialogClicked(object sender, ClickedEventArgs args)
131         {
132             var button = new Button()
133             {
134                 Text = "OK",
135             };
136
137             button.Clicked += (object s, ClickedEventArgs a) =>
138             {
139                 Navigator?.Pop();
140             };
141
142             DialogPage.ShowAlertDialog("Title", "Message", button);
143
144             var button2 = new Button()
145             {
146                 Text = "OK2",
147             };
148
149             button2.Clicked += (object s, ClickedEventArgs a) =>
150             {
151                 Navigator?.Pop();
152             };
153
154             DialogPage.ShowAlertDialog("Title2", "Message2", button2);
155         }
156
157         private void ButtonNewAlertDialogClicked(object sender, ClickedEventArgs args)
158         {
159             var button = new Button()
160             {
161                 Text = "Cancel",
162             };
163
164             button.Clicked += (object s, ClickedEventArgs a) =>
165             {
166                 Navigator?.Pop();
167             };
168
169             var button2 = new Button()
170             {
171                 Text = $"New AlertDialog {++count}",
172             };
173
174             button2.Clicked += (object s, ClickedEventArgs a) =>
175             {
176                 ButtonNewAlertDialogClicked(s, a);
177             };
178
179             DialogPage.ShowAlertDialog("Title", "Message", button, button2);
180         }
181     }
182 }