當前位置: 首頁>>代碼示例>>C#>>正文


C# PointCollection.ToArray方法代碼示例

本文整理匯總了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);
					}
			}
		}
開發者ID:xbadcode,項目名稱:Rubezh,代碼行數:33,代碼來源:InternalConverter.cs

示例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));
 }
開發者ID:frksptr,項目名稱:kinect-demo,代碼行數:10,代碼來源:GeometryHelper.cs


注:本文中的System.Windows.Media.PointCollection.ToArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。