【问题标题】:Point/Point3D to TouchPoint?Point/Point3D 到 TouchPoint?
【发布时间】:2012-06-15 22:06:01
【问题描述】:

我编写了一个使用鼠标的 C# 程序,它运行良好。我现在希望实现触摸支持。问题是我经常跟踪鼠标并在整个程序中使用 Point 和 Point3D 类。当我使用触摸时,我需要跟踪“鼠标”的移动位置。我可以得到触摸的坐标,但这就是我卡住的地方。我正在使用 Helix 3D Toolkit,大多数功能都需要 Point 或 Point3D 输入参数。我的问题是,有没有办法将 TouchPoint 转换为 Point 或 Point3D?或者有没有其他“简单”的方式来实现触摸支持?

这是我正在尝试做的一些代码:

private Point3D? GetPoints(TouchEventArgs e)
{
    var p = e.GetTouchPoint(ViewPort);
    var ray = Viewport3DHelper.Point2DtoRay3D(ViewPort.Viewport, p); //error here at p
    if (ray != null)
    {
        var pi = ray.PlaneIntersection(new Point3D(0, 0, 0), new Vector3D(0, 0, 1));
        if (pi.HasValue)
            return pi;
    }
    return null;
}

【问题讨论】:

  • 没关系,我想通了。我刚刚用 p.Bounds.X 和 p.Bounds.Y 创建了一个新的 Point()。无论如何,谢谢你们!

标签: c# wpf touch touchscreen


【解决方案1】:

想通了。我刚刚用 p.Bounds.X 和 p.Bounds.Y 创建了一个新的 Point()。

【讨论】:

    猜你喜欢
    • 2013-03-29
    • 1970-01-01
    • 1970-01-01
    • 2019-01-06
    • 2013-08-20
    • 1970-01-01
    • 2010-09-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多