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;
27 /// Represents an application that have a UI screen. The NUIApplication class has a default stage.
29 public class NUIApplication : CoreApplication
32 /// Occurs whenever the application is resumed.
34 /// <since_tizen> 4 </since_tizen>
35 public event EventHandler Resumed;
38 /// Occurs whenever the application is paused.
40 /// <since_tizen> 4 </since_tizen>
41 public event EventHandler Paused;
44 /// The instance of ResourceManager.
46 private static System.Resources.ResourceManager resourceManager = null;
49 /// The default constructor.
51 /// <since_tizen> 3 </since_tizen>
52 public NUIApplication() : base(new NUICoreBackend())
57 /// The constructor with a stylesheet.
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 /// <since_tizen> 3 </since_tizen>
68 public NUIApplication(string stylesheet, WindowMode windowMode) : base(new NUICoreBackend(stylesheet,windowMode))
73 /// Overrides this method if you want to handle behavior.
75 protected override void OnLocaleChanged(LocaleChangedEventArgs e)
77 Log.Debug("NUI", "OnLocaleChanged() is called!");
78 base.OnLocaleChanged(e);
82 /// Overrides this method if you want to handle behavior.
84 protected override void OnLowBattery(LowBatteryEventArgs e)
86 Log.Debug("NUI", "OnLowBattery() is called!");
91 /// Overrides this method if you want to handle behavior.
93 protected override void OnLowMemory(LowMemoryEventArgs e)
95 Log.Debug("NUI", "OnLowMemory() is called!");
100 /// Overrides this method if you want to handle behavior.
102 protected override void OnRegionFormatChanged(RegionFormatChangedEventArgs e)
104 Log.Debug("NUI", "OnRegionFormatChanged() is called!");
105 base.OnRegionFormatChanged(e);
109 /// Overrides this method if you want to handle behavior.
111 protected override void OnTerminate()
113 Log.Debug("NUI", "OnTerminate() is called!");
118 /// Overrides this method if you want to handle behavior.
120 protected virtual void OnPause()
122 Log.Debug("NUI", "OnPause() is called!");
123 Paused?.Invoke(this, EventArgs.Empty);
127 /// Overrides this method if you want to handle behavior.
129 protected virtual void OnResume()
131 Log.Debug("NUI", "OnResume() is called!");
132 Resumed?.Invoke(this, EventArgs.Empty);
136 /// Overrides this method if you want to handle behavior.
138 protected virtual void OnPreCreate()
140 Log.Debug("NUI", "OnPreCreate() is called!");
144 /// Overrides this method if you want to handle behavior.
146 protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
148 Log.Debug("NUI", "OnAppControlReceived() is called!");
151 Log.Debug("NUI", "OnAppControlReceived() is called! ApplicationId=" + e.ReceivedAppControl.ApplicationId);
152 Log.Debug("NUI", "CallerApplicationId=" + e.ReceivedAppControl.CallerApplicationId + " IsReplyRequest=" + e.ReceivedAppControl.IsReplyRequest);
154 base.OnAppControlReceived(e);
158 /// Overrides this method if you want to handle behavior.
160 protected override void OnCreate()
162 // This is also required to create DisposeQueue on main thread.
163 DisposeQueue disposeQ = DisposeQueue.Instance;
164 disposeQ.Initialize();
165 Log.Debug("NUI","OnCreate() is called!");
170 /// Runs the NUIApplication.
172 /// <param name="args">Arguments from commandline.</param>
173 /// <since_tizen> 4 </since_tizen>
174 public override void Run(string[] args)
176 Backend.AddEventHandler(EventType.PreCreated, OnPreCreate);
177 Backend.AddEventHandler(EventType.Resumed, OnResume);
178 Backend.AddEventHandler(EventType.Paused, OnPause);
183 /// Exits the NUIApplication.
185 /// <since_tizen> 4 </since_tizen>
186 public override void Exit()
192 /// Ensures that the function passed in is called from the main loop when it is idle.
194 /// <param name="func">The function to call</param>
195 /// <returns>true if added successfully, false otherwise</returns>
196 /// <since_tizen> 4 </since_tizen>
197 public bool AddIdle(System.Delegate func)
199 return ((NUICoreBackend)this.Backend).AddIdle(func);
203 /// Enumeration for deciding whether a NUI application window is opaque or transparent.
205 /// <since_tizen> 3 </since_tizen>
206 public enum WindowMode
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;