示例#1
0
        /// <summary>
        /// Convert a Nucleus arc into a WPF PathFigure
        /// </summary>
        /// <param name="arc"></param>
        /// <returns></returns>
        public static Media.PathFigure Convert(Arc arc)
        {
            Media.PathFigure result = new Media.PathFigure();
            result.StartPoint = Convert(arc.StartPoint);
            double radius = arc.Circle.Radius;

            if (arc.Closed)
            {
                //Circle!
                result.Segments.Add(new Media.ArcSegment(Convert(arc.PointAt(0.5)), new W.Size(radius, radius), 0, true,
                                                         Media.SweepDirection.Clockwise, true));
                result.Segments.Add(new Media.ArcSegment(Convert(arc.EndPoint), new W.Size(radius, radius), 0, false,
                                                         Media.SweepDirection.Clockwise, true));
            }
            else
            {
                bool largeArc            = arc.RadianMeasure.IsReflex;
                Media.SweepDirection dir = Media.SweepDirection.Clockwise;
                if (!arc.IsClockwise)
                {
                    dir = Media.SweepDirection.Counterclockwise;
                }
                result.Segments.Add(new Media.ArcSegment(Convert(arc.EndPoint), new W.Size(radius, radius), 0, largeArc, dir, true));
            }
            return(result);
        }
示例#2
0
 /// <summary>
 /// Convert a Nucleus PolyCurve into a WPF PathFigure
 /// </summary>
 /// <param name="polyCurve"></param>
 /// <returns></returns>
 public static Media.PathFigure Convert(PolyCurve polyCurve)
 {
     Media.PathFigure result = new Media.PathFigure();
     if (polyCurve.SubCurves.Count > 0)
     {
         result.StartPoint = Convert(polyCurve.StartPoint);
         foreach (Curve crv in polyCurve.SubCurves)
         {
             if (crv is Line)
             {
                 result.Segments.Add(new Media.LineSegment(Convert(crv.EndPoint), true));
             }
             else if (crv is Arc)
             {
                 Arc    arc    = ((Arc)crv);
                 double radius = arc.Circle.Radius;
                 if (arc.Closed)
                 {
                     //Circle!
                     result.Segments.Add(new Media.ArcSegment(Convert(arc.PointAt(0.5)), new W.Size(radius, radius), 0, true,
                                                              Media.SweepDirection.Clockwise, true));
                     result.Segments.Add(new Media.ArcSegment(Convert(arc.EndPoint), new W.Size(radius, radius), 0, false,
                                                              Media.SweepDirection.Clockwise, true));
                 }
                 else
                 {
                     bool largeArc            = arc.RadianMeasure.IsReflex;
                     Media.SweepDirection dir = Media.SweepDirection.Clockwise;
                     if (!arc.IsClockwise)
                     {
                         dir = Media.SweepDirection.Counterclockwise;
                     }
                     result.Segments.Add(new Media.ArcSegment(Convert(arc.EndPoint), new W.Size(radius, radius), 0, largeArc, dir, true));
                 }
             }
             else if (crv is PolyLine)
             {
                 for (int i = 1; i < crv.Vertices.Count; i++)
                 {
                     Vertex v = crv.Vertices[i];
                     result.Segments.Add(new Media.LineSegment(Convert(v.Position), true));
                 }
             }
         }
     }
     return(result);
 }
示例#3
0
        /// <summary>
        /// Rotate the label towards certain degree clockwise or anticlockwise
        /// </summary>
        /// <param name="degree">Angle in Radian</param>
        /// <param name="direction">SweepDirection</param>
        public Boolean RotateByVerticalOffset(Double verticalOffset, System.Windows.Media.SweepDirection direction)
        {
            Double offsetAngle = Math.Atan(verticalOffset / YRadiusLabel);

            if (direction == SweepDirection.Counterclockwise)
            {
                offsetAngle *= -1;
            }

            Double currentMeanAngle = CurrentMeanAngle + offsetAngle;

            currentMeanAngle = ResetMeanAngle(currentMeanAngle);
            Point tempPosition = GetCartesianCoordinates4Labels(currentMeanAngle);

            if (Math.Abs(BaseMeanAngle - ResetMeanAngle(CurrentMeanAngle + offsetAngle)) > Math.PI / 5)
            {
                return(false);
            }

            CurrentMeanAngle = currentMeanAngle;
            Position         = tempPosition;

            return(true);
        }
示例#4
0
        /// <summary>
        /// 得到圆弧的几何图形;
        /// </summary>
        /// <param name="center"></param>
        /// <param name="screenRadius"></param>
        /// <param name="beginAngle"></param>
        /// <param name="angle"></param>
        /// <param name="smallAngle"></param>
        /// <returns></returns>
        private static SystemMedia.PathGeometry GetArcGeometry(Point startScreenPoint, Point endScreenPoint, double screenRadius, bool smallAngle, SystemMedia.SweepDirection sweepDirection)
        {
            var arcSegment = new SystemMedia.ArcSegment(endScreenPoint, new System.Windows.Size(screenRadius, screenRadius), 0D, !smallAngle, sweepDirection, true);

            var segments   = new SystemMedia.PathSegment[] { arcSegment };
            var pathFigure = new SystemMedia.PathFigure(startScreenPoint, segments, false);

            var figures = new SystemMedia.PathFigure[] { pathFigure };

            arcSegment.Freeze();
            pathFigure.Freeze();

            return(new SystemMedia.PathGeometry(figures, SystemMedia.FillRule.EvenOdd, null));
        }