[NUI] Add a new WindowLayout Sample
authorDaekwang Ryu <dkdk.ryu@samsung.com>
Fri, 24 Mar 2023 06:02:52 +0000 (15:02 +0900)
committerJaehyun Cho <jaehyun0cho@gmail.com>
Wed, 21 Jun 2023 03:04:41 +0000 (12:04 +0900)
test/NUIWindowLayout/.pic/quarters-screen.png [new file with mode: 0644]
test/NUIWindowLayout/.pic/thirds-screen.png [new file with mode: 0644]
test/NUIWindowLayout/NUIWindowLayout.cs [new file with mode: 0755]
test/NUIWindowLayout/NUIWindowLayout.csproj [new file with mode: 0755]
test/NUIWindowLayout/README.md [new file with mode: 0644]
test/NUIWindowLayout/shared/res/NUIWindowLayout.png [new file with mode: 0755]
test/NUIWindowLayout/tizen-manifest.xml [new file with mode: 0755]

diff --git a/test/NUIWindowLayout/.pic/quarters-screen.png b/test/NUIWindowLayout/.pic/quarters-screen.png
new file mode 100644 (file)
index 0000000..73057e1
Binary files /dev/null and b/test/NUIWindowLayout/.pic/quarters-screen.png differ
diff --git a/test/NUIWindowLayout/.pic/thirds-screen.png b/test/NUIWindowLayout/.pic/thirds-screen.png
new file mode 100644 (file)
index 0000000..4316342
Binary files /dev/null and b/test/NUIWindowLayout/.pic/thirds-screen.png differ
diff --git a/test/NUIWindowLayout/NUIWindowLayout.cs b/test/NUIWindowLayout/NUIWindowLayout.cs
new file mode 100755 (executable)
index 0000000..c57b170
--- /dev/null
@@ -0,0 +1,95 @@
+using System;
+using Tizen.NUI;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Components;
+using System.Collections.Generic;
+
+namespace NUIWindowLayout
+{
+    class Program : NUIApplication
+    {
+        private uint numOfWindows;
+        private List<Window> windows = new List<Window>();
+        private Color[] colors = { Color.DarkGreen, Color.Aqua, Color.Coral, Color.DimGrey };
+
+        public Program(uint numOfWindows) : base(ThemeOptions.None, new DefaultBorder())
+        {
+            if (numOfWindows > 0 && numOfWindows <= 4)
+            {
+                this.numOfWindows = numOfWindows;
+            }
+            else
+            {
+                Tizen.Log.Error("WindowLayout", "numOfWindows is not valid. Put 0 < numOfWindows <= 4");
+            }
+        }
+        protected override void OnCreate()
+        {
+            base.OnCreate();
+            Window window = NUIApplication.GetDefaultWindow();
+            window.KeyEvent += OnKeyEvent;
+            Initialize();
+        }
+
+        void Initialize()
+        {
+            windows.Add(NUIApplication.GetDefaultWindow());
+
+            for (int i = 1; i < numOfWindows; i++)
+            {
+                windows.Add(new Window((i + 1).ToString() + "window", new DefaultBorder()));
+            }
+
+            for (int i = 0; i < numOfWindows; i++)
+            {
+                Window window = windows[i];
+                window.BackgroundColor = colors[i];
+
+                ScrollableBase scrollableBase = new ScrollableBase();
+                scrollableBase.WidthSpecification = LayoutParamPolicies.MatchParent;
+                scrollableBase.HeightSpecification = LayoutParamPolicies.MatchParent;
+                scrollableBase.ScrollingDirection = ScrollableBase.Direction.Vertical;
+
+                scrollableBase.Layout = new LinearLayout()
+                {
+                    LinearOrientation = LinearLayout.Orientation.Vertical,
+                    HorizontalAlignment = HorizontalAlignment.Center,
+                    VerticalAlignment = VerticalAlignment.Center,
+                };
+
+                for (int idxType = 0; idxType < System.Enum.GetValues(typeof(WindowLayoutType)).Length; idxType++)
+                {
+                    Button button = new Button();
+                    button.TextLabel.Text = idxType.ToString() + "." + (WindowLayoutType)idxType; // Set text to the enum value
+                    button.Size = new Size(200, 50);
+
+                    button.Clicked += (object sender, ClickedEventArgs e) =>
+                    {
+                        int number;
+                        number = int.Parse(((Button)sender).TextLabel.Text.Split('.')[0]);
+                        WindowLayoutType type = (WindowLayoutType)number;
+                        Tizen.Log.Info("WindowLayout", type.ToString());
+                        window.SetLayout((WindowLayoutType)number);
+                    };
+                    scrollableBase.Add(button);
+                }
+
+                window.Add(scrollableBase);
+            }
+        }
+
+        public void OnKeyEvent(object sender, Window.KeyEventArgs e)
+        {
+            if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "XF86Back" || e.Key.KeyPressedName == "Escape"))
+            {
+                Exit();
+            }
+        }
+
+        static void Main(string[] args)
+        {
+            var app = new Program(4);
+            app.Run(args);
+        }
+    }
+}
diff --git a/test/NUIWindowLayout/NUIWindowLayout.csproj b/test/NUIWindowLayout/NUIWindowLayout.csproj
new file mode 100755 (executable)
index 0000000..7853929
--- /dev/null
@@ -0,0 +1,24 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <OutputType>Exe</OutputType>
+    <TargetFramework>netcoreapp3.1</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\" />
+    <PackageReference Include="Tizen.NET.Sdk" Version="1.0.9" />
+    <ProjectReference Include="../../src/Tizen/Tizen.csproj" />
+    <ProjectReference Include="../../src/Tizen.NUI/Tizen.NUI.csproj" />
+    <ProjectReference Include="../../src/Tizen.NUI.Components/Tizen.NUI.Components.csproj" />
+  </ItemGroup>
+
+</Project>
diff --git a/test/NUIWindowLayout/README.md b/test/NUIWindowLayout/README.md
new file mode 100644 (file)
index 0000000..b6f811b
--- /dev/null
@@ -0,0 +1,13 @@
+# NUIWindowLayout
+This app shows how to use the WindowLayout feature.
+When you use Window.SetLayout(), you can move and resize the window, for instance moving and resizing the window to the left half of the screen.
+
+
+## ScreenShot
++ LeftThird, CenterThird, RightThird
+![](./.pic/thirds-screen.png)
+
+
+
++ UpperLeftQuarter, UpperRightQuarter, LowerLeftQuarter, LowerRightQuarter
+![](./.pic/quarters-screen.png)
\ No newline at end of file
diff --git a/test/NUIWindowLayout/shared/res/NUIWindowLayout.png b/test/NUIWindowLayout/shared/res/NUIWindowLayout.png
new file mode 100755 (executable)
index 0000000..9f3cb98
Binary files /dev/null and b/test/NUIWindowLayout/shared/res/NUIWindowLayout.png differ
diff --git a/test/NUIWindowLayout/tizen-manifest.xml b/test/NUIWindowLayout/tizen-manifest.xml
new file mode 100755 (executable)
index 0000000..01affb8
--- /dev/null
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns="http://tizen.org/ns/packages" api-version="6.5" package="org.tizen.example.NUIWindowLayout" version="1.0.0">
+  <profile name="common" />
+  <ui-application appid="org.tizen.example.NUIWindowLayout"
+                                       exec="NUIWindowLayout.dll"
+                                       type="dotnet-nui"
+                                       multiple="false"
+                                       taskmanage="true"
+                                       nodisplay="false"
+                                       launch_mode="single"
+                    api-version="9">
+    <label>NUIWindowLayout</label>
+    <icon>NUIWindowLayout.png</icon>
+    <metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true" />
+  </ui-application>
+</manifest>