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