本文整理汇总了C#中System.Windows.Media.PointCollection.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# PointCollection.ToArray方法的具体用法?C# PointCollection.ToArray怎么用?C# PointCollection.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.PointCollection
的用法示例。
在下文中一共展示了PointCollection.ToArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PointsToPath
/// <summary>
/// Преобразует набор точек в путь
/// </summary>
/// <param name="points">Коллекция точек</param>
/// <param name="pathKind">Тип пути - Линия(замкнутая/открытая), либо Эллипс</param>
/// <returns></returns>
public static string PointsToPath(PointCollection points, PathKind pathKind) {
var enumerable = points.ToArray();
if (!enumerable.Any()) {
return string.Empty;
}
switch (pathKind) {
case PathKind.Ellipse: {
var radiusX = (enumerable[1].X - enumerable[0].X) / 2;
var radiusY = (enumerable[2].Y - enumerable[1].Y) / 2;
var center = new Point(enumerable[1].X - radiusX, enumerable[2].Y - radiusY);
var geometry = new EllipseGeometry(center: center, radiusX: radiusX, radiusY: radiusY);
return geometry.GetFlattenedPathGeometry().ToString(CultureInfo.InvariantCulture);
}
default: {
var start = enumerable[0];
var segments = new List<LineSegment>();
for (var i = 1; i < enumerable.Length; i++) {
segments.Add(new LineSegment(new Point(enumerable[i].X, enumerable[i].Y), true));
}
var figure = new PathFigure(start, segments, (pathKind == PathKind.ClosedLine));
var geometry = new PathGeometry();
geometry.Figures.Add(figure);
return geometry.ToString(CultureInfo.InvariantCulture);
}
}
}
示例2: InsidePolygon3D
// Checks if 3D points projected to the plane of the polygon are inside the polygon
public static bool InsidePolygon3D(Point3D[] polyVertices, Point3D projectedPoint)
{
PointCollection points = new PointCollection();
foreach (Point3D point in polyVertices)
{
points.Add(new Point(point.X, point.Y));
}
return InsidePolygon(points.ToArray(), new Point(projectedPoint.X, projectedPoint.Y));
}