2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 using Tizen.Applications;
20 using Tizen.Applications.CoreBackend;
26 /// Represents an application that have a UI screen. The NUIApplication class has a default stage.
28 public class NUIApplication : CoreApplication
31 /// Occurs whenever the application is resumed.
33 /// <since_tizen> 4 </since_tizen>
34 public event EventHandler Resumed;
37 /// Occurs whenever the application is paused.
39 /// <since_tizen> 4 </since_tizen>
40 public event EventHandler Paused;
43 /// The instance of ResourceManager.
45 private static System.Resources.ResourceManager resourceManager = null;
48 /// The default constructor.
50 /// <since_tizen> 3 </since_tizen>
51 public NUIApplication() : base(new NUICoreBackend())
56 /// The constructor with a stylesheet.
58 /// <param name="styleSheet">The styleSheet url.</param>
59 /// <since_tizen> 3 </since_tizen>
60 public NUIApplication(string styleSheet) : base(new NUICoreBackend(styleSheet))
65 /// The constructor with a stylesheet and window mode.
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))
75 /// Overrides this method if you want to handle behavior.
77 protected override void OnLocaleChanged(LocaleChangedEventArgs e)
79 base.OnLocaleChanged(e);
83 /// Overrides this method if you want to handle behavior.
85 protected override void OnLowBattery(LowBatteryEventArgs e)
91 /// Overrides this method if you want to handle behavior.
93 protected override void OnLowMemory(LowMemoryEventArgs e)
99 /// Overrides this method if you want to handle behavior.
101 protected override void OnRegionFormatChanged(RegionFormatChangedEventArgs e)
103 base.OnRegionFormatChanged(e);
107 /// Overrides this method if you want to handle behavior.
109 protected override void OnTerminate()
115 /// Overrides this method if you want to handle behavior.
117 protected virtual void OnPause()
119 Paused?.Invoke(this, EventArgs.Empty);
123 /// Overrides this method if you want to handle behavior.
125 protected virtual void OnResume()
127 Resumed?.Invoke(this, EventArgs.Empty);
131 /// Overrides this method if you want to handle behavior.
133 protected virtual void OnPreCreate()
138 /// Overrides this method if you want to handle behavior.
140 protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
144 Log.Info("NUI", "OnAppControlReceived() is called! ApplicationId=" + e.ReceivedAppControl.ApplicationId);
145 Log.Info("NUI", "CallerApplicationId=" + e.ReceivedAppControl.CallerApplicationId + " IsReplyRequest=" + e.ReceivedAppControl.IsReplyRequest);
147 base.OnAppControlReceived(e);
151 /// Overrides this method if you want to handle behavior.
153 protected override void OnCreate()
155 // This is also required to create DisposeQueue on main thread.
156 DisposeQueue disposeQ = DisposeQueue.Instance;
157 disposeQ.Initialize();
162 /// Runs the NUIApplication.
164 /// <param name="args">Arguments from commandline.</param>
165 /// <since_tizen> 4 </since_tizen>
166 public override void Run(string[] args)
168 Backend.AddEventHandler(EventType.PreCreated, OnPreCreate);
169 Backend.AddEventHandler(EventType.Resumed, OnResume);
170 Backend.AddEventHandler(EventType.Paused, OnPause);
175 /// Exits the NUIApplication.
177 /// <since_tizen> 4 </since_tizen>
178 public override void Exit()
184 /// Ensures that the function passed in is called from the main loop when it is idle.
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)
191 return ((NUICoreBackend)this.Backend).AddIdle(func);
195 /// Enumeration for deciding whether a NUI application window is opaque or transparent.
197 /// <since_tizen> 3 </since_tizen>
198 public enum WindowMode
203 /// <since_tizen> 3 </since_tizen>
208 /// <since_tizen> 3 </since_tizen>
213 internal Application ApplicationHandle
217 return ((NUICoreBackend)this.Backend).ApplicationHandle;
222 /// ResourceManager to handle multilingual.
224 /// <since_tizen> 4 </since_tizen>
225 public static System.Resources.ResourceManager MultilingualResourceManager
229 return resourceManager;
233 resourceManager = value;
238 /// Gets the window instance.
240 [Obsolete("Please do not use! this will be deprecated")]
245 return Window.Instance;