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;
26 /// Represents an application that have UI screen. The NUIApplication class has a default stage.
28 public class NUIApplication : CoreUIApplication
31 /// The instance of the Application.
34 /// This application is created before OnCreate() or created event. And the NUIApplication will be terminated when this application is closed.
36 private Application _application;
39 /// The instance of the Dali Application extension.
41 private ApplicationExtensions _applicationExt;
44 /// Store the stylesheet value.
46 private string _stylesheet;
49 /// Store the window mode value.
51 private Application.WindowMode _windowMode;
54 /// Store the app mode value.
56 private AppMode _appMode;
59 /// The instance of the Dali Stage.
61 private Window _window;
64 /// The default constructor.
66 public NUIApplication() : base()
68 _appMode = AppMode.Default;
72 /// The constructor with stylesheet.
74 public NUIApplication(string stylesheet) : base()
76 //handle the stylesheet
77 _appMode = AppMode.StyleSheetOnly;
78 _stylesheet = stylesheet;
82 /// The constructor with stylesheet and window mode.
84 public NUIApplication(string stylesheet, WindowMode windowMode) : base()
86 //handle the stylesheet and windowMode
87 _appMode = AppMode.StyleSheetWithWindowMode;
88 _stylesheet = stylesheet;
89 _windowMode = (Application.WindowMode)windowMode;
93 /// Overrides this method if want to handle behavior.
95 protected override void OnPause()
98 _applicationExt.Pause();
99 NUILog.Debug("OnPause() is called!");
103 /// Overrides this method if want to handle behavior before calling OnCreate().<br>
104 /// stage property is initialized in this overrided method.<br>
106 protected override void OnPreCreate()
108 // Initialize DisposeQueue Singleton class.
109 DisposeQueue disposeQ = DisposeQueue.Instance;
110 NUILog.Debug("##### 1) DisposeQueue.Instance.Initialize()!");
113 case AppMode.Default:
114 _application = Tizen.NUI.Application.NewApplication();
116 case AppMode.StyleSheetOnly:
117 _application = Tizen.NUI.Application.NewApplication(_stylesheet);
119 case AppMode.StyleSheetWithWindowMode:
120 _application = Tizen.NUI.Application.NewApplication(_stylesheet, _windowMode);
125 _applicationExt = new ApplicationExtensions(_application);
126 _applicationExt.Init();
127 _applicationExt.Start();
129 // This is also required to create DisposeQueue on main thread.
130 disposeQ.Initialize();
131 NUILog.Debug("##### 2) DisposeQueue.Instance.Initialize()!");
132 _window = Window.Instance;
133 _window.SetBackgroundColor(Color.White);
134 NUILog.Debug("OnPreCreate() is called!");
138 /// Overrides this method if want to handle behavior.
140 protected override void OnResume()
143 _applicationExt.Resume();
144 NUILog.Debug("OnResume() is called!");
148 /// Overrides this method if want to handle behavior.
150 protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
152 base.OnAppControlReceived(e);
153 NUILog.Debug("OnAppControlReceived() is called!");
156 NUILog.Debug("OnAppControlReceived() is called! ApplicationId=" + e.ReceivedAppControl.ApplicationId);
157 NUILog.Debug("CallerApplicationId=" + e.ReceivedAppControl.CallerApplicationId + " IsReplyRequest=" + e.ReceivedAppControl.IsReplyRequest);
162 /// Overrides this method if want to handle behavior.
164 protected override void OnCreate()
167 NUILog.Debug("OnCreate() is called!");
171 /// Overrides this method if want to handle behavior.
173 protected override void OnLocaleChanged(LocaleChangedEventArgs e)
175 base.OnLocaleChanged(e);
176 _applicationExt.LanguageChange();
177 NUILog.Debug("OnLocaleChanged() is called!");
181 /// Overrides this method if want to handle behavior.
183 protected override void OnLowBattery(LowBatteryEventArgs e)
185 base.OnLowBattery(e);
186 NUILog.Debug("OnLowBattery() is called!");
190 /// Overrides this method if want to handle behavior.
192 protected override void OnLowMemory(LowMemoryEventArgs e)
195 NUILog.Debug("OnLowMemory() is called!");
199 /// Overrides this method if want to handle behavior.
201 protected override void OnRegionFormatChanged(RegionFormatChangedEventArgs e)
203 base.OnRegionFormatChanged(e);
204 NUILog.Debug("OnRegionFormatChanged() is called!");
208 /// Overrides this method if want to handle behavior.
210 protected override void OnTerminate()
213 _applicationExt.Terminate();
214 NUILog.Debug("OnTerminate() is called!");
218 /// The mode of creating NUI application.
224 StyleSheetWithWindowMode = 2
228 /// Enumeration for deciding whether a NUI application window is opaque or transparent.
230 public enum WindowMode
237 /// Get the window instance.
243 return _application.GetWindow();