如何获得触摸X Y相对于屏幕的坐标? [英] How obtain touch X Y cordinates relative to screen?
本文介绍了如何获得触摸X Y相对于屏幕的坐标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好我的信息和示例关于如何获得相对于屏幕的XY协调,而不是我触摸的元素。
C#示例代码赞赏。
Hello I really info and example about how obtain X Y coordinated relative to screen, not to elemnt I touch.
C# example code appreciated.
推荐答案
<您好Groboto,
Hi Groboto,
您可以通过以下代码将协调元素转换为屏幕协调。
You could translate element coordinated to screen coordinated via the following code.
void MainWindow_TouchDown(object sender, TouchEventArgs e)
{
TouchPoint pointFromWindow = e.GetTouchPoint(this); //relative to Top-Left corner of Window
Point locationFromScreen = this.PointToScreen(new Point(pointFromWindow.Position.X, pointFromWindow.Position.Y)); //translate to coordinates relative to Top-Left corner of Screen
}
有关详细信息,请参阅:
For more information, please refer to:
https://msdn.microsoft.com/en-us/library/system.windows.media.visual.pointtoscreen(v=vs.110).aspx
最佳问候,
张龙
这篇关于如何获得触摸X Y相对于屏幕的坐标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文