/* * Copyright (c) 2016 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ using System; using Tizen.Applications; using Tizen.Applications.CoreBackend; using Tizen.NUI; namespace Tizen.NUI { /// /// Represents an application that have UI screen. The NUIApplication class has a default stage. /// public class NUIApplication : CoreApplication { /// /// Occurs whenever the application is resumed. /// public event EventHandler Resumed; /// /// Occurs whenever the application is paused. /// public event EventHandler Paused; /// /// The instance of ResourceManager. /// private static System.Resources.ResourceManager resourceManager = null; /// /// The default constructor. /// public NUIApplication() : base(new NUICoreBackend()) { } /// /// The constructor with stylesheet. /// public NUIApplication(string stylesheet) : base(new NUICoreBackend(stylesheet)) { } /// /// The constructor with stylesheet and window mode. /// public NUIApplication(string stylesheet, WindowMode windowMode) : base(new NUICoreBackend(stylesheet,windowMode)) { } /// /// Overrides this method if want to handle behavior. /// protected override void OnLocaleChanged(LocaleChangedEventArgs e) { Log.Debug("NUI", "OnLocaleChanged() is called!"); base.OnLocaleChanged(e); } /// /// Overrides this method if want to handle behavior. /// protected override void OnLowBattery(LowBatteryEventArgs e) { Log.Debug("NUI", "OnLowBattery() is called!"); base.OnLowBattery(e); } /// /// Overrides this method if want to handle behavior. /// protected override void OnLowMemory(LowMemoryEventArgs e) { Log.Debug("NUI", "OnLowMemory() is called!"); base.OnLowMemory(e); } /// /// Overrides this method if want to handle behavior. /// protected override void OnRegionFormatChanged(RegionFormatChangedEventArgs e) { Log.Debug("NUI", "OnRegionFormatChanged() is called!"); base.OnRegionFormatChanged(e); } /// /// Overrides this method if want to handle behavior. /// protected override void OnTerminate() { Log.Debug("NUI", "OnTerminate() is called!"); base.OnTerminate(); } /// /// Overrides this method if want to handle behavior. /// protected void OnPause() { Log.Debug("NUI", "OnPause() is called!"); Paused?.Invoke(this, EventArgs.Empty); } /// /// Overrides this method if want to handle behavior. /// protected virtual void OnResume() { Log.Debug("NUI", "OnResume() is called!"); Resumed?.Invoke(this, EventArgs.Empty); } /// /// Overrides this method if want to handle behavior. /// protected virtual void OnPreCreate() { Log.Debug("NUI", "OnPreCreate() is called!"); } /// /// Overrides this method if want to handle behavior. /// protected override void OnAppControlReceived(AppControlReceivedEventArgs e) { Log.Debug("NUI", "OnAppControlReceived() is called!"); if (e != null) { Log.Debug("NUI", "OnAppControlReceived() is called! ApplicationId=" + e.ReceivedAppControl.ApplicationId); Log.Debug("NUI", "CallerApplicationId=" + e.ReceivedAppControl.CallerApplicationId + " IsReplyRequest=" + e.ReceivedAppControl.IsReplyRequest); } base.OnAppControlReceived(e); } /// /// Overrides this method if want to handle behavior. /// protected override void OnCreate() { // This is also required to create DisposeQueue on main thread. DisposeQueue disposeQ = DisposeQueue.Instance; disposeQ.Initialize(); Log.Debug("NUI","OnCreate() is called!"); base.OnCreate(); } /// /// Run NUIApplication. /// /// Arguments from commandline. public override void Run(string[] args) { string[] argsClone = null; if (args == null) { argsClone = new string[1]; } else { argsClone = new string[args.Length + 1]; args.CopyTo(argsClone, 1); } argsClone[0] = string.Empty; Backend.AddEventHandler(EventType.Resumed, OnResume); Backend.AddEventHandler(EventType.AppControlReceived, OnAppControlReceived); Backend.AddEventHandler(EventType.Paused, OnPause); Backend.AddEventHandler(EventType.Terminated, OnTerminate); Backend.AddEventHandler(EventType.RegionFormatChanged, OnRegionFormatChanged); Backend.AddEventHandler(EventType.LowMemory, OnLowMemory); Backend.AddEventHandler(EventType.LowBattery, OnLowBattery); Backend.AddEventHandler(EventType.LocaleChanged, OnLocaleChanged); Backend.AddEventHandler(EventType.Created, OnCreate); Backend.Run(argsClone); } /// /// Exit NUIApplication. /// public override void Exit() { Backend.Exit(); } /// /// Enumeration for deciding whether a NUI application window is opaque or transparent. /// public enum WindowMode { Opaque = 0, Transparent = 1 } } }