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以降では補正する必要がある
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;
public override void GetDpi(out float dpix, out float dpiy)
{
- dpix = DisplayInformation.GetForCurrentView().LogicalDpi;
- dpiy = DisplayInformation.GetForCurrentView().LogicalDpi;
+ Util.GetDpi(out dpix, out dpiy);
}
public bool Resize(Windows.UI.Xaml.Shapes.Rectangle rect, double width, double height)
Point startPos, endPos;
TextStoreHelper.GetStringExtent(this.Document, this.View, i_startIndex, i_endIndex, out startPos, out endPos);
- float dpi;
- this.Render.GetDpi(out dpi, out dpi);
- double scale = dpi / 96.0;
-
- var screenStartPos = Util.GetScreentPoint(startPos.Scale(scale), this);
- var screenEndPos = Util.GetScreentPoint(endPos.Scale(scale), this);
+ double scale = Util.GetScale();
+
+ //DIPを渡すと予測候補の位置がおかしくなるので、デバイス依存の座標に変換する
+ var screenStartPos = Util.GetScreentPoint(startPos, this).Scale(scale);
+ var screenEndPos = Util.GetScreentPoint(endPos, this).Scale(scale);
o_topLeft = new POINT((int)(screenStartPos.X), (int)(screenStartPos.Y));
o_bottomRight = new POINT((int)(screenEndPos.X), (int)(screenEndPos.Y));
}