Add ScreenDpi API in Window class
authorSeungkeun Lee <sngn.lee@samsung.com>
Mon, 19 Dec 2016 00:48:45 +0000 (09:48 +0900)
committerSeungkeun Lee <sngn.lee@samsung.com>
Fri, 6 Jan 2017 00:51:00 +0000 (16:51 -0800)
 - To get Screen DPI

Change-Id: Ic183809290901654330427d9dc8c7f67630cb918

src/ElmSharp/ElmSharp/Window.cs
src/ElmSharp/Interop/Interop.Elementary.Win.cs
test/ElmSharp.Test/ElmSharp.Test.csproj
test/ElmSharp.Test/TC/ScreenInformationTest.cs [new file with mode: 0644]
test/ElmSharp.Test/TestRunner.cs

index 1b4d54d..3409b2d 100644 (file)
@@ -90,6 +90,16 @@ namespace ElmSharp
             }
         }
 
+        public Point ScreenDpi
+        {
+            get
+            {
+                Point point = default(Point);
+                Interop.Elementary.elm_win_screen_dpi_get(Handle, out point.X, out point.Y);
+                return point;
+            }
+        }
+
         public int Rotation
         {
             get
@@ -151,7 +161,6 @@ namespace ElmSharp
             }
         }
 
-
         public void Active()
         {
             Interop.Elementary.elm_win_activate(Handle);
index bc7c0b9..aadc2de 100644 (file)
@@ -115,5 +115,8 @@ internal static partial class Interop
             rotations = null;
             return false;
         }
+
+        [DllImport(Libraries.Elementary)]
+        internal static extern void elm_win_screen_dpi_get(IntPtr obj, out int xdpi, out int ydpi);
     }
 }
index ac91e1b..4eeca22 100644 (file)
@@ -43,6 +43,7 @@
     <Compile Include="TC\BackgroundTest1.cs" />
     <Compile Include="TC\BackgroundTest2.cs" />
     <Compile Include="TC\BackgroundTest3.cs" />
+    <Compile Include="TC\ScreenInformationTest.cs" />
     <Compile Include="TC\BoxLayoutTest1.cs" />
     <Compile Include="TC\BoxTest1.cs" />
     <Compile Include="TC\BackgroundColorTest1.cs" />
       </FlavorProperties>
     </VisualStudio>
   </ProjectExtensions>
-</Project>
\ No newline at end of file
+</Project>
diff --git a/test/ElmSharp.Test/TC/ScreenInformationTest.cs b/test/ElmSharp.Test/TC/ScreenInformationTest.cs
new file mode 100644 (file)
index 0000000..92a5d4a
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.Linq;
+
+namespace ElmSharp.Test
+{
+    public class ScreenInformationTest : TestCaseBase
+    {
+        public override string TestName => "ScreenInformationTest";
+        public override string TestDescription => "To get screen information";
+
+        Naviframe _navi;
+        int _sequence = 0;
+
+        public override void Run(Window window)
+        {
+            Conformant conformant = new Conformant(window);
+            conformant.Show();
+            Box box = new Box(window);
+            box.Show();
+            conformant.SetContent(box);
+            Label label = new Label(window);
+            label.SetAlignment(-1, 0);
+            label.SetWeight(1, 0);
+            label.Text = string.Format("<span color=#FFFFFF , font_size=50>ScreenSize : {0}x{1}", window.ScreenSize.Width, window.ScreenSize.Height);
+            label.Show();
+            box.PackEnd(label);
+            Label label2 = new Label(window);
+            label2.SetAlignment(-1, 0);
+            label2.SetWeight(1, 0);
+            label2.Text = string.Format("<span color=#FFFFFF , font_size=50>ScreenDPI : xdpi : {0} ydpi : {1}", window.ScreenDpi.X, window.ScreenDpi.Y);
+            label2.Show();
+            box.PackEnd(label2);
+        }
+
+        EvasObject CreatePage(Window parent)
+        {
+            Box box = new Box(parent);
+            box.Show();
+
+            Label label = new Label(parent)
+            {
+                Text = string.Format("{0} Page", _sequence++),
+                WeightX = 1,
+                AlignmentX = -1,
+            };
+            Button push = new Button(parent)
+            {
+                Text = "Push",
+                WeightX = 1,
+                AlignmentX = -1,
+            };
+            Button pop = new Button(parent)
+            {
+                Text = "pop",
+                WeightX = 1,
+                AlignmentX = -1,
+            };
+
+            label.Show();
+            push.Show();
+            pop.Show();
+
+            push.Clicked += (s, e) =>
+            {
+                _navi.Push(CreatePage(parent), string.Format("{0} Page", _sequence - 1));
+            };
+
+            pop.Clicked += (s, e) =>
+            {
+                var item = _navi.NavigationStack.LastOrDefault();
+                int nativePointer = (int)(IntPtr)(item.Content);
+                Console.WriteLine("----- Before Call _navi.Pop() {0:x} ", nativePointer);
+                _navi.Pop();
+                Console.WriteLine("----- After Call _navi.Pop() {0:x} ", nativePointer);
+            };
+
+            push.Resize(500, 100);
+            pop.Resize(500, 100);
+            label.Resize(500, 100);
+            box.SetLayoutCallback(() =>
+            {
+                Console.WriteLine("Layout callback with : {0}", box.Geometry);
+                var rect = box.Geometry;
+                label.Move(rect.X, rect.Y);
+                push.Move(rect.X, rect.Y + 100);
+                pop.Move(rect.X, rect.Y + 200);
+            });
+
+            box.PackEnd(label);
+            box.PackEnd(push);
+            box.PackEnd(pop);
+            return box;
+        }
+    }
+}
index 0d7afa2..b359d20 100644 (file)
@@ -128,6 +128,7 @@ namespace ElmSharp.Test
         private void CreateFirstPage(IEnumerable<TestCaseBase> testCases)
         {
             _firstPageWindow = CreateWindow();
+            Console.WriteLine("Screen DPI : {0}", _firstPageWindow.ScreenDpi.X);
             Conformant conformant = new Conformant(_firstPageWindow);
             conformant.Show();
             Box box = new Box(_firstPageWindow)