double scale = dpi / 96;
Point topLeftPos = this.textbox.GetPostionFromTextPoint(topLeft);
Point bottomRightPos = this.textbox.GetPostionFromTextPoint(bottomRight);
- topLeftPos = topLeftPos.Scale(scale);
- bottomRightPos = bottomRightPos.Scale(scale);
+ topLeftPos = Util.GetPointInWindow(topLeftPos.Scale(scale),textbox);
+ bottomRightPos = Util.GetPointInWindow(bottomRightPos.Scale(scale),textbox);
#endif
#if WPF
Point topLeftPos = this.textbox.GetPostionFromTextPoint(topLeft);
public static Point GetPointInWindow(Point client, Windows.UI.Xaml.UIElement element)
{
//ウィンドウ内での絶対座標を取得する
- var gt = element.TransformToVisual(null);
+ var gt = element.TransformToVisual(Windows.UI.Xaml.Window.Current.Content);
return gt.TransformPoint(client);
}
public static Point GetScreentPoint(Point client, Windows.UI.Xaml.UIElement element)
{
- //ウィンドウ内での絶対座標を取得する
- Point screenPoint = GetPointInWindow(client, element);
+ var gt = element.TransformToVisual(Windows.UI.Xaml.Window.Current.Content);
+ Point p = gt.TransformPoint(client);
//Windows10以降では補正する必要がある
Windows.Foundation.Rect win_rect = Windows.UI.Xaml.Window.Current.CoreWindow.Bounds;
- screenPoint = screenPoint.Offset(win_rect.X, win_rect.Y);
-
+ var screenPoint = p.Offset(win_rect.X, win_rect.Y);
return screenPoint;
}
public static Windows.Foundation.Rect GetClientRect(Windows.Foundation.Rect screen, Windows.UI.Xaml.UIElement element)
public static Windows.Foundation.Rect GetScreentRect(Windows.Foundation.Rect client, Windows.UI.Xaml.UIElement element)
{
//ウィンドウ内での絶対座標を取得する
- var gt = element.TransformToVisual(null);
+ var gt = element.TransformToVisual(Windows.UI.Xaml.Window.Current.Content);
Windows.Foundation.Rect screenRect = gt.TransformBounds(client);
//Windows10以降では補正する必要がある