Ejemplo n.º 1
0
        public static Path BaseToForkLiePath(ShapesBase.BaseForkLiePath baseForkLiePath)
        {
            Path path = new Path();

            path.Stroke          = baseForkLiePath.Stroke;
            path.StrokeThickness = baseForkLiePath.StrokeThickness;
            path.Margin          = baseForkLiePath.Thickness;
            //定义圆弧半径
            double       radius       = baseForkLiePath.Radius;
            PathGeometry pathGeometry = new PathGeometry();
            PathFigure   figure       = new PathFigure();

            //路径图起点坐标
            figure.StartPoint = baseForkLiePath.FigureStartPoint;
            ArcSegment arc = new ArcSegment(
                baseForkLiePath.ArcStopPoint,
                new Size(radius, radius),
                0,
                false,
                baseForkLiePath.sweepDirection,
                true);

            figure.Segments.Add(arc);
            pathGeometry.Figures.Add(figure);
            path.Data = pathGeometry;
            return(path);
        }
Ejemplo n.º 2
0
        public static ShapesBase.BaseForkLiePath ForkLiePathToBase(Path path)
        {
            ShapesBase.BaseForkLiePath baseForkLiePath = new ShapesBase.BaseForkLiePath();
            baseForkLiePath.Stroke          = path.Stroke;
            baseForkLiePath.StrokeThickness = path.StrokeThickness;
            baseForkLiePath.Thickness       = path.Margin;

            //找到圆弧起点
            if (path.Data != null)
            {
                PathGeometry pathGeometry = path.Data as PathGeometry;
                PathFigure   figure       = pathGeometry.Figures.First();
                ArcSegment   arc          = figure.Segments.First() as ArcSegment;
                baseForkLiePath.ArcStopPoint     = arc.Point;
                baseForkLiePath.FigureStartPoint = figure.StartPoint;
                baseForkLiePath.Radius           = arc.Size.Width;
                baseForkLiePath.sweepDirection   = arc.SweepDirection;
            }
            return(baseForkLiePath);
        }