OSDN Git Service

ナレーター実行時にフォーカスがずれるバグを修正した
authorkonekoneko <test2214@hotmail.co.jp>
Sun, 18 Sep 2016 17:06:08 +0000 (22:36 +0530)
committerkonekoneko <test2214@hotmail.co.jp>
Sun, 18 Sep 2016 17:06:08 +0000 (22:36 +0530)
Core/Automaion/FooTextBoxAutomationPeer.cs
Core/ITextRender.cs
Core/Util.cs

index fb4ad1e..3ef3d8e 100644 (file)
@@ -194,7 +194,7 @@ namespace FooEditEngine
 #if METRO || WINDOWS_UWP
         ITextRangeProvider ITextProvider.RangeFromPoint(Windows.Foundation.Point screenLocation)
         {
-            Windows.Foundation.Point pt = Util.GetClientPoint(screenLocation, this.fooTextBox);
+            Point pt = Util.GetClientPoint(screenLocation, this.fooTextBox);
 
             int index = this.fooTextBox.GetIndexFromPostion(pt);
             int length = 1;
@@ -404,10 +404,13 @@ namespace FooEditEngine
 
 
 #if METRO || WINDOWS_UWP
-            Windows.Foundation.Point topLeftPos = this.textbox.GetPostionFromTextPoint(topLeft);
-            Windows.Foundation.Point bottomRightPos = this.textbox.GetPostionFromTextPoint(bottomRight);
-            topLeftPos = Util.GetScreentPoint(topLeftPos, this.textbox);
-            bottomRightPos = Util.GetScreentPoint(bottomRightPos, this.textbox);
+            float dpi;
+            Util.GetDpi(out dpi,out dpi);
+            double scale = dpi / 96;
+            Point topLeftPos = this.textbox.GetPostionFromTextPoint(topLeft);
+            Point bottomRightPos = this.textbox.GetPostionFromTextPoint(bottomRight);
+            topLeftPos = topLeftPos.Scale(scale);
+            bottomRightPos = bottomRightPos.Scale(scale);
 #endif
 #if WPF
             System.Windows.Point topLeftPos = this.textbox.GetPostionFromTextPoint(topLeft);
index a269220..2edef63 100644 (file)
@@ -72,6 +72,13 @@ namespace FooEditEngine
             this.Y *= scale;
             return this;
         }
+
+        public Point Offset(double x_offset, double y_offset)
+        {
+            this.X += x_offset;
+            this.Y += y_offset;
+            return this;
+        }
 #if WINFORM
         public static implicit operator Point(System.Drawing.Point p)
         {
index 46efc65..bb8ef6f 100644 (file)
@@ -34,12 +34,11 @@ namespace FooEditEngine
             return dpi / 96.0;
         }
 
-        public static Windows.Foundation.Point GetClientPoint(Windows.Foundation.Point screen, Windows.UI.Xaml.UIElement element)
+        public static Point GetClientPoint(Point screen, Windows.UI.Xaml.UIElement element)
         {
             //Windows10以降では補正する必要がある
             Windows.Foundation.Rect win_rect = Windows.UI.Xaml.Window.Current.CoreWindow.Bounds;
-            screen.X -= win_rect.X;
-            screen.Y -= win_rect.Y;
+            screen = screen.Offset(-win_rect.X, -win_rect.Y);
 
             var gt = element.TransformToVisual(element);
             return gt.TransformPoint(screen);
@@ -52,8 +51,7 @@ namespace FooEditEngine
 
             //Windows10以降では補正する必要がある
             Windows.Foundation.Rect win_rect = Windows.UI.Xaml.Window.Current.CoreWindow.Bounds;
-            screenPoint.X += win_rect.X;
-            screenPoint.Y += win_rect.Y;
+            screenPoint = screenPoint.Offset(win_rect.X, win_rect.Y);
 
             return screenPoint;
         }