Follow formatting NUI
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Controls / Navigation / Page.cs
1 /*
2  * Copyright(c) 2020 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 System;
18 using System.Collections.Generic;
19 using System.ComponentModel;
20 using Tizen.NUI.BaseComponents;
21 using Tizen.NUI.Binding;
22 using System.Windows.Input;
23
24 namespace Tizen.NUI.Components
25 {
26     /// <summary>
27     /// PageAppearingEventArgs is a class to record page appearing event arguments which will be sent to user.
28     /// </summary>
29     [EditorBrowsable(EditorBrowsableState.Never)]
30     public class PageAppearingEventArgs : EventArgs
31     {
32     }
33
34     /// <summary>
35     /// PageDisappearingEventArgs is a class to record page disappearing event arguments which will be sent to user.
36     /// </summary>
37     [EditorBrowsable(EditorBrowsableState.Never)]
38     public class PageDisappearingEventArgs : EventArgs
39     {
40     }
41
42     /// <summary>
43     /// The Page class is a class which is an element of navigation.
44     /// </summary>
45     [EditorBrowsable(EditorBrowsableState.Never)]
46     public class Page : Control
47     {
48         private View _content = null;
49
50         /// <summary>
51         /// Creates a new instance of a Page.
52         /// </summary>
53         /// <param name="content">The content to set to Content of Page.</param>
54         [EditorBrowsable(EditorBrowsableState.Never)]
55         public Page(View content = null) : base()
56         {
57             //Page fills to parent by default.
58             WidthResizePolicy = ResizePolicyType.FillToParent;
59             HeightResizePolicy = ResizePolicyType.FillToParent;
60
61             if (content)
62             {
63                 Content = content;
64             }
65         }
66
67         /// <summary>
68         /// Content of Page. Content is added to Children automatically.
69         /// </summary>
70         [EditorBrowsable(EditorBrowsableState.Never)]
71         public View Content
72         {
73             get
74             {
75                 return _content;
76             }
77             set
78             {
79                 if (_content)
80                 {
81                     if (_content != value)
82                     {
83                         Remove(_content);
84                         _content = value;
85                         Add(value);
86                     }
87                 }
88                 else
89                 {
90                     _content = value;
91                     Add(value);
92                 }
93             }
94         }
95
96         /// <summary>
97         /// An event for the page appearing signal which can be used to subscribe or unsubscribe the event handler provided by the user.
98         /// </summary>
99         [EditorBrowsable(EditorBrowsableState.Never)]
100         public event EventHandler<PageAppearingEventArgs> Appearing;
101
102         /// <summary>
103         /// An event for the page disappearing signal which can be used to subscribe or unsubscribe the event handler provided by the user.
104         /// </summary>
105         [EditorBrowsable(EditorBrowsableState.Never)]
106         public event EventHandler<PageDisappearingEventArgs> Disappearing;
107
108         internal void InvokeAppearing()
109         {
110             Appearing?.Invoke(this, new PageAppearingEventArgs());
111         }
112
113         internal void InvokeDisappearing()
114         {
115             Disappearing?.Invoke(this, new PageDisappearingEventArgs());
116         }
117     }
118 }