[NUI] Add FrameComponent dll sample (#2106)
authorhuiyueun <35286162+huiyueun@users.noreply.github.com>
Wed, 21 Oct 2020 01:13:30 +0000 (10:13 +0900)
committerGitHub <noreply@github.com>
Wed, 21 Oct 2020 01:13:30 +0000 (10:13 +0900)
- copy FrameComponentDll to '/opt/usr/' path.
- launch
app_launcher -s org.tizen.example.NUIComponentApplication __AUL_COMPONENT_ID__ csharp_frame3

Signed-off-by: huiyu.eun <huiyu.eun@samsung.com>
test/Tizen.NUI.ComponentApplication/FrameComponentDll/FrameComponentDll.cs [new file with mode: 0755]
test/Tizen.NUI.ComponentApplication/FrameComponentDll/FrameComponentDll.csproj [new file with mode: 0755]
test/Tizen.NUI.ComponentApplication/FrameComponentDll/shared/res/FrameComponentDll.png [new file with mode: 0755]
test/Tizen.NUI.ComponentApplication/NUIComponentApplication/NUIComponentApplication.cs

diff --git a/test/Tizen.NUI.ComponentApplication/FrameComponentDll/FrameComponentDll.cs b/test/Tizen.NUI.ComponentApplication/FrameComponentDll/FrameComponentDll.cs
new file mode 100755 (executable)
index 0000000..64dd3b4
--- /dev/null
@@ -0,0 +1,65 @@
+using System;
+using Tizen.Applications;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+
+namespace FrameComponentDll
+{
+
+    public class MyFrameComponent3 : NUIFrameComponent
+    {
+        private TextLabel text;
+
+        public override bool OnCreate()
+        {
+            Tizen.Log.Error("MYLOG", "MyFrameComponent OnCreate");
+
+            Window.BackgroundColor = Color.Yellow;
+            text = new TextLabel("dll Frame");
+            text.HorizontalAlignment = HorizontalAlignment.Center;
+            text.VerticalAlignment = VerticalAlignment.Bottom;
+            text.TextColor = Color.Red;
+            text.PointSize = 30.0f;
+            text.HeightResizePolicy = ResizePolicyType.FillToParent;
+            text.WidthResizePolicy = ResizePolicyType.FillToParent;
+            Window.Add(text);
+            return true;
+        }
+
+
+        public override void OnDestroy()
+        {
+            Tizen.Log.Error("MYLOG", "MyFrameComponent OnDestroy");
+            text.Dispose();
+        }
+
+        public override void OnPause()
+        {
+            Tizen.Log.Error("MYLOG", "MyFrameComponent OnPause");
+        }
+
+        public override void OnResume()
+        {
+            Tizen.Log.Error("MYLOG", "MyFrameComponent OnResume");
+        }
+
+        public override void OnStart(AppControl appControl, bool restarted)
+        {
+            Tizen.Log.Error("MYLOG", "MyFrameComponent OnStart");
+        }
+
+        public override void OnStop()
+        {
+            Tizen.Log.Error("MYLOG", "MyFrameComponent OnStop");
+        }
+
+        public void ChangeSharedText(string strText)
+        {
+            text.Text = strText;
+        }
+
+        static void Main(string[] args)
+        {
+        }
+    }
+}
diff --git a/test/Tizen.NUI.ComponentApplication/FrameComponentDll/FrameComponentDll.csproj b/test/Tizen.NUI.ComponentApplication/FrameComponentDll/FrameComponentDll.csproj
new file mode 100755 (executable)
index 0000000..9251a43
--- /dev/null
@@ -0,0 +1,24 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <TargetFramework>netcoreapp2.0</TargetFramework>
+  </PropertyGroup>
+
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugType>portable</DebugType>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>None</DebugType>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <Folder Include="lib\"/>
+    <Folder Include="res\"/>
+  </ItemGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\..\..\src\Tizen.NUI\Tizen.NUI.csproj" />
+  </ItemGroup>
+</Project>
+
diff --git a/test/Tizen.NUI.ComponentApplication/FrameComponentDll/shared/res/FrameComponentDll.png b/test/Tizen.NUI.ComponentApplication/FrameComponentDll/shared/res/FrameComponentDll.png
new file mode 100755 (executable)
index 0000000..9f3cb98
Binary files /dev/null and b/test/Tizen.NUI.ComponentApplication/FrameComponentDll/shared/res/FrameComponentDll.png differ
index cd5eb19..9bccab8 100755 (executable)
@@ -1,5 +1,7 @@
 using System;
 using System.Collections.Generic;
+using System.IO;
+using System.Reflection;
 using Tizen.Applications;
 using Tizen.NUI;
 using Tizen.NUI.BaseComponents;
@@ -136,13 +138,39 @@ namespace NUIComponentApplicationSample
             }
         }
 
+        static private Type LoadFrameComponentDll()
+        {
+            string path = @"/opt/usr/FrameComponentDll.dll";
+            FileInfo fi = new FileInfo(path);
+            if (fi.Exists)
+            {
+                Assembly assembly = Assembly.LoadFile(path);
+                if (assembly != null)
+                {
+                    Module[] modules = assembly.GetModules();
+                    Type frameComponent3 = modules[0].GetType("FrameComponentDll.MyFrameComponent3");
+                    return frameComponent3;
+                }
+            }
+            return null;
+        }
+
         static void Main(string[] args)
         {
+
             Dictionary<Type, string> dict = new Dictionary<Type, string>();
             dict.Add(typeof(MyFrameComponent), "csharp_frame");
             dict.Add(typeof(MyFrameComponent2), "csharp_frame2");
-            var app = new Program(dict);
 
+            Type type = LoadFrameComponentDll();
+            if (type != null)
+            {
+                Tizen.Log.Error("MYLOG", "Add type : " + type);
+                dict.Add(type, "csharp_frame3");
+            }
+
+
+            var app = new Program(dict);
             app.Run(args);
             app.Dispose();
         }