Revert "[NUI] Dialog and AlertDialog code refactoring with adding DialogPage"
[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             var dialogPage = new ContentPage()
37             {
38                 Content = button,
39             };
40             window.GetDefaultNavigator().Push(dialogPage);
41         }
42
43         public void Deactivate()
44         {
45             var window = NUIApplication.GetDefaultWindow();
46             var newPageCount = window.GetDefaultNavigator().NavigationPages.Count;
47
48             for (int i = 0; i < (newPageCount - oldPageCount); i++)
49             {
50                 window.GetDefaultNavigator().Pop();
51             }
52         }
53     }
54 }