当前位置: 首页>>代码示例>>C#>>正文


C# PathFigure.GetFlattenedPathFigure方法代码示例

本文整理汇总了C#中System.Windows.Media.PathFigure.GetFlattenedPathFigure方法的典型用法代码示例。如果您正苦于以下问题:C# PathFigure.GetFlattenedPathFigure方法的具体用法?C# PathFigure.GetFlattenedPathFigure怎么用?C# PathFigure.GetFlattenedPathFigure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Media.PathFigure的用法示例。


在下文中一共展示了PathFigure.GetFlattenedPathFigure方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetPathFigureLength

        internal static double GetPathFigureLength(PathFigure pathFigure)
        {
            if (pathFigure == null)
                return 0;

            var isAlreadyFlattened = pathFigure.Segments.All(pathSegment => (pathSegment is PolyLineSegment) || (pathSegment is LineSegment));

            var pathFigureFlattened = isAlreadyFlattened ? pathFigure : pathFigure.GetFlattenedPathFigure();
            double length = 0;
            var pt1 = pathFigureFlattened.StartPoint;

            foreach (var pathSegment in pathFigureFlattened.Segments)
            {
                if (pathSegment is LineSegment)
                {
                    var pt2 = ((LineSegment)pathSegment).Point;
                    length += (pt2 - pt1).Length;
                    pt1 = pt2;
                }
                else if (pathSegment is PolyLineSegment)
                {
                    var pointCollection = ((PolyLineSegment)pathSegment).Points;
                    foreach (var pt2 in pointCollection)
                    {
                        length += (pt2 - pt1).Length;
                        pt1 = pt2;
                    }
                }
            }
            return length;
        }
开发者ID:bisato,项目名称:DW.WPFToolkit,代码行数:31,代码来源:PathCalculator.cs

示例2: CalculateLength

 private double CalculateLength(PathFigure path)
 {
     PathFigure p = path.GetFlattenedPathFigure(0.1, ToleranceType.Relative);
     double lenght = 0;
     Point start = p.StartPoint;
     for (int i = 0; i < p.Segments.Count; i++)
     {
         if (p.Segments[i] is LineSegment)
         {
             LineSegment seg = (p.Segments[i] as LineSegment);
             lenght += Point.Subtract(start, seg.Point).Length;
             start = seg.Point;
         }
         else if (p.Segments[i] is PolyLineSegment)
         {
             PolyLineSegment seg = (p.Segments[i] as PolyLineSegment);
             for (int j = 0; j < seg.Points.Count; j++)
             {
                 lenght += Point.Subtract(start, seg.Points[j]).Length;
                 start = seg.Points[j];
             }
         }
     }
     return lenght;
 }
开发者ID:nomoreserious,项目名称:FlowSimulation,代码行数:25,代码来源:RoadGraphConfigViewModel.cs

示例3: GetPathFigureLength

		public static double GetPathFigureLength(PathFigure pathFigure)
		{
			double result;
			if (pathFigure == null)
			{
				result = 0.0;
			}
			else
			{
				bool flag = true;
				foreach (PathSegment current in pathFigure.Segments)
				{
					if (!(current is PolyLineSegment) && !(current is LineSegment))
					{
						flag = false;
						break;
					}
				}
				PathFigure pathFigure2 = flag ? pathFigure : pathFigure.GetFlattenedPathFigure();
				double num = 0.0;
				Point point = pathFigure2.StartPoint;
				foreach (PathSegment current in pathFigure2.Segments)
				{
					if (current is LineSegment)
					{
						Point point2 = (current as LineSegment).Point;
						num += (point2 - point).Length;
						point = point2;
					}
					else if (current is PolyLineSegment)
					{
						PointCollection points = (current as PolyLineSegment).Points;
						foreach (Point point2 in points)
						{
							num += (point2 - point).Length;
							point = point2;
						}
					}
				}
				result = num;
			}
			return result;
		}
开发者ID:akordowski,项目名称:Source-Code-Atomiq,代码行数:43,代码来源:TextOnPathBase.cs

示例4: GetPathFigureLength

        //static void OnTextPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
        //{
        //    (obj as TextOnPathBase).OnTextPropertyChanged(args);
        //}
        //protected abstract void OnTextPropertyChanged(DependencyPropertyChangedEventArgs args);
        //static void OnPathPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
        //{
        //    (obj as TextOnPathBase).OnPathPropertyChanged(args);
        //}
        //protected abstract void OnPathPropertyChanged(DependencyPropertyChangedEventArgs args);
        // Utility method
        public static double GetPathFigureLength(PathFigure pathFigure)
        {
            if (pathFigure == null)
                return 0;

            bool isAlreadyFlattened = true;

            foreach (PathSegment pathSegment in pathFigure.Segments)
            {
                if (!(pathSegment is PolyLineSegment) && !(pathSegment is LineSegment))
                {
                    isAlreadyFlattened = false;
                    break;
                }
            }

            PathFigure pathFigureFlattened = isAlreadyFlattened ?
                pathFigure : pathFigure.GetFlattenedPathFigure();

            double length = 0;
            Point pt1     = pathFigureFlattened.StartPoint;

            foreach (PathSegment pathSegment in pathFigureFlattened.Segments)
            {
                if (pathSegment is LineSegment)
                {
                    Point pt2 = (pathSegment as LineSegment).Point;
                    length += (pt2 - pt1).Length;
                    pt1 = pt2;
                }
                else if (pathSegment is PolyLineSegment)
                {
                    PointCollection pointCollection = (pathSegment as PolyLineSegment).Points;
                    foreach (Point pt2 in pointCollection)
                    {
                        length += (pt2 - pt1).Length;
                        pt1 = pt2;
                    }
                }
            }

            return length;
        }
开发者ID:udayanroy,项目名称:SvgSharp,代码行数:54,代码来源:WpfTextOnPathBase.cs

示例5: GetGlyphPolygon

		public static PolygonClosedD2D GetGlyphPolygon(PathFigure figure, bool reverseY, double deviationAngleInDegrees, double deviationAbsolute)
		{
			PolyBezierSegment polyBezierSegment;
			PolyLineSegment polyLineSegment;

			var flattenedFigure = figure.GetFlattenedPathFigure();

			if (flattenedFigure.Segments.Count != 1)
				throw new NotSupportedException();

			var points = (flattenedFigure.Segments[0] as PolyLineSegment).Points.Select(p => ToAltaxo(p, reverseY)).ToArray();

			var sharpPoints = new HashSet<PointD2D>();

			Point prevEndPoint;
			Vector prevEndVector;

			Vector startVector, endVector;
			Point endPoint;

			GetStartAndEndVector(figure.StartPoint, figure.Segments[0], out prevEndPoint, out startVector, out prevEndVector);
			for (int i = 1; i <= figure.Segments.Count; ++i)
			{
				if (i == figure.Segments.Count && prevEndPoint != figure.StartPoint) // if the end point of the very last segment is not the same than the start point of the figure
				{
					// Consider the straight line segment from the prevPoint to figure.StartPoint in the case that the startpoint and the endpoint of the figure are different
					startVector = endVector = figure.StartPoint - prevEndPoint;
					if (!IsSmoothJoint(startVector, prevEndVector))
						sharpPoints.Add(ToAltaxo(prevEndPoint, reverseY));
					prevEndVector = endVector;
					prevEndPoint = figure.StartPoint;
				}

				PathSegment seg = figure.Segments[i % figure.Segments.Count];
				GetStartAndEndVector(prevEndPoint, seg, out endPoint, out startVector, out endVector);

				if (!IsSmoothJoint(startVector, prevEndVector))
					sharpPoints.Add(ToAltaxo(prevEndPoint, reverseY));

				if (null != (polyLineSegment = (seg as PolyLineSegment)))
				{
					var preP = prevEndPoint;
					for (int j = 0; j < polyLineSegment.Points.Count - 1; ++j)
					{
						if (!IsSmoothJoint(polyLineSegment.Points[j] - preP, polyLineSegment.Points[j + 1] - polyLineSegment.Points[j]))
							sharpPoints.Add(ToAltaxo(polyLineSegment.Points[j], reverseY));
						preP = polyLineSegment.Points[j];
					}

					prevEndPoint = polyLineSegment.Points[polyLineSegment.Points.Count - 1];
				}
				if (null != (polyBezierSegment = (seg as PolyBezierSegment)))
				{
					for (int j = 2; j < polyBezierSegment.Points.Count - 1; j += 3)
						if (!IsSmoothJoint(polyBezierSegment.Points[j] - polyBezierSegment.Points[j - 1], polyBezierSegment.Points[j + 1] - polyBezierSegment.Points[j]))
							sharpPoints.Add(ToAltaxo(polyBezierSegment.Points[j], reverseY));
				}

				prevEndVector = endVector;
				prevEndPoint = endPoint;
			}

			return new PolygonClosedD2D(points, sharpPoints);
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:64,代码来源:PathGeometryHelper.cs


注:本文中的System.Windows.Media.PathFigure.GetFlattenedPathFigure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。