Пример #1
0
        private static PathGeometry ArcBlock(Arc arc, double fromAngle, double toAngle, double tickLength)
        {
            PathGeometry geometry = new PathGeometry();
            PathFigure figure = new PathFigure();

            geometry.Figures.Add(figure);
            var op1 = arc.GetPoint(fromAngle);
            var ip1 = arc.GetPoint(fromAngle, -1 * tickLength);
            var op2 = arc.GetPoint(toAngle);
            var ip2 = arc.GetPoint(toAngle, -1 * tickLength);

            figure.StartPoint = op1;
            var rotationAngle = toAngle - fromAngle;
            var isLargeArc = arc.IsLargeAngle(fromAngle, toAngle);
            var sweepDirection = arc.SweepDirection(fromAngle, toAngle);
            figure.Segments.Add(new ArcSegment(op2, new Size(arc.Radius, arc.Radius), rotationAngle, isLargeArc, sweepDirection, true));
            figure.Segments.Add(new LineSegment(ip2, true));
            sweepDirection = arc.SweepDirection(toAngle, fromAngle);
            var ri = arc.Radius - tickLength;
            if (ri < 0)
            {
                ri = 0;
            }
            figure.Segments.Add(new ArcSegment(ip1, new Size(ri, ri), rotationAngle, isLargeArc, sweepDirection, true));
            figure.Segments.Add(new LineSegment(op1, true));
            figure.IsClosed = true;
            figure.Freeze();
            geometry.Freeze();
            return geometry;
        }