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();
137 // This is also required to create DisposeQueue on main thread.
138 disposeQ.Initialize();
140 Tizen.Log.Debug("NUI", "##### 2) DisposeQueue.Instance.Initialize()!");
142 _window = Window.Instance;
143 _window.SetBackgroundColor(Color.White);
144 LOG("OnPreCreate() is called!");
148 /// Overrides this method if want to handle behavior.
150 protected override void OnResume()
153 _applicationExt.Resume();
154 LOG("OnResume() is called!");
158 /// Overrides this method if want to handle behavior.
160 protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
162 base.OnAppControlReceived(e);
163 LOG("OnAppControlReceived() is called!");
166 LOG("OnAppControlReceived() is called! ApplicationId=" + e.ReceivedAppControl.ApplicationId);
167 LOG("CallerApplicationId=" + e.ReceivedAppControl.CallerApplicationId + " IsReplyRequest=" + e.ReceivedAppControl.IsReplyRequest);
172 /// Overrides this method if want to handle behavior.
174 protected override void OnCreate()
177 LOG("OnCreate() is called!");
181 /// Overrides this method if want to handle behavior.
183 protected override void OnLocaleChanged(LocaleChangedEventArgs e)
185 base.OnLocaleChanged(e);
186 _applicationExt.LanguageChange();
187 LOG("OnLocaleChanged() is called!");
191 /// Overrides this method if want to handle behavior.
193 protected override void OnLowBattery(LowBatteryEventArgs e)
195 base.OnLowBattery(e);
196 LOG("OnLowBattery() is called!");
200 /// Overrides this method if want to handle behavior.
202 protected override void OnLowMemory(LowMemoryEventArgs e)
205 LOG("OnLowMemory() is called!");
209 /// Overrides this method if want to handle behavior.
211 protected override void OnRegionFormatChanged(RegionFormatChangedEventArgs e)
213 base.OnRegionFormatChanged(e);
214 LOG("OnRegionFormatChanged() is called!");
218 /// Overrides this method if want to handle behavior.
220 protected override void OnTerminate()
223 _applicationExt.Terminate();
224 LOG("OnTerminate() is called!");
228 /// The mode of creating NUI application.
234 StyleSheetWithWindowMode = 2
238 /// Enumeration for deciding whether a NUI application window is opaque or transparent.
240 public enum WindowMode
247 /// Get the window instance.
253 return _application.GetWindow();