c# - 无法从 System.Collections.Generic.List 转换到 System.Collections.Generic.List
问题描述
我在 WPF 应用程序中使用 GMaps.NET 和 GMaps.WindowsPresentation。GMaps 演示文稿附带的类之一是 GMapPolygon 和一个名为 CreatePath 的函数。我正在尝试使用此函数测试在两个或多个点之间添加一条线,但在解析点列表时出现错误。它必须是某种类型的列表还是我错过了什么。
在使用 Windows 演示文稿时,我找不到在两点之间绘制一条线的示例,但有用于 Windows 窗体的示例
这就是我现在想要做的:
List<PointLatLng> points = new List<PointLatLng>();
points.Add(new PointLatLng(48.866383, 2.323575));
points.Add(new PointLatLng(48.863868, 2.321554));
points.Add(new PointLatLng(48.861017, 2.330030));
points.Add(new PointLatLng(48.863727, 2.331918));
GMapPolygon SectorPolygon = new GMapPolygon(points);
SectorPolygon.CreatePath( points,true);
这是我要解析的函数:
public virtual Path CreatePath(List<Point> localPath, bool addBlurEffect)
{
// Create a StreamGeometry to use to specify myPath.
StreamGeometry geometry = new StreamGeometry();
using(StreamGeometryContext ctx = geometry.Open())
{
ctx.BeginFigure(localPath[0], true, true);
// Draw a line to the next specified point.
ctx.PolyLineTo(localPath, true, true);
}
// Freeze the geometry (make it unmodifiable)
// for additional performance benefits.
geometry.Freeze();
// Create a path to draw a geometry with.
Path myPath = new Path();
{
// Specify the shape of the Path using the StreamGeometry.
myPath.Data = geometry;
if(addBlurEffect)
{
BlurEffect ef = new BlurEffect();
{
ef.KernelType = KernelType.Gaussian;
ef.Radius = 3.0;
ef.RenderingBias = RenderingBias.Performance;
}
myPath.Effect = ef;
}
myPath.Stroke = Brushes.MidnightBlue;
myPath.StrokeThickness = 5;
myPath.StrokeLineJoin = PenLineJoin.Round;
myPath.StrokeStartLineCap = PenLineCap.Triangle;
myPath.StrokeEndLineCap = PenLineCap.Square;
myPath.Fill = Brushes.AliceBlue;
myPath.Opacity = 0.6;
myPath.IsHitTestVisible = false;
}
return myPath;
}
解决方案
推荐阅读
- flowtype - 为什么 ReadOnly 对象需要对象中的可选属性?
- javascript - Tampermonkey,等待在另一个选项卡中设置值,它可以被读取
- batch-file - 如何使用带有批处理文件的 youtube-dl 下载 MP3?
- c++ - 其他列表的每个点与列表的最近点
- android - 错误:无法在 pubspec.yaml 中找到资产条目:“assets/fonts/Lato-Regular.ttf”
- javascript - 从反应传单中的地图中删除缩放控件
- c# - C# 重载隐式转换引用旧值
- speech-to-text - Watson Speech to Text 异步 http 接口 - curl/java 无法注册回调
- powershell - 从数组的属性中获取唯一索引项的最快方法
- reactjs - 打字稿 - 使用键变量更改字典的值