OSDN Git Service

予測候補の位置が相変わらずおかしいので再修正
[fooeditengine/FooEditEngine.git] / Core / Util.cs
index 044ba38..f2e16f9 100644 (file)
@@ -19,6 +19,19 @@ namespace FooEditEngine
     class Util
     {
 #if METRO
+        public static void GetDpi(out float dpix, out float dpiy)
+        {
+            dpix = Windows.Graphics.Display.DisplayInformation.GetForCurrentView().LogicalDpi;
+            dpiy = Windows.Graphics.Display.DisplayInformation.GetForCurrentView().LogicalDpi;
+        }
+
+        public static double GetScale()
+        {
+            float dpi;
+            Util.GetDpi(out dpi, out dpi);
+            return dpi / 96.0;
+        }
+
         public static Windows.Foundation.Point GetClientPoint(Windows.Foundation.Point screen, Windows.UI.Xaml.UIElement element)
         {
             //Windows10以降では補正する必要がある
@@ -29,11 +42,11 @@ namespace FooEditEngine
             var gt = element.TransformToVisual(element);
             return gt.TransformPoint(screen);
         }
-        public static Windows.Foundation.Point GetScreentPoint(Windows.Foundation.Point client, Windows.UI.Xaml.UIElement element)
+        public static Point GetScreentPoint(Point client, Windows.UI.Xaml.UIElement element)
         {
             //ウィンドウ内での絶対座標を取得する
             var gt = element.TransformToVisual(null);
-            Windows.Foundation.Point screenPoint = gt.TransformPoint(client);
+            Point screenPoint = gt.TransformPoint(client);
 
             //Windows10以降では補正する必要がある
             Windows.Foundation.Rect win_rect = Windows.UI.Xaml.Window.Current.CoreWindow.Bounds;