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 /// <param name="styleSheet">The styleSheet url.</param>
60 /// <since_tizen> 3 </since_tizen>
61 public NUIApplication(string styleSheet) : base(new NUICoreBackend(styleSheet))
66 /// The constructor with a stylesheet and window mode.
68 /// <param name="styleSheet">The styleSheet url.</param>
69 /// <param name="windowMode">The windowMode.</param>
70 /// <since_tizen> 3 </since_tizen>
71 public NUIApplication(string styleSheet, WindowMode windowMode) : base(new NUICoreBackend(styleSheet, windowMode))
76 /// Overrides this method if you want to handle behavior.
78 protected override void OnLocaleChanged(LocaleChangedEventArgs e)
80 Log.Debug("NUI", "OnLocaleChanged() is called!");
81 base.OnLocaleChanged(e);
85 /// Overrides this method if you want to handle behavior.
87 protected override void OnLowBattery(LowBatteryEventArgs e)
89 Log.Debug("NUI", "OnLowBattery() is called!");
94 /// Overrides this method if you want to handle behavior.
96 protected override void OnLowMemory(LowMemoryEventArgs e)
98 Log.Debug("NUI", "OnLowMemory() is called!");
103 /// Overrides this method if you want to handle behavior.
105 protected override void OnRegionFormatChanged(RegionFormatChangedEventArgs e)
107 Log.Debug("NUI", "OnRegionFormatChanged() is called!");
108 base.OnRegionFormatChanged(e);
112 /// Overrides this method if you want to handle behavior.
114 protected override void OnTerminate()
116 Log.Debug("NUI", "OnTerminate() is called!");
121 /// Overrides this method if you want to handle behavior.
123 protected virtual void OnPause()
125 Log.Debug("NUI", "OnPause() is called!");
126 Paused?.Invoke(this, EventArgs.Empty);
130 /// Overrides this method if you want to handle behavior.
132 protected virtual void OnResume()
134 Log.Debug("NUI", "OnResume() is called!");
135 Resumed?.Invoke(this, EventArgs.Empty);
139 /// Overrides this method if you want to handle behavior.
141 protected virtual void OnPreCreate()
143 Log.Debug("NUI", "OnPreCreate() is called!");
147 /// Overrides this method if you want to handle behavior.
149 protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
151 Log.Debug("NUI", "OnAppControlReceived() is called!");
154 Log.Debug("NUI", "OnAppControlReceived() is called! ApplicationId=" + e.ReceivedAppControl.ApplicationId);
155 Log.Debug("NUI", "CallerApplicationId=" + e.ReceivedAppControl.CallerApplicationId + " IsReplyRequest=" + e.ReceivedAppControl.IsReplyRequest);
157 base.OnAppControlReceived(e);
161 /// Overrides this method if you want to handle behavior.
163 protected override void OnCreate()
165 // This is also required to create DisposeQueue on main thread.
166 DisposeQueue disposeQ = DisposeQueue.Instance;
167 disposeQ.Initialize();
168 Log.Debug("NUI","OnCreate() is called!");
173 /// Runs the NUIApplication.
175 /// <param name="args">Arguments from commandline.</param>
176 /// <since_tizen> 4 </since_tizen>
177 public override void Run(string[] args)
179 Backend.AddEventHandler(EventType.PreCreated, OnPreCreate);
180 Backend.AddEventHandler(EventType.Resumed, OnResume);
181 Backend.AddEventHandler(EventType.Paused, OnPause);
186 /// Exits the NUIApplication.
188 /// <since_tizen> 4 </since_tizen>
189 public override void Exit()
195 /// Ensures that the function passed in is called from the main loop when it is idle.
197 /// <param name="func">The function to call</param>
198 /// <returns>true if added successfully, false otherwise</returns>
199 /// <since_tizen> 4 </since_tizen>
200 public bool AddIdle(System.Delegate func)
202 return ((NUICoreBackend)this.Backend).AddIdle(func);
206 /// Enumeration for deciding whether a NUI application window is opaque or transparent.
208 /// <since_tizen> 3 </since_tizen>
209 public enum WindowMode
214 /// <since_tizen> 3 </since_tizen>
219 /// <since_tizen> 3 </since_tizen>
224 internal Application ApplicationHandle
228 return ((NUICoreBackend)this.Backend).ApplicationHandle;
233 /// ResourceManager to handle multilingual.
235 /// <since_tizen> 4 </since_tizen>
236 public static System.Resources.ResourceManager MultilingualResourceManager
240 return resourceManager;
244 resourceManager = value;
249 /// Gets the window instance.
251 [Obsolete("Please do not use! this will be deprecated")]
256 return Window.Instance;