[NUI] Supports to set/get full screen sized window
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Samples / Tizen.NUI.Samples / Samples / WindowBorderTest.cs
1 using Tizen.NUI.BaseComponents;
2 using Tizen.NUI.Components;
3 using static Tizen.NUI.Window;
4
5 namespace Tizen.NUI.Samples
6 {
7     public class WindowBorderSample : IExample
8     {
9         private View parent1;
10         private Navigator navigator;
11         private ContentPage firstPage, secondPage;
12         private Button firstButton, secondButton;
13         private Button textButton;
14         private Button textButton1;
15         private void Popped(object sender, PoppedEventArgs args)
16         {
17             global::System.Console.WriteLine("Page is popped!");
18             args.Page.Dispose();
19
20             if (args.Page == firstPage)
21             {
22                 firstPage = null;
23             }
24             else
25             {
26                 secondPage = null;
27             }
28
29             navigator.Popped -= Popped;
30         }
31
32         public void Activate()
33         {
34             Window window = NUIApplication.GetDefaultWindow();
35
36             navigator = new Navigator()
37            {
38                WidthResizePolicy = ResizePolicyType.FillToParent,
39                HeightResizePolicy = ResizePolicyType.FillToParent
40            };
41
42             window.Add(navigator);
43
44             CreateFirstPage();
45
46             textButton = new Button();
47             textButton.BackgroundImage = CommonResource.GetTVResourcePath() + "component/c_buttonbasic/c_basic_button_white_bg_normal_9patch.png";
48             textButton.BackgroundImageBorder = new Rectangle(4, 4, 5, 5);
49             textButton.Size = new Size(100, 80);
50             textButton.TextLabel.Text = "Left";
51
52             textButton.PositionUsesPivotPoint = true;
53             textButton.ParentOrigin = Tizen.NUI.ParentOrigin.BottomLeft;
54             textButton.PivotPoint = Tizen.NUI.ParentOrigin.BottomLeft;
55             window.Add(textButton);
56
57             textButton.Clicked += (object sender, ClickedEventArgs e) =>
58             {
59                 Window.Instance.RequestResizeToServer(ResizeDirection.BottomLeft);
60             };
61
62             textButton1 = new Button();
63             textButton1.BackgroundImage = CommonResource.GetTVResourcePath() + "component/c_buttonbasic/c_basic_button_white_bg_normal_9patch.png";
64             textButton1.BackgroundImageBorder = new Rectangle(4, 4, 5, 5);
65             textButton1.Size = new Size(100, 80);
66             textButton1.TextLabel.Text = "Right";
67
68             textButton1.PositionUsesPivotPoint = true;
69             textButton1.ParentOrigin = Tizen.NUI.ParentOrigin.BottomRight;
70             textButton1.PivotPoint = Tizen.NUI.ParentOrigin.BottomRight;
71             window.Add(textButton1);
72
73             textButton1.Clicked += (object sender, ClickedEventArgs e) =>
74             {
75                 Window.Instance.RequestResizeToServer(ResizeDirection.BottomRight);
76             };
77         }
78
79         private void CreateFirstPage()
80         {
81             firstButton = new Button()
82             {
83                 Text = "First Page",
84                 WidthResizePolicy = ResizePolicyType.FillToParent,
85                 HeightResizePolicy = ResizePolicyType.FillToParent,
86             };
87             firstButton.Clicked += (object sender, ClickedEventArgs e) =>
88             {
89                 CreateSecondPage();
90             };
91
92             parent1 = new View()
93             {
94                 WidthResizePolicy = ResizePolicyType.FillToParent,
95                 HeightResizePolicy = ResizePolicyType.FillToParent,
96                 Layout = new LinearLayout()
97                 {
98                     VerticalAlignment = VerticalAlignment.Top,
99                     LinearOrientation = LinearLayout.Orientation.Vertical,
100                     CellPadding = new Size(50, 50),
101                 }
102             };
103
104             parent1.Add(firstButton);
105             firstPage = new ContentPage()
106             {
107                 AppBar = new AppBar()
108                 {
109                     AutoNavigationContent = false,
110                     Title = "FirstPage",
111                 },
112                 Content = parent1,
113             };
114             firstPage.Appearing += (object sender, PageAppearingEventArgs e) =>
115             {
116                 global::System.Console.WriteLine("First Page is appearing!");
117             };
118             firstPage.Disappearing += (object sender, PageDisappearingEventArgs e) =>
119             {
120                 global::System.Console.WriteLine("First Page is disappearing!");
121             };
122
123             navigator.Push(firstPage);
124         }
125
126         private void CreateSecondPage()
127         {
128             secondButton = new Button()
129             {
130                 Text = "Second Page",
131                 WidthResizePolicy = ResizePolicyType.FillToParent,
132                 HeightResizePolicy = ResizePolicyType.FillToParent,
133             };
134             secondButton.Clicked += (object sender, ClickedEventArgs e) =>
135             {
136                 navigator.Pop();
137             };
138
139             secondPage = new ContentPage()
140             {
141                 AppBar = new AppBar()
142                 {
143                     Title = "SecondPage",
144                 },
145                 Content = secondButton,
146             };
147             secondPage.Appearing += (object sender, PageAppearingEventArgs e) =>
148             {
149                 global::System.Console.WriteLine("Second Page is appearing!");
150             };
151             secondPage.Disappearing += (object sender, PageDisappearingEventArgs e) =>
152             {
153                 global::System.Console.WriteLine("Second Page is disappearing!");
154             };
155
156             navigator.Push(secondPage);
157         }
158
159         public void Deactivate()
160         {
161             if (navigator != null)
162             {
163                 NUIApplication.GetDefaultWindow().Remove(navigator);
164
165                 navigator.Dispose();
166                 navigator = null;
167                 firstButton = null;
168                 firstPage = null;
169                 secondButton = null;
170                 secondPage = null;
171             }
172         }
173     }
174 }