[NUI] Add Dialog class
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Samples / Tizen.NUI.Samples / Samples / DialogSample.cs
1 using Tizen.NUI.BaseComponents;
2 using Tizen.NUI.Components;
3
4 namespace Tizen.NUI.Samples
5 {
6     public class DialogSample : IExample
7     {
8         private int oldPageCount = 0;
9
10         public void Activate()
11         {
12             var window = NUIApplication.GetDefaultWindow();
13
14             oldPageCount = window.GetDefaultNavigator().NavigationPages.Count;
15
16             var button = new Button()
17             {
18                 Text = "Click to show Dialog",
19                 WidthResizePolicy = ResizePolicyType.FillToParent,
20                 HeightResizePolicy = ResizePolicyType.FillToParent
21             };
22
23             button.Clicked += (object sender, ClickedEventArgs e) =>
24             {
25                 var textLabel = new TextLabel("Message")
26                 {
27                     BackgroundColor = Color.White,
28                     Size = new Size(180, 180),
29                     HorizontalAlignment = HorizontalAlignment.Center,
30                     VerticalAlignment = VerticalAlignment.Center
31                 };
32
33                 Navigator.ShowDialog(textLabel);
34             };
35
36             window.GetDefaultNavigator().Push(new Page(button));
37         }
38
39         public void Deactivate()
40         {
41             var window = NUIApplication.GetDefaultWindow();
42             var newPageCount = window.GetDefaultNavigator().NavigationPages.Count;
43
44             for (int i = 0; i < (newPageCount - oldPageCount); i++)
45             {
46                 window.GetDefaultNavigator().Pop();
47             }
48         }
49     }
50 }