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
30 private void LOG(string _str)
33 Tizen.Log.Debug("NUI", _str);
38 /// The instance of the Application.
41 /// This application is created before OnCreate() or created event. And the NUIApplication will be terminated when this application is closed.
43 private Application _application;
46 /// The instance of the Dali Application extension.
48 private ApplicationExtensions _applicationExt;
51 /// Store the stylesheet value.
53 private string _stylesheet;
56 /// Store the window mode value.
58 private Application.WindowMode _windowMode;
61 /// Store the app mode value.
63 private AppMode _appMode;
66 /// The instance of the Dali Stage.
68 private Window _window;
71 /// The default constructor.
73 public NUIApplication() : base()
75 _appMode = AppMode.Default;
79 /// The constructor with stylesheet.
81 public NUIApplication(string stylesheet) : base()
83 //handle the stylesheet
84 _appMode = AppMode.StyleSheetOnly;
85 _stylesheet = stylesheet;
89 /// The constructor with stylesheet and window mode.
91 public NUIApplication(string stylesheet, WindowMode windowMode) : base()
93 //handle the stylesheet and windowMode
94 _appMode = AppMode.StyleSheetWithWindowMode;
95 _stylesheet = stylesheet;
96 _windowMode = (Application.WindowMode)windowMode;
100 /// Overrides this method if want to handle behavior.
102 protected override void OnPause()
105 _applicationExt.Pause();
106 LOG("OnPause() is called!");
110 /// Overrides this method if want to handle behavior before calling OnCreate().<br>
111 /// stage property is initialized in this overrided method.<br>
113 protected override void OnPreCreate()
115 // Initialize DisposeQueue Singleton class.
116 DisposeQueue disposeQ = DisposeQueue.Instance;
118 Tizen.Log.Debug("NUI", "##### 1) DisposeQueue.Instance.Initialize()!");
122 case AppMode.Default:
123 _application = Tizen.NUI.Application.NewApplication();
125 case AppMode.StyleSheetOnly:
126 _application = Tizen.NUI.Application.NewApplication(_stylesheet);
128 case AppMode.StyleSheetWithWindowMode:
129 _application = Tizen.NUI.Application.NewApplication(_stylesheet, _windowMode);
134 _applicationExt = new ApplicationExtensions(_application);
135 _applicationExt.Init();
136 _applicationExt.Start();
138 // This is also required to create DisposeQueue on main thread.
139 disposeQ.Initialize();
141 Tizen.Log.Debug("NUI", "##### 2) DisposeQueue.Instance.Initialize()!");
143 _window = Window.Instance;
144 _window.SetBackgroundColor(Color.White);
145 LOG("OnPreCreate() is called!");
149 /// Overrides this method if want to handle behavior.
151 protected override void OnResume()
154 _applicationExt.Resume();
155 LOG("OnResume() is called!");
159 /// Overrides this method if want to handle behavior.
161 protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
163 base.OnAppControlReceived(e);
164 LOG("OnAppControlReceived() is called!");
167 LOG("OnAppControlReceived() is called! ApplicationId=" + e.ReceivedAppControl.ApplicationId);
168 LOG("CallerApplicationId=" + e.ReceivedAppControl.CallerApplicationId + " IsReplyRequest=" + e.ReceivedAppControl.IsReplyRequest);
173 /// Overrides this method if want to handle behavior.
175 protected override void OnCreate()
178 LOG("OnCreate() is called!");
182 /// Overrides this method if want to handle behavior.
184 protected override void OnLocaleChanged(LocaleChangedEventArgs e)
186 base.OnLocaleChanged(e);
187 _applicationExt.LanguageChange();
188 LOG("OnLocaleChanged() is called!");
192 /// Overrides this method if want to handle behavior.
194 protected override void OnLowBattery(LowBatteryEventArgs e)
196 base.OnLowBattery(e);
197 LOG("OnLowBattery() is called!");
201 /// Overrides this method if want to handle behavior.
203 protected override void OnLowMemory(LowMemoryEventArgs e)
206 LOG("OnLowMemory() is called!");
210 /// Overrides this method if want to handle behavior.
212 protected override void OnRegionFormatChanged(RegionFormatChangedEventArgs e)
214 base.OnRegionFormatChanged(e);
215 LOG("OnRegionFormatChanged() is called!");
219 /// Overrides this method if want to handle behavior.
221 protected override void OnTerminate()
224 _applicationExt.Terminate();
225 LOG("OnTerminate() is called!");
229 /// The mode of creating NUI application.
235 StyleSheetWithWindowMode = 2
239 /// Enumeration for deciding whether a NUI application window is opaque or transparent.
241 public enum WindowMode
248 /// Get the window instance.
254 return _application.GetWindow();