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 /// The instance of ResourceManager.
34 private static System.Resources.ResourceManager resourceManager = null;
36 /// The default constructor.
38 public NUIApplication() : base(new NUICoreBackend())
43 /// The constructor with stylesheet.
45 public NUIApplication(string stylesheet) : base(new NUICoreBackend(stylesheet))
50 /// The constructor with stylesheet and window mode.
52 public NUIApplication(string stylesheet, WindowMode windowMode) : base(new NUICoreBackend(stylesheet,windowMode))
57 /// Overrides this method if want to handle behavior.
59 protected override void OnLocaleChanged(LocaleChangedEventArgs e)
64 /// Overrides this method if want to handle behavior.
66 protected override void OnLowBattery(LowBatteryEventArgs e)
68 Log.Debug("NUI", "OnLowBattery() is called!");
72 /// Overrides this method if want to handle behavior.
74 protected override void OnLowMemory(LowMemoryEventArgs e)
76 Log.Debug("NUI", "OnLowMemory() is called!");
80 /// Overrides this method if want to handle behavior.
82 protected override void OnRegionFormatChanged(RegionFormatChangedEventArgs e)
84 Log.Debug("NUI", "OnRegionFormatChanged() is called!");
88 /// Overrides this method if want to handle behavior.
90 protected override void OnTerminate()
92 Log.Debug("NUI", "OnTerminate() is called!");
96 /// Overrides this method if want to handle behavior.
98 protected virtual void OnPause()
103 /// Overrides this method if want to handle behavior.
105 protected virtual void OnResume()
110 /// Overrides this method if want to handle behavior.
112 protected virtual void OnPreCreate()
117 /// Overrides this method if want to handle behavior.
119 protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
121 Log.Debug("NUI", "OnAppControlReceived() is called!");
124 Log.Debug("NUI", "OnAppControlReceived() is called! ApplicationId=" + e.ReceivedAppControl.ApplicationId);
125 Log.Debug("NUI", "CallerApplicationId=" + e.ReceivedAppControl.CallerApplicationId + " IsReplyRequest=" + e.ReceivedAppControl.IsReplyRequest);
130 /// Overrides this method if want to handle behavior.
132 protected override void OnCreate()
134 // This is also required to create DisposeQueue on main thread.
135 DisposeQueue disposeQ = DisposeQueue.Instance;
136 disposeQ.Initialize();
137 Log.Debug("NUI","OnCreate() is called!");
141 /// Run NUIApplication.
143 /// <param name="args">Arguments from commandline.</param>
144 public override void Run(string[] args)
146 string[] argsClone = null;
150 argsClone = new string[1];
154 argsClone = new string[args.Length + 1];
155 args.CopyTo(argsClone, 1);
157 argsClone[0] = string.Empty;
159 Backend.AddEventHandler(EventType.PreCreated, OnPreCreate);
160 Backend.AddEventHandler(EventType.Created, OnCreate);
161 Backend.AddEventHandler<AppControlReceivedEventArgs>(EventType.AppControlReceived, OnAppControlReceived);
162 Backend.AddEventHandler(EventType.Resumed, OnResume);
163 Backend.AddEventHandler(EventType.Paused, OnPause);
164 Backend.AddEventHandler(EventType.Terminated, OnTerminate);
165 Backend.AddEventHandler<RegionFormatChangedEventArgs>(EventType.RegionFormatChanged, OnRegionFormatChanged);
166 Backend.AddEventHandler<LowMemoryEventArgs>(EventType.LowMemory, OnLowMemory);
167 Backend.AddEventHandler<LowBatteryEventArgs>(EventType.LowBattery, OnLowBattery);
168 Backend.AddEventHandler<LocaleChangedEventArgs>(EventType.LocaleChanged, OnLocaleChanged);
170 Backend.Run(argsClone);
174 /// Exit NUIApplication.
176 public override void Exit()
182 /// Enumeration for deciding whether a NUI application window is opaque or transparent.
184 public enum WindowMode
191 internal Application ApplicationHandle
195 return ((NUICoreBackend)this.Backend).ApplicationHandle;
200 /// ResourceManager to handle multilingual
202 public static System.Resources.ResourceManager MultilingualResourceManager
206 return resourceManager;
210 resourceManager = value;