/* * 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 System.ComponentModel; using Tizen.Applications; using Tizen.Applications.CoreBackend; namespace Tizen.NUI { /// /// Represents an application that have a UI screen. The NUIApplication class has a default stage. /// /// 3 public class NUIApplication : CoreApplication { /// /// Occurs whenever the application is resumed. /// /// 4 public event EventHandler Resumed; /// /// Occurs whenever the application is paused. /// /// 4 public event EventHandler Paused; /// /// The instance of ResourceManager. /// private static System.Resources.ResourceManager resourceManager = null; /// /// The default constructor. /// /// 3 public NUIApplication() : base(new NUICoreBackend()) { } /// /// The constructor with a stylesheet. /// /// The styleSheet url. /// 3 public NUIApplication(string styleSheet) : base(new NUICoreBackend(styleSheet)) { } /// /// The constructor with a stylesheet and window mode. /// /// The styleSheet url. /// The windowMode. /// 3 public NUIApplication(string styleSheet, WindowMode windowMode) : base(new NUICoreBackend(styleSheet, windowMode)) { } /// /// Overrides this method if you want to handle behavior. /// /// 3 protected override void OnLocaleChanged(LocaleChangedEventArgs e) { base.OnLocaleChanged(e); } /// /// Overrides this method if you want to handle behavior. /// /// 3 protected override void OnLowBattery(LowBatteryEventArgs e) { base.OnLowBattery(e); } /// /// Overrides this method if you want to handle behavior. /// /// 3 protected override void OnLowMemory(LowMemoryEventArgs e) { base.OnLowMemory(e); } /// /// Overrides this method if you want to handle behavior. /// /// 3 protected override void OnRegionFormatChanged(RegionFormatChangedEventArgs e) { base.OnRegionFormatChanged(e); } /// /// Overrides this method if you want to handle behavior. /// /// 3 protected override void OnTerminate() { base.OnTerminate(); } /// /// Overrides this method if you want to handle behavior. /// /// 3 protected virtual void OnPause() { Paused?.Invoke(this, EventArgs.Empty); } /// /// Overrides this method if you want to handle behavior. /// /// 3 protected virtual void OnResume() { Resumed?.Invoke(this, EventArgs.Empty); } /// /// Overrides this method if you want to handle behavior. /// /// 3 protected virtual void OnPreCreate() { } /// /// Overrides this method if you want to handle behavior. /// /// 3 protected override void OnAppControlReceived(AppControlReceivedEventArgs e) { if (e != null) { Log.Info("NUI", "OnAppControlReceived() is called! ApplicationId=" + e.ReceivedAppControl.ApplicationId); Log.Info("NUI", "CallerApplicationId=" + e.ReceivedAppControl.CallerApplicationId + " IsReplyRequest=" + e.ReceivedAppControl.IsReplyRequest); } base.OnAppControlReceived(e); } /// /// Overrides this method if you want to handle behavior. /// /// 3 protected override void OnCreate() { // This is also required to create DisposeQueue on main thread. DisposeQueue disposeQ = DisposeQueue.Instance; disposeQ.Initialize(); base.OnCreate(); } /// /// Runs the NUIApplication. /// /// Arguments from commandline. /// 4 public override void Run(string[] args) { Backend.AddEventHandler(EventType.PreCreated, OnPreCreate); Backend.AddEventHandler(EventType.Resumed, OnResume); Backend.AddEventHandler(EventType.Paused, OnPause); base.Run(args); } /// /// Exits the NUIApplication. /// /// 4 public override void Exit() { base.Exit(); } /// /// Ensures that the function passed in is called from the main loop when it is idle. /// /// The function to call /// true if added successfully, false otherwise /// 4 public bool AddIdle(System.Delegate func) { return ((NUICoreBackend)this.Backend).AddIdle(func); } /// /// Enumeration for deciding whether a NUI application window is opaque or transparent. /// /// 3 public enum WindowMode { /// /// Opaque /// /// 3 Opaque = 0, /// /// Transparent /// /// 3 Transparent = 1 } internal Application ApplicationHandle { get { return ((NUICoreBackend)this.Backend).ApplicationHandle; } } /// /// ResourceManager to handle multilingual. /// /// 4 public static System.Resources.ResourceManager MultilingualResourceManager { get { return resourceManager; } set { resourceManager = value; } } /// /// Gets the window instance. /// /// 3 [Obsolete("Please do not use! This will be deprecated!")] [EditorBrowsable(EditorBrowsableState.Never)] public Window Window { get { return Window.Instance; } } } }