Merge "Add C# binding for VideoView.Underlay property."
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / NUIApplication.cs
index 2221036..b1d888b 100755 (executable)
 using System;
 using Tizen.Applications;
 using Tizen.Applications.CoreBackend;
-using Tizen.NUI;
 
 namespace Tizen.NUI
 {
 
     /// <summary>
-    /// Represents an application that have UI screen. The NUIApplication class has a default stage.
+    /// Represents an application that have UI screen. The NUIApplication class has a default stage.
     /// </summary>
     public class NUIApplication : CoreApplication
     {
         /// <summary>
+        /// Occurs whenever the application is resumed.
+        /// </summary>
+        /// <since_tizen> 4 </since_tizen>
+        public event EventHandler Resumed;
+
+        /// <summary>
+        /// Occurs whenever the application is paused.
+        /// </summary>
+        /// <since_tizen> 4 </since_tizen>
+        public event EventHandler Paused;
+
+        /// <summary>
         /// The instance of ResourceManager.
         /// </summary>
         private static System.Resources.ResourceManager resourceManager = null;
+
         /// <summary>
         /// The default constructor.
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
         public NUIApplication() : base(new NUICoreBackend())
         {
         }
 
         /// <summary>
-        /// The constructor with stylesheet.
+        /// The constructor with stylesheet.
         /// </summary>
-        public NUIApplication(string stylesheet) : base(new NUICoreBackend(stylesheet))
+        /// <param name="styleSheet">The styleSheet url.</param>
+        /// <since_tizen> 3 </since_tizen>
+        public NUIApplication(string styleSheet) : base(new NUICoreBackend(styleSheet))
         {
         }
 
         /// <summary>
-        /// The constructor with stylesheet and window mode.
+        /// The constructor with stylesheet and window mode.
         /// </summary>
-        public NUIApplication(string stylesheet, WindowMode windowMode) : base(new NUICoreBackend(stylesheet,windowMode))
+        /// <param name="styleSheet">The styleSheet url.</param>
+        /// <param name="windowMode">The windowMode.</param>
+        /// <since_tizen> 3 </since_tizen>
+        public NUIApplication(string styleSheet, WindowMode windowMode) : base(new NUICoreBackend(styleSheet, windowMode))
         {
         }
 
         /// <summary>
-        /// Overrides this method if want to handle behavior.
+        /// Overrides this method if you want to handle behavior.
         /// </summary>
         protected override void OnLocaleChanged(LocaleChangedEventArgs e)
         {
+            base.OnLocaleChanged(e);
         }
 
         /// <summary>
-        /// Overrides this method if want to handle behavior.
+        /// Overrides this method if you want to handle behavior.
         /// </summary>
         protected override void OnLowBattery(LowBatteryEventArgs e)
         {
-            Log.Debug("NUI", "OnLowBattery() is called!");
+            base.OnLowBattery(e);
         }
 
         /// <summary>
-        /// Overrides this method if want to handle behavior.
+        /// Overrides this method if you want to handle behavior.
         /// </summary>
         protected override void OnLowMemory(LowMemoryEventArgs e)
         {
-            Log.Debug("NUI", "OnLowMemory() is called!");
+            base.OnLowMemory(e);
         }
 
         /// <summary>
-        /// Overrides this method if want to handle behavior.
+        /// Overrides this method if you want to handle behavior.
         /// </summary>
         protected override void OnRegionFormatChanged(RegionFormatChangedEventArgs e)
         {
-            Log.Debug("NUI", "OnRegionFormatChanged() is called!");
+            base.OnRegionFormatChanged(e);
         }
 
         /// <summary>
-        /// Overrides this method if want to handle behavior.
+        /// Overrides this method if you want to handle behavior.
         /// </summary>
         protected override void OnTerminate()
         {
-            Log.Debug("NUI", "OnTerminate() is called!");
+            base.OnTerminate();
+        }
+
+        /// <summary>
+        /// Overrides this method if you want to handle behavior.
+        /// </summary>
+        protected virtual void OnPause()
+        {
+            Paused?.Invoke(this, EventArgs.Empty);
         }
 
         /// <summary>
-        /// Overrides this method if want to handle behavior.
+        /// Overrides this method if you want to handle behavior.
         /// </summary>
-        protected void OnPause()
+        protected virtual void OnResume()
         {
+            Resumed?.Invoke(this, EventArgs.Empty);
         }
 
         /// <summary>
-        /// Overrides this method if want to handle behavior.
+        /// Overrides this method if you want to handle behavior.
         /// </summary>
-        protected void OnResume()
+        protected virtual void OnPreCreate()
         {
-            Log.Debug("NUI", "OnResume() is called!");
         }
 
         /// <summary>
-        /// Overrides this method if want to handle behavior.
+        /// Overrides this method if you want to handle behavior.
         /// </summary>
         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);
+                Log.Info("NUI", "OnAppControlReceived() is called! ApplicationId=" + e.ReceivedAppControl.ApplicationId);
+                Log.Info("NUI", "CallerApplicationId=" + e.ReceivedAppControl.CallerApplicationId + "   IsReplyRequest=" + e.ReceivedAppControl.IsReplyRequest);
             }
+            base.OnAppControlReceived(e);
         }
 
         /// <summary>
-        /// Overrides this method if want to handle behavior.
+        /// Overrides this method if you want to handle behavior.
         /// </summary>
         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();
         }
 
         /// <summary>
-        /// Run NUIApplication.
+        /// Runs the NUIApplication.
         /// </summary>
         /// <param name="args">Arguments from commandline.</param>
+        /// <since_tizen> 4 </since_tizen>
         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.PreCreated, OnPreCreate);
             Backend.AddEventHandler(EventType.Resumed, OnResume);
-            Backend.AddEventHandler<AppControlReceivedEventArgs>(EventType.AppControlReceived, OnAppControlReceived);
             Backend.AddEventHandler(EventType.Paused, OnPause);
-            Backend.AddEventHandler(EventType.Terminated, OnTerminate);
-            Backend.AddEventHandler<RegionFormatChangedEventArgs>(EventType.RegionFormatChanged, OnRegionFormatChanged);
-            Backend.AddEventHandler<LowMemoryEventArgs>(EventType.LowMemory, OnLowMemory);
-            Backend.AddEventHandler<LowBatteryEventArgs>(EventType.LowBattery, OnLowBattery);
-            Backend.AddEventHandler<LocaleChangedEventArgs>(EventType.LocaleChanged, OnLocaleChanged);
-            Backend.AddEventHandler(EventType.Created, OnCreate);
-
-            Backend.Run(argsClone);
+            base.Run(args);
         }
 
         /// <summary>
-        /// Exit NUIApplication.
+        /// Exits the NUIApplication.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
         public override void Exit()
         {
-            Backend.Exit();
+            base.Exit();
+        }
+
+        /// <summary>
+        /// Ensures that the function passed in is called from the main loop when it is idle.
+        /// </summary>
+        /// <param name="func">The function to call</param>
+        /// <returns>true if added successfully, false otherwise</returns>
+        /// <since_tizen> 4 </since_tizen>
+        public bool AddIdle(System.Delegate func)
+        {
+            return ((NUICoreBackend)this.Backend).AddIdle(func);
         }
 
         /// <summary>
         /// Enumeration for deciding whether a NUI application window is opaque or transparent.
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
         public enum WindowMode
         {
+            /// <summary>
+            /// Opaque
+            /// </summary>
+            /// <since_tizen> 3 </since_tizen>
             Opaque = 0,
+            /// <summary>
+            /// Transparent
+            /// </summary>
+            /// <since_tizen> 3 </since_tizen>
             Transparent = 1
         }
 
@@ -190,8 +219,9 @@ namespace Tizen.NUI
         }
 
         /// <summary>
-        /// ResourceManager to handle multilingual
+        /// ResourceManager to handle multilingual.
         /// </summary>
+        /// <since_tizen> 4 </since_tizen>
         public static System.Resources.ResourceManager MultilingualResourceManager
         {
             get
@@ -203,5 +233,17 @@ namespace Tizen.NUI
                 resourceManager = value;
             }
         }
+
+        /// <summary>
+        /// Gets the window instance.
+        /// </summary>
+        [Obsolete("Please do not use! this will be deprecated")]
+        public Window Window
+        {
+            get
+            {
+                return Window.Instance;
+            }
+        }
     }
-}
+}
\ No newline at end of file