GraphicsPathIterator.HasCurve 方法    
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
指示与此 GraphicsPathIterator 关联的路径是否包含曲线。
public:
 bool HasCurve();public bool HasCurve();member this.HasCurve : unit -> boolPublic Function HasCurve () As Boolean返回
如果当前子路径包含曲线,此方法将返回 true;否则,false。
示例
以下示例旨在与 Windows 窗体一起使用,它需要 PaintEventArgseOnPaint 事件对象。 该代码执行以下操作:
- 创建 GraphicsPath 对象, - myPath。
- 添加三行、一个矩形和椭圆。 
- 为 - myPath创建 GraphicsPathIterator 对象。
- 测试以查看当前路径 - myPath是否包含曲线。
- 在消息框中显示测试结果。 
private:
   void HasCurveExample( PaintEventArgs^ /*e*/ )
   {
      // Create a path and add three lines,
      // a rectangle and an ellipse.
      GraphicsPath^ myPath = gcnew GraphicsPath;
      array<Point>^ myPoints = {Point(20,20),Point(120,120),Point(20,120),Point(20,20)};
      Rectangle myRect = Rectangle(120,120,100,100);
      myPath->AddLines( myPoints );
      myPath->AddRectangle( myRect );
      myPath->AddEllipse( 220, 220, 100, 100 );
      // Create a GraphicsPathIterator for myPath.
      GraphicsPathIterator^ myPathIterator = gcnew GraphicsPathIterator( myPath );
      // Test for a curve.
      bool myHasCurve = myPathIterator->HasCurve();
      // Show the test result.
      MessageBox::Show( myHasCurve.ToString() );
   }
private void HasCurveExample(PaintEventArgs e)
{
             
    // Create a path and add three lines,
    // a rectangle and an ellipse.
    GraphicsPath myPath = new GraphicsPath();
    
    Point[] myPoints = {new Point(20, 20), new Point(120, 120), 
        new Point(20, 120),new Point(20, 20) }; 
    Rectangle myRect = new Rectangle(120, 120, 100, 100);
    myPath.AddLines(myPoints);
    myPath.AddRectangle(myRect);
    myPath.AddEllipse(220, 220, 100, 100);
             
    // Create a GraphicsPathIterator for myPath.
    GraphicsPathIterator myPathIterator = new
        GraphicsPathIterator(myPath);
             
    // Test for a curve.
    bool myHasCurve = myPathIterator.HasCurve();
             
    // Show the test result.
    MessageBox.Show(myHasCurve.ToString());
}
Public Sub HasCurveExample(ByVal e As PaintEventArgs)
    Dim myPath As New GraphicsPath
    Dim myPoints As Point() = {New Point(20, 20), _
        New Point(120, 120), New Point(20, 120), New Point(20, 20)}
    Dim myRect As New Rectangle(120, 120, 100, 100)
    myPath.AddLines(myPoints)
    myPath.AddRectangle(myRect)
    myPath.AddEllipse(220, 220, 100, 100)
    ' Create a GraphicsPathIterator for myPath.
    Dim myPathIterator As New GraphicsPathIterator(myPath)
    Dim myHasCurve As Boolean = myPathIterator.HasCurve()
    MessageBox.Show(myHasCurve.ToString())
End Sub
注解
路径中的所有曲线都存储为贝塞尔样条序列。 例如,向路径添加椭圆时,可以指定椭圆的边框的左上角、宽度和高度。 这些数字(左上角、宽度和高度)不存储在路径中:相反;椭圆转换为四个贝塞尔样条序列。 路径存储这些 Bézier 样条的终结点和控制点。
路径存储一个数据点数组,每个数据点都属于线条或 Bézier 样条。 如果数组中的某些点属于贝塞尔样条,则 HasCurve 返回 true。 如果数组中的所有点都属于行,则 HasCurve 返回 false。
某些方法平展路径,这意味着路径中的所有曲线都转换为线条序列。 平展路径后,HasCurve 将始终返回 false。 调用 GraphicsPath 类的 Flatten、Widen或 Warp 方法将平展路径。