#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;
#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);
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);
//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;
}