[Tizen] Add a new constructor to NUIApplication. 50/143850/3
authorFeng Jin <feng16.jin@samsung.com>
Tue, 8 Aug 2017 17:50:12 +0000 (01:50 +0800)
committerMinho Sun <minho.sun@samsung.com>
Wed, 23 Aug 2017 12:35:52 +0000 (12:35 +0000)
Change-Id: Ie55cd4eab61e76d648c65035007e3682ab9ca3dc
Signed-off-by: Feng Jin <feng16.jin@samsung.com>
Tizen.NUI/Tizen.NUI.csproj
Tizen.NUI/src/internal/Application.cs
Tizen.NUI/src/internal/NDalicPINVOKE.cs
Tizen.NUI/src/internal/NUICoreBackend.cs

index a756ddc..9b983d6 100755 (executable)
@@ -25,8 +25,8 @@
 \r
   <ItemGroup>\r
     <PackageReference Include="System.Reflection.TypeExtensions" Version="4.3.0" PrivateAssets="All" />\r
-    <PackageReference Include="Tizen.Applications.Common" Version="1.5.8" />\r
-    <PackageReference Include="Tizen.System.SystemSettings" Version="1.0.4" PrivateAssets="All"/>\r
+    <PackageReference Include="Tizen.Applications.Common" Version="1.5.10" />\r
+    <PackageReference Include="Tizen.System.SystemSettings" Version="1.0.4" PrivateAssets="All" />\r
   </ItemGroup>\r
   <Target Name="ChangeAliasesOfStrongNameAssemblies" BeforeTargets="FindReferenceAssembliesForReferences;ResolveReferences">\r
     <ItemGroup>\r
index 9a3c950..1bfbc8d 100755 (executable)
@@ -1134,6 +1134,21 @@ namespace Tizen.NUI
             return ret;
         }
 
+
+        public static Application NewApplication(string[] args, string stylesheet, Application.WindowMode windowMode)
+        {
+            NUILog.Debug(" NewApplication(string[] args, string stylesheet, Application.WindowMode windowMode) is called! ");
+
+            Application ret = New(args, stylesheet, (Application.WindowMode)windowMode);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+
+            // we've got an application now connect the signals
+            ret.SetupDelegates();
+            // set the singleton
+            _instance = ret;
+            return _instance;
+        }
+
         //Removed from v0.2.33
         /*public bool AddIdle(System.Delegate func)
         {
@@ -1187,6 +1202,28 @@ namespace Tizen.NUI
             return ret;
         }
 
+        public static Application New(string[] args, string stylesheet, Application.WindowMode windowMode)
+        {
+            NUILog.Debug("New(string[] args) is called!");
+            int argc = args.Length;
+            string argvStr = "";
+            for (int index = 0; index < args.Length; index++)
+            {
+                if(index == (args.Length - 1))
+                {
+                    argvStr = argvStr + args[index];
+                }
+                else
+                {
+                    argvStr = argvStr + args[index] + " ";
+                }
+            }
+
+            Application ret = new Application(NDalicPINVOKE.Application_New__MANUAL_4(argc, argvStr, stylesheet, (int)windowMode), true);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
+        }
+
         public static Application New(int argc, string stylesheet, Application.WindowMode windowMode, Rectangle positionSize)
         {
             Application ret = new Application(NDalicPINVOKE.Application_New__SWIG_4(argc, stylesheet, (int)windowMode, Rectangle.getCPtr(positionSize)), true);
index 1939974..e6c72b6 100755 (executable)
@@ -6296,6 +6296,9 @@ class NDalicPINVOKE {
   [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_Application_New__SWIG_3")]
   public static extern global::System.IntPtr Application_New__SWIG_3(int jarg1, string jarg3, int jarg4);
 
+  [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_Application_New__MANUAL_4")]
+  public static extern global::System.IntPtr Application_New__MANUAL_4(int jarg1, string jarg2, string jarg3, int jarg4);
+
   [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_new_Application__SWIG_0")]
   public static extern global::System.IntPtr new_Application__SWIG_0();
 
@@ -6428,7 +6431,6 @@ class NDalicPINVOKE {
   [global::System.Runtime.InteropServices.DllImport("NDalic", EntryPoint="CSharp_Dali_Application_New__SWIG_4")]
   public static extern global::System.IntPtr Application_New__SWIG_4(int jarg1, string jarg3, int jarg4, global::System.Runtime.InteropServices.HandleRef jarg5);
 
-
   [global::System.Runtime.InteropServices.DllImport("libdali-csharp-binder.so", EntryPoint="CSharp_Dali_TimerSignalType_Empty")]
   public static extern bool TimerSignalType_Empty(global::System.Runtime.InteropServices.HandleRef jarg1);
 
index 7aa0e00..d8dcd81 100755 (executable)
@@ -30,6 +30,8 @@ namespace Tizen.NUI
         /// Application instance to connect event.
         /// </summary>
         protected Application _application;
+        private string _stylesheet = "";
+        private NUIApplication.WindowMode _windowMode = NUIApplication.WindowMode.Opaque;
 
         /// <summary>
         /// Dictionary to contain each type of event callback.
@@ -41,7 +43,6 @@ namespace Tizen.NUI
         /// </summary>
         public NUICoreBackend()
         {
-            _application = Application.NewApplication();
         }
 
         /// <summary>
@@ -49,7 +50,7 @@ namespace Tizen.NUI
         /// </summary>
         public NUICoreBackend(string stylesheet)
         {
-            _application = Application.NewApplication(stylesheet);
+            _stylesheet = stylesheet;
         }
 
         /// <summary>
@@ -57,7 +58,8 @@ namespace Tizen.NUI
         /// </summary>
         public NUICoreBackend(string stylesheet, NUIApplication.WindowMode windowMode)
         {
-            _application = Application.NewApplication(stylesheet, (Application.WindowMode)windowMode );
+            _stylesheet = stylesheet;
+            _windowMode = windowMode;
         }
 
         /// <summary>
@@ -89,7 +91,10 @@ namespace Tizen.NUI
         /// </summary>
         public void Dispose()
         {
-            _application.Dispose();
+            if(_application != null)
+            {
+                _application.Dispose();
+            }
         }
 
         /// <summary>
@@ -97,7 +102,10 @@ namespace Tizen.NUI
         /// </summary>
         public void Exit()
         {
-            _application.Quit();
+            if(_application != null)
+            {
+                _application.Quit();
+            }
         }
 
         /// <summary>
@@ -107,6 +115,17 @@ namespace Tizen.NUI
         public void Run(string[] args)
         {
             TizenSynchronizationContext.Initialize();
+
+            args[0] = Tizen.Applications.Application.Current.ApplicationInfo.ExecutablePath;
+            if (args.Length == 1)
+            {
+                _application = Application.NewApplication();
+            }
+            else if (args.Length > 1)
+            {
+                _application = Application.NewApplication(args, _stylesheet, (Application.WindowMode)_windowMode);
+            }
+
             _application.BatteryLow += OnBatteryLow;
             _application.LanguageChanged += OnLanguageChanged;
             _application.MemoryLow += OnMemoryLow;