[NUI] Add Obsolete attributes for EditorBrowsable apis
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / NUIApplication.cs
1 /*
2  * Copyright (c) 2016 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
18 using System;
19 using System.ComponentModel;
20 using Tizen.Applications;
21 using Tizen.Applications.CoreBackend;
22
23 namespace Tizen.NUI
24 {
25
26     /// <summary>
27     /// Represents an application that have a UI screen. The NUIApplication class has a default stage.
28     /// </summary>
29     /// <since_tizen> 3 </since_tizen>
30     public class NUIApplication : CoreApplication
31     {
32         /// <summary>
33         /// Occurs whenever the application is resumed.
34         /// </summary>
35         /// <since_tizen> 4 </since_tizen>
36         public event EventHandler Resumed;
37
38         /// <summary>
39         /// Occurs whenever the application is paused.
40         /// </summary>
41         /// <since_tizen> 4 </since_tizen>
42         public event EventHandler Paused;
43
44         /// <summary>
45         /// The instance of ResourceManager.
46         /// </summary>
47         private static System.Resources.ResourceManager resourceManager = null;
48
49         /// <summary>
50         /// The default constructor.
51         /// </summary>
52         /// <since_tizen> 3 </since_tizen>
53         public NUIApplication() : base(new NUICoreBackend())
54         {
55         }
56
57         /// <summary>
58         /// The constructor with a stylesheet.
59         /// </summary>
60         /// <param name="styleSheet">The styleSheet url.</param>
61         /// <since_tizen> 3 </since_tizen>
62         public NUIApplication(string styleSheet) : base(new NUICoreBackend(styleSheet))
63         {
64         }
65
66         /// <summary>
67         /// The constructor with a stylesheet and window mode.
68         /// </summary>
69         /// <param name="styleSheet">The styleSheet url.</param>
70         /// <param name="windowMode">The windowMode.</param>
71         /// <since_tizen> 3 </since_tizen>
72         public NUIApplication(string styleSheet, WindowMode windowMode) : base(new NUICoreBackend(styleSheet, windowMode))
73         {
74         }
75
76         /// <summary>
77         /// Overrides this method if you want to handle behavior.
78         /// </summary>
79         /// <since_tizen> 3 </since_tizen>
80         protected override void OnLocaleChanged(LocaleChangedEventArgs e)
81         {
82             base.OnLocaleChanged(e);
83         }
84
85         /// <summary>
86         /// Overrides this method if you want to handle behavior.
87         /// </summary>
88         /// <since_tizen> 3 </since_tizen>
89         protected override void OnLowBattery(LowBatteryEventArgs e)
90         {
91             base.OnLowBattery(e);
92         }
93
94         /// <summary>
95         /// Overrides this method if you want to handle behavior.
96         /// </summary>
97         /// <since_tizen> 3 </since_tizen>
98         protected override void OnLowMemory(LowMemoryEventArgs e)
99         {
100             base.OnLowMemory(e);
101         }
102
103         /// <summary>
104         /// Overrides this method if you want to handle behavior.
105         /// </summary>
106         /// <since_tizen> 3 </since_tizen>
107         protected override void OnRegionFormatChanged(RegionFormatChangedEventArgs e)
108         {
109             base.OnRegionFormatChanged(e);
110         }
111
112         /// <summary>
113         /// Overrides this method if you want to handle behavior.
114         /// </summary>
115         /// <since_tizen> 3 </since_tizen>
116         protected override void OnTerminate()
117         {
118             base.OnTerminate();
119         }
120
121         /// <summary>
122         /// Overrides this method if you want to handle behavior.
123         /// </summary>
124         /// <since_tizen> 3 </since_tizen>
125         protected virtual void OnPause()
126         {
127             Paused?.Invoke(this, EventArgs.Empty);
128         }
129
130         /// <summary>
131         /// Overrides this method if you want to handle behavior.
132         /// </summary>
133         /// <since_tizen> 3 </since_tizen>
134         protected virtual void OnResume()
135         {
136             Resumed?.Invoke(this, EventArgs.Empty);
137         }
138
139         /// <summary>
140         /// Overrides this method if you want to handle behavior.
141         /// </summary>
142         /// <since_tizen> 3 </since_tizen>
143         protected virtual void OnPreCreate()
144         {
145         }
146
147         /// <summary>
148         /// Overrides this method if you want to handle behavior.
149         /// </summary>
150         /// <since_tizen> 3 </since_tizen>
151         protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
152         {
153             if (e != null)
154             {
155                 Log.Info("NUI", "OnAppControlReceived() is called! ApplicationId=" + e.ReceivedAppControl.ApplicationId);
156                 Log.Info("NUI", "CallerApplicationId=" + e.ReceivedAppControl.CallerApplicationId + "   IsReplyRequest=" + e.ReceivedAppControl.IsReplyRequest);
157             }
158             base.OnAppControlReceived(e);
159         }
160
161         /// <summary>
162         /// Overrides this method if you want to handle behavior.
163         /// </summary>
164         /// <since_tizen> 3 </since_tizen>
165         protected override void OnCreate()
166         {
167             // This is also required to create DisposeQueue on main thread.
168             DisposeQueue disposeQ = DisposeQueue.Instance;
169             disposeQ.Initialize();
170             base.OnCreate();
171         }
172
173         /// <summary>
174         /// Runs the NUIApplication.
175         /// </summary>
176         /// <param name="args">Arguments from commandline.</param>
177         /// <since_tizen> 4 </since_tizen>
178         public override void Run(string[] args)
179         {
180             Backend.AddEventHandler(EventType.PreCreated, OnPreCreate);
181             Backend.AddEventHandler(EventType.Resumed, OnResume);
182             Backend.AddEventHandler(EventType.Paused, OnPause);
183             base.Run(args);
184         }
185
186         /// <summary>
187         /// Exits the NUIApplication.
188         /// </summary>
189         /// <since_tizen> 4 </since_tizen>
190         public override void Exit()
191         {
192             base.Exit();
193         }
194
195         /// <summary>
196         /// Ensures that the function passed in is called from the main loop when it is idle.
197         /// </summary>
198         /// <param name="func">The function to call</param>
199         /// <returns>true if added successfully, false otherwise</returns>
200         /// <since_tizen> 4 </since_tizen>
201         public bool AddIdle(System.Delegate func)
202         {
203             return ((NUICoreBackend)this.Backend).AddIdle(func);
204         }
205
206         /// <summary>
207         /// Enumeration for deciding whether a NUI application window is opaque or transparent.
208         /// </summary>
209         /// <since_tizen> 3 </since_tizen>
210         public enum WindowMode
211         {
212             /// <summary>
213             /// Opaque
214             /// </summary>
215             /// <since_tizen> 3 </since_tizen>
216             Opaque = 0,
217             /// <summary>
218             /// Transparent
219             /// </summary>
220             /// <since_tizen> 3 </since_tizen>
221             Transparent = 1
222         }
223
224
225         internal Application ApplicationHandle
226         {
227             get
228             {
229                 return ((NUICoreBackend)this.Backend).ApplicationHandle;
230             }
231         }
232
233         /// <summary>
234         /// ResourceManager to handle multilingual.
235         /// </summary>
236         /// <since_tizen> 4 </since_tizen>
237         public static System.Resources.ResourceManager MultilingualResourceManager
238         {
239             get
240             {
241                 return resourceManager;
242             }
243             set
244             {
245                 resourceManager = value;
246             }
247         }
248
249         /// <summary>
250         /// Gets the window instance.
251         /// </summary>
252         /// <since_tizen> 3 </since_tizen>
253         [Obsolete("Please do not use! This will be deprecated!")]
254         [EditorBrowsable(EditorBrowsableState.Never)]
255         public Window Window
256         {
257             get
258             {
259                 return Window.Instance;
260             }
261         }
262     }
263 }