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)
32 //Tizen.Log.Debug("NUI", _str);
33 //Console.WriteLine("[NUI]" + _str);
37 /// The instance of the Application.
40 /// This application is created before OnCreate() or created event. And the NUIApplication will be terminated when this application is closed.
42 private Application _application;
45 /// The instance of the Dali Application extension.
47 private ApplicationExtensions _applicationExt;
50 /// Store the stylesheet value.
52 private string _stylesheet;
55 /// Store the window mode value.
57 private Application.WindowMode _windowMode;
60 /// Store the app mode value.
62 private AppMode _appMode;
65 /// The instance of the Dali Stage.
70 /// The default constructor.
72 public NUIApplication() : base()
74 _appMode = AppMode.Default;
78 /// The constructor with stylesheet.
80 public NUIApplication(string stylesheet) : base()
82 //handle the stylesheet
83 _appMode = AppMode.StyleSheetOnly;
84 _stylesheet = stylesheet;
88 /// The constructor with stylesheet and window mode.
90 public NUIApplication(string stylesheet, WindowMode windowMode) : base()
92 //handle the stylesheet and windowMode
93 _appMode = AppMode.StyleSheetWithWindowMode;
94 _stylesheet = stylesheet;
95 _windowMode = (Application.WindowMode)windowMode;
99 /// Overrides this method if want to handle behavior.
101 protected override void OnPause()
104 _applicationExt.Pause();
105 LOG("OnPause() is called!");
109 /// Overrides this method if want to handle behavior before calling OnCreate().
110 /// stage property is initialized in this overrided method.
112 protected override void OnPreCreate()
116 case AppMode.Default:
117 _application = Tizen.NUI.Application.NewApplication();
119 case AppMode.StyleSheetOnly:
120 _application = Tizen.NUI.Application.NewApplication(_stylesheet);
122 case AppMode.StyleSheetWithWindowMode:
123 _application = Tizen.NUI.Application.NewApplication(_stylesheet, _windowMode);
128 _applicationExt = new ApplicationExtensions(_application);
129 _applicationExt.Init();
131 _stage = Stage.Instance;
132 _stage.SetBackgroundColor(Color.White);
133 LOG("OnPreCreate() is called!");
137 /// Overrides this method if want to handle behavior.
139 protected override void OnResume()
142 _applicationExt.Resume();
143 LOG("OnResume() is called!");
147 /// Overrides this method if want to handle behavior.
149 protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
151 base.OnAppControlReceived(e);
152 LOG("OnAppControlReceived() is called!");
155 LOG("OnAppControlReceived() is called! ApplicationId=" + e.ReceivedAppControl.ApplicationId);
156 LOG("CallerApplicationId=" + e.ReceivedAppControl.CallerApplicationId + " IsReplyRequest=" + e.ReceivedAppControl.IsReplyRequest);
161 /// Overrides this method if want to handle behavior.
163 protected override void OnCreate()
166 LOG("OnCreate() is called!");
170 /// Overrides this method if want to handle behavior.
172 protected override void OnLocaleChanged(LocaleChangedEventArgs e)
174 base.OnLocaleChanged(e);
175 _applicationExt.LanguageChange();
176 LOG("OnLocaleChanged() is called!");
180 /// Overrides this method if want to handle behavior.
182 protected override void OnLowBattery(LowBatteryEventArgs e)
184 base.OnLowBattery(e);
185 LOG("OnLowBattery() is called!");
189 /// Overrides this method if want to handle behavior.
191 protected override void OnLowMemory(LowMemoryEventArgs e)
194 LOG("OnLowMemory() is called!");
198 /// Overrides this method if want to handle behavior.
200 protected override void OnRegionFormatChanged(RegionFormatChangedEventArgs e)
202 base.OnRegionFormatChanged(e);
203 LOG("OnRegionFormatChanged() is called!");
207 /// Overrides this method if want to handle behavior.
209 protected override void OnTerminate()
212 _applicationExt.Terminate();
213 LOG("OnTerminate() is called!");
217 /// The mode of creating NUI application.
223 StyleSheetWithWindowMode = 2
227 /// Enumeration for deciding whether a NUI application window is opaque or transparent.
229 public enum WindowMode