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 System.ComponentModel;
20 using Tizen.Applications;
21 using Tizen.Applications.CoreBackend;
27 /// Represents an application that have a UI screen. The NUIApplication class has a default stage.
29 /// <since_tizen> 3 </since_tizen>
30 public class NUIApplication : CoreApplication
33 /// Occurs whenever the application is resumed.
35 /// <since_tizen> 4 </since_tizen>
36 public event EventHandler Resumed;
39 /// Occurs whenever the application is paused.
41 /// <since_tizen> 4 </since_tizen>
42 public event EventHandler Paused;
45 /// The instance of ResourceManager.
47 private static System.Resources.ResourceManager resourceManager = null;
50 /// The default constructor.
52 /// <since_tizen> 3 </since_tizen>
53 public NUIApplication() : base(new NUICoreBackend())
58 /// The constructor with a stylesheet.
60 /// <param name="styleSheet">The styleSheet url.</param>
61 /// <since_tizen> 3 </since_tizen>
62 public NUIApplication(string styleSheet) : base(new NUICoreBackend(styleSheet))
67 /// The constructor with a stylesheet and window mode.
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))
77 /// Overrides this method if you want to handle behavior.
79 /// <since_tizen> 3 </since_tizen>
80 protected override void OnLocaleChanged(LocaleChangedEventArgs e)
82 base.OnLocaleChanged(e);
86 /// Overrides this method if you want to handle behavior.
88 /// <since_tizen> 3 </since_tizen>
89 protected override void OnLowBattery(LowBatteryEventArgs e)
95 /// Overrides this method if you want to handle behavior.
97 /// <since_tizen> 3 </since_tizen>
98 protected override void OnLowMemory(LowMemoryEventArgs e)
104 /// Overrides this method if you want to handle behavior.
106 /// <since_tizen> 3 </since_tizen>
107 protected override void OnRegionFormatChanged(RegionFormatChangedEventArgs e)
109 base.OnRegionFormatChanged(e);
113 /// Overrides this method if you want to handle behavior.
115 /// <since_tizen> 3 </since_tizen>
116 protected override void OnTerminate()
122 /// Overrides this method if you want to handle behavior.
124 /// <since_tizen> 3 </since_tizen>
125 protected virtual void OnPause()
127 Paused?.Invoke(this, EventArgs.Empty);
131 /// Overrides this method if you want to handle behavior.
133 /// <since_tizen> 3 </since_tizen>
134 protected virtual void OnResume()
136 Resumed?.Invoke(this, EventArgs.Empty);
140 /// Overrides this method if you want to handle behavior.
142 /// <since_tizen> 3 </since_tizen>
143 protected virtual void OnPreCreate()
148 /// Overrides this method if you want to handle behavior.
150 /// <since_tizen> 3 </since_tizen>
151 protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
155 Log.Info("NUI", "OnAppControlReceived() is called! ApplicationId=" + e.ReceivedAppControl.ApplicationId);
156 Log.Info("NUI", "CallerApplicationId=" + e.ReceivedAppControl.CallerApplicationId + " IsReplyRequest=" + e.ReceivedAppControl.IsReplyRequest);
158 base.OnAppControlReceived(e);
162 /// Overrides this method if you want to handle behavior.
164 /// <since_tizen> 3 </since_tizen>
165 protected override void OnCreate()
167 // This is also required to create DisposeQueue on main thread.
168 DisposeQueue disposeQ = DisposeQueue.Instance;
169 disposeQ.Initialize();
174 /// Runs the NUIApplication.
176 /// <param name="args">Arguments from commandline.</param>
177 /// <since_tizen> 4 </since_tizen>
178 public override void Run(string[] args)
180 Backend.AddEventHandler(EventType.PreCreated, OnPreCreate);
181 Backend.AddEventHandler(EventType.Resumed, OnResume);
182 Backend.AddEventHandler(EventType.Paused, OnPause);
187 /// Exits the NUIApplication.
189 /// <since_tizen> 4 </since_tizen>
190 public override void Exit()
196 /// Ensures that the function passed in is called from the main loop when it is idle.
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)
203 return ((NUICoreBackend)this.Backend).AddIdle(func);
207 /// Enumeration for deciding whether a NUI application window is opaque or transparent.
209 /// <since_tizen> 3 </since_tizen>
210 public enum WindowMode
215 /// <since_tizen> 3 </since_tizen>
220 /// <since_tizen> 3 </since_tizen>
225 internal Application ApplicationHandle
229 return ((NUICoreBackend)this.Backend).ApplicationHandle;
234 /// ResourceManager to handle multilingual.
236 /// <since_tizen> 4 </since_tizen>
237 public static System.Resources.ResourceManager MultilingualResourceManager
241 return resourceManager;
245 resourceManager = value;
250 /// Gets the window instance.
252 /// <since_tizen> 3 </since_tizen>
253 [Obsolete("Please do not use! this will be deprecated")]
254 [EditorBrowsable(EditorBrowsableState.Never)]
259 return Window.Instance;