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 default constructor.
34 public NUIApplication() : base(new NUICoreBackend())
39 /// The constructor with stylesheet.
41 public NUIApplication(string stylesheet) : base(new NUICoreBackend(stylesheet))
46 /// The constructor with stylesheet and window mode.
48 public NUIApplication(string stylesheet, WindowMode windowMode) : base(new NUICoreBackend(stylesheet,windowMode))
53 /// Overrides this method if want to handle behavior.
55 protected override void OnLocaleChanged(LocaleChangedEventArgs e)
60 /// Overrides this method if want to handle behavior.
62 protected override void OnLowBattery(LowBatteryEventArgs e)
64 Log.Debug("NUI", "OnLowBattery() is called!");
68 /// Overrides this method if want to handle behavior.
70 protected override void OnLowMemory(LowMemoryEventArgs e)
72 Log.Debug("NUI", "OnLowMemory() is called!");
76 /// Overrides this method if want to handle behavior.
78 protected override void OnRegionFormatChanged(RegionFormatChangedEventArgs e)
80 Log.Debug("NUI", "OnRegionFormatChanged() is called!");
84 /// Overrides this method if want to handle behavior.
86 protected override void OnTerminate()
88 Log.Debug("NUI", "OnTerminate() is called!");
92 /// Overrides this method if want to handle behavior.
94 protected void OnPause()
99 /// Overrides this method if want to handle behavior.
101 protected void OnResume()
103 Log.Debug("NUI", "OnResume() is called!");
107 /// Overrides this method if want to handle behavior.
109 protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
111 Log.Debug("NUI", "OnAppControlReceived() is called!");
114 Log.Debug("NUI", "OnAppControlReceived() is called! ApplicationId=" + e.ReceivedAppControl.ApplicationId);
115 Log.Debug("NUI", "CallerApplicationId=" + e.ReceivedAppControl.CallerApplicationId + " IsReplyRequest=" + e.ReceivedAppControl.IsReplyRequest);
120 /// Overrides this method if want to handle behavior.
122 protected override void OnCreate()
124 // This is also required to create DisposeQueue on main thread.
125 DisposeQueue disposeQ = DisposeQueue.Instance;
126 disposeQ.Initialize();
127 Log.Debug("NUI","OnCreate() is called!");
131 /// Run NUIApplication.
133 /// <param name="args">Arguments from commandline.</param>
134 public override void Run(string[] args)
136 string[] argsClone = null;
140 argsClone = new string[1];
144 argsClone = new string[args.Length + 1];
145 args.CopyTo(argsClone, 1);
147 argsClone[0] = string.Empty;
149 Backend.AddEventHandler(EventType.Resumed, OnResume);
150 Backend.AddEventHandler<AppControlReceivedEventArgs>(EventType.AppControlReceived, OnAppControlReceived);
151 Backend.AddEventHandler(EventType.Paused, OnPause);
152 Backend.AddEventHandler(EventType.Terminated, OnTerminate);
153 Backend.AddEventHandler<RegionFormatChangedEventArgs>(EventType.RegionFormatChanged, OnRegionFormatChanged);
154 Backend.AddEventHandler<LowMemoryEventArgs>(EventType.LowMemory, OnLowMemory);
155 Backend.AddEventHandler<LowBatteryEventArgs>(EventType.LowBattery, OnLowBattery);
156 Backend.AddEventHandler<LocaleChangedEventArgs>(EventType.LocaleChanged, OnLocaleChanged);
157 Backend.AddEventHandler(EventType.Created, OnCreate);
159 Backend.Run(argsClone);
163 /// Exit NUIApplication.
165 public override void Exit()
171 /// Enumeration for deciding whether a NUI application window is opaque or transparent.
173 public enum WindowMode
180 /// Get the window instance.
186 return _application.GetWindow();
190 internal Application ApplicationHandle