none
WPF 画图 RRS feed

答案

  • DrawingContextDrawGeometry方法,然后将你要的扇形Path通过方法绘制出来,例如:

          PathFigure pathFigure = new PathFigure { IsClosed = true };
    
          pathFigure.StartPoint = new Point(100, 100);
    
          pathFigure.Segments.Add(
              new ArcSegment
              {
                Point = new Point(300, 300),
                IsLargeArc = false,
                Size = new Size(200, 200),
                SweepDirection = SweepDirection.Clockwise
              });
    
          pathFigure.Segments.Add(new LineSegment { Point = new Point(200, 300) });
    
          pathFigure.Segments.Add(
              new ArcSegment
              {
                Point = new Point(100, 200),
                IsLargeArc = false,
                Size = new Size(100, 100),
                SweepDirection = SweepDirection.Counterclockwise
              });
    
          PathGeometry pathGeometry = new PathGeometry();
          pathGeometry.Figures.Add(pathFigure);
          drawingContext.DrawGeometry(Brushes.Red, new Pen(Brushes.Black, 2), pathGeometry);

    效果:


    Bob Bao [MSFT]
    MSDN Community Support | Feedback to us

    2012年4月30日 4:06
    版主

全部回复

  • DrawingContextDrawGeometry方法,然后将你要的扇形Path通过方法绘制出来,例如:

          PathFigure pathFigure = new PathFigure { IsClosed = true };
    
          pathFigure.StartPoint = new Point(100, 100);
    
          pathFigure.Segments.Add(
              new ArcSegment
              {
                Point = new Point(300, 300),
                IsLargeArc = false,
                Size = new Size(200, 200),
                SweepDirection = SweepDirection.Clockwise
              });
    
          pathFigure.Segments.Add(new LineSegment { Point = new Point(200, 300) });
    
          pathFigure.Segments.Add(
              new ArcSegment
              {
                Point = new Point(100, 200),
                IsLargeArc = false,
                Size = new Size(100, 100),
                SweepDirection = SweepDirection.Counterclockwise
              });
    
          PathGeometry pathGeometry = new PathGeometry();
          pathGeometry.Figures.Add(pathFigure);
          drawingContext.DrawGeometry(Brushes.Red, new Pen(Brushes.Black, 2), pathGeometry);

    效果:


    Bob Bao [MSFT]
    MSDN Community Support | Feedback to us

    2012年4月30日 4:06
    版主
  • DrawingContext是重写的传进来的吗,为什么我用相同的方法画不出来啊?
    2012年5月22日 5:43
  • UserControl 中 重载OnRender方法

    Bob Bao [MSFT]
    MSDN Community Support | Feedback to us

    2012年5月22日 5:52
    版主