Vector2类型在Win2D绘图方式上不一致
Vector2 types in Win2D drawing method inconsistency
我将在 Windows 10 年迈入 UAP 世界的第一步。
我正在尝试使用 Win2D 库编写一个在 IoT/R-PI2 设备上显示图形的小型应用程序。
我有一个显示单线的绘图方法:
private void Canvas_Draw(CanvasControl sender, CanvasDrawEventArgs args)
{
var a = new System.Numerics.Vector2(10,10);
var b = new System.Numerics.Vector2(100,100);
args.DrawingSession.DrawLine(a,b,Colors.Yellow);
}
VS2015 社区版。 IntelliSense 告诉我,我提供了参数 'a' 和 'b' 不兼容的 vector2 类型。它期待 Windows.Foundation.Numerics.Vector2 而不是 System.Numerics.Vector2.
但是,该程序在桌面和 r-pi 上编译和运行都很好。
我的应用程序的某些部分基于 this tutorial,其中该方法显然采用 System.Numeric.Verctor2
个参数。
我在另一个 post 中读到 Windows 8.1 和 10 之间的 API 以及这个 GitHub issue。
我也导入了这个post中提到的包,但它没有改变任何东西。
我不知道这个 post 是否与我的问题有关,但至少它提到了这两个命名空间的问题。
为什么 IntelliSense 将此代码突出显示为错误? VS 中有错误吗?
我是不是做错了什么?
项目:https://github.com/chrisi/IoTCanvas
一些系统/IDE 相关规格:
- Microsoft Visual Studio Community 2015 版本 14.0.23107.0 D14REL
- Microsoft .NET 框架版本 4.6.00079
- 已安装版本:社区
- Visual Basic 2015 00322-20000-00000-AA366
- 可视化 C# 2015 00322-20000-00000-AA366
- Visual C++ 2015 00322-20000-00000-AA366
- Windows Phone SDK 8.0 - ENU 00322-20000-00000-AA366
- Visual Studio 包 1.0
的 Application Insights 工具
- JetBrains ReSharper Ultimate 2015.2 内部版本 103.0.20150818.200216
- Microsoft Azure 移动服务工具 1.4
- NuGet 包管理器 3.2.0
- PreEmptive Analytics Visualizer 1.2
- SQL 服务器压缩 &SQLite 工具箱 4.3.0
- Visual Studio 通用工具 Windows 应用程序 14.0.23309.00 d14oob
System.Numerics.Vectors 附带 Windows 10,您无需单独安装。
您看到对 Windows.Foundation.Numerics 的引用的原因是因为 Windows.Foundation.Numerics 是 WinRT 类型的名称。这在 .NET 中被投影为 System.Numerics.Vector2。其他语言可能会以不同的方式投影 - 例如,在 C++/CX 中它是 Windows::Foundation::Numerics::float2。
我强烈怀疑您 运行 遇到了 ReSharper 的问题 - 请参阅 https://github.com/Microsoft/Win2D/issues/145。那里的话是:
This one is fixed in R#10 and the fix will be available in one of the next EAP builds.
我将在 Windows 10 年迈入 UAP 世界的第一步。
我正在尝试使用 Win2D 库编写一个在 IoT/R-PI2 设备上显示图形的小型应用程序。
我有一个显示单线的绘图方法:
private void Canvas_Draw(CanvasControl sender, CanvasDrawEventArgs args)
{
var a = new System.Numerics.Vector2(10,10);
var b = new System.Numerics.Vector2(100,100);
args.DrawingSession.DrawLine(a,b,Colors.Yellow);
}
VS2015 社区版。 IntelliSense 告诉我,我提供了参数 'a' 和 'b' 不兼容的 vector2 类型。它期待 Windows.Foundation.Numerics.Vector2 而不是 System.Numerics.Vector2.
但是,该程序在桌面和 r-pi 上编译和运行都很好。
我的应用程序的某些部分基于 this tutorial,其中该方法显然采用 System.Numeric.Verctor2
个参数。
我在另一个 post 中读到 Windows 8.1 和 10 之间的 API 以及这个 GitHub issue。
我也导入了这个post中提到的包,但它没有改变任何东西。
我不知道这个 post 是否与我的问题有关,但至少它提到了这两个命名空间的问题。
为什么 IntelliSense 将此代码突出显示为错误? VS 中有错误吗?
我是不是做错了什么?
项目:https://github.com/chrisi/IoTCanvas
一些系统/IDE 相关规格:
- Microsoft Visual Studio Community 2015 版本 14.0.23107.0 D14REL
- Microsoft .NET 框架版本 4.6.00079
- 已安装版本:社区
- Visual Basic 2015 00322-20000-00000-AA366
- 可视化 C# 2015 00322-20000-00000-AA366
- Visual C++ 2015 00322-20000-00000-AA366
- Windows Phone SDK 8.0 - ENU 00322-20000-00000-AA366
- Visual Studio 包 1.0 的 Application Insights 工具
- JetBrains ReSharper Ultimate 2015.2 内部版本 103.0.20150818.200216
- Microsoft Azure 移动服务工具 1.4
- NuGet 包管理器 3.2.0
- PreEmptive Analytics Visualizer 1.2
- SQL 服务器压缩 &SQLite 工具箱 4.3.0
- Visual Studio 通用工具 Windows 应用程序 14.0.23309.00 d14oob
System.Numerics.Vectors 附带 Windows 10,您无需单独安装。
您看到对 Windows.Foundation.Numerics 的引用的原因是因为 Windows.Foundation.Numerics 是 WinRT 类型的名称。这在 .NET 中被投影为 System.Numerics.Vector2。其他语言可能会以不同的方式投影 - 例如,在 C++/CX 中它是 Windows::Foundation::Numerics::float2。
我强烈怀疑您 运行 遇到了 ReSharper 的问题 - 请参阅 https://github.com/Microsoft/Win2D/issues/145。那里的话是:
This one is fixed in R#10 and the fix will be available in one of the next EAP builds.