0

挑战是我必须在运行时为 windows phone 7 制作一个画布对象。然后在其上添加一个弧,一个起点和一个终点。我试过这段代码

    PathGeometry pathGeometry = new PathGeometry();
    PathFigure figure = new PathFigure();
    figure.StartPoint = new Point(150, 200);
    figure.Segments.Add(
    new ArcSegment(
    new Point(300, 200),
    new Size(700, 100),
    90,
    false,
    SweepDirection.Clockwise,
    true
    )
    );
    pathGeometry.Figures.Add(figure);
    Path path = new Path();
    path.Data = pathGeometry;
    path.Fill = Brushes.Pink;
    path.Stroke = Brushes.Green;

现在我必须在画布上添加这个弧,但它不需要参数。有没有其他方法可以做到这一点。我被它困住了。

4

1 回答 1

1

好吧,我猜 Arc 是指这种类型的图形,在此处输入图像描述

为了绘制这条弧线,我使用了这段代码,它对我来说很好用,也和你的代码很相似,希望它对你有帮助..

 PathFigure pthFigure1 = new PathFigure();
    pthFigure1.StartPoint = new Point(50, 60);// starting cordinates of arcs
    ArcSegment arcSeg1 = new ArcSegment();
    arcSeg1.Point = new Point(100, 82);   // ending cordinates of arcs
    arcSeg1.Size = new Size(10, 10);

    arcSeg1.IsLargeArc = false;
    arcSeg1.SweepDirection = SweepDirection.Clockwise;
    arcSeg1.RotationAngle = 90;
    PathSegmentCollection myPathSegmentCollection1 = new PathSegmentCollection();
    myPathSegmentCollection1.Add(arcSeg1);
    pthFigure1.Segments = myPathSegmentCollection1;
    PathFigureCollection pthFigureCollection1 = new PathFigureCollection();
    pthFigureCollection1.Add(pthFigure1);
    PathGeometry pthGeometry1 = new PathGeometry();
    pthGeometry1.Figures = pthFigureCollection1;
    System.Windows.Shapes.Path arcPath1 = new System.Windows.Shapes.Path();
    arcPath1.Data = pthGeometry1;
    arcPath1.Fill = new SolidColorBrush(Color.FromArgb(255, 255, 23, 0));
    this.LayoutRoot.Children.Add(arcPath1);
于 2014-01-27T08:04:38.470 回答