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 UI screen. The NUIApplication class has a default stage.
29 public class NUIApplication : CoreApplication
32 /// Occurs whenever the application is resumed.
34 public event EventHandler Resumed;
37 /// Occurs whenever the application is paused.
39 public event EventHandler Paused;
42 /// The instance of ResourceManager.
44 private static System.Resources.ResourceManager resourceManager = null;
47 /// The default constructor.
49 public NUIApplication() : base(new NUICoreBackend())
54 /// The constructor with stylesheet.
56 public NUIApplication(string stylesheet) : base(new NUICoreBackend(stylesheet))
61 /// The constructor with stylesheet and window mode.
63 public NUIApplication(string stylesheet, WindowMode windowMode) : base(new NUICoreBackend(stylesheet,windowMode))
68 /// Overrides this method if want to handle behavior.
70 protected override void OnLocaleChanged(LocaleChangedEventArgs e)
72 Log.Debug("NUI", "OnLocaleChanged() is called!");
73 base.OnLocaleChanged(e);
77 /// Overrides this method if want to handle behavior.
79 protected override void OnLowBattery(LowBatteryEventArgs e)
81 Log.Debug("NUI", "OnLowBattery() is called!");
86 /// Overrides this method if want to handle behavior.
88 protected override void OnLowMemory(LowMemoryEventArgs e)
90 Log.Debug("NUI", "OnLowMemory() is called!");
95 /// Overrides this method if want to handle behavior.
97 protected override void OnRegionFormatChanged(RegionFormatChangedEventArgs e)
99 Log.Debug("NUI", "OnRegionFormatChanged() is called!");
100 base.OnRegionFormatChanged(e);
104 /// Overrides this method if want to handle behavior.
106 protected override void OnTerminate()
108 Log.Debug("NUI", "OnTerminate() is called!");
113 /// Overrides this method if want to handle behavior.
115 protected virtual void OnPause()
117 Log.Debug("NUI", "OnPause() is called!");
118 Paused?.Invoke(this, EventArgs.Empty);
122 /// Overrides this method if want to handle behavior.
124 protected virtual void OnResume()
126 Log.Debug("NUI", "OnResume() is called!");
127 Resumed?.Invoke(this, EventArgs.Empty);
131 /// Overrides this method if want to handle behavior.
133 protected virtual void OnPreCreate()
135 Log.Debug("NUI", "OnPreCreate() is called!");
139 /// Overrides this method if want to handle behavior.
141 protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
143 Log.Debug("NUI", "OnAppControlReceived() is called!");
146 Log.Debug("NUI", "OnAppControlReceived() is called! ApplicationId=" + e.ReceivedAppControl.ApplicationId);
147 Log.Debug("NUI", "CallerApplicationId=" + e.ReceivedAppControl.CallerApplicationId + " IsReplyRequest=" + e.ReceivedAppControl.IsReplyRequest);
149 base.OnAppControlReceived(e);
153 /// Overrides this method if want to handle behavior.
155 protected override void OnCreate()
157 // This is also required to create DisposeQueue on main thread.
158 DisposeQueue disposeQ = DisposeQueue.Instance;
159 disposeQ.Initialize();
160 Log.Debug("NUI","OnCreate() is called!");
165 /// Run NUIApplication.
167 /// <param name="args">Arguments from commandline.</param>
168 public override void Run(string[] args)
170 Backend.AddEventHandler(EventType.PreCreated, OnPreCreate);
171 Backend.AddEventHandler(EventType.Resumed, OnResume);
172 Backend.AddEventHandler(EventType.Paused, OnPause);
177 /// Exit NUIApplication.
179 public override void Exit()
185 /// Enumeration for deciding whether a NUI application window is opaque or transparent.
187 public enum WindowMode
194 internal Application ApplicationHandle
198 return ((NUICoreBackend)this.Backend).ApplicationHandle;
203 /// ResourceManager to handle multilingual
205 public static System.Resources.ResourceManager MultilingualResourceManager
209 return resourceManager;
213 resourceManager = value;
218 /// Get the window instance.
220 [Obsolete("Please do not use! this will be deprecated")]
225 return Window.Instance;