GraphicsPathIterator.HasCurve 方法

定義

指示與這個 GraphicsPathIterator 關聯的路徑是否含有曲線。

public:
 bool HasCurve();
public bool HasCurve ();
member this.HasCurve : unit -> bool
Public Function HasCurve () As Boolean

傳回

如果目前的子路徑含有曲線,則這個方法會傳回 true,否則傳回 false

範例

下列範例是設計來搭配 Windows Forms 使用,而且需要 PaintEventArgse事件OnPaint物件。 此程式碼會執行下列動作:

  • 建立 GraphicsPath 物件 myPath

  • 加入三行、矩形和橢圓形。

  • 建立 GraphicsPathIteratormyPath物件。

  • 測試以查看目前路徑 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 曲線的序列。 路徑會儲存這些 Bézier 曲線的端點和控制點。

路徑會儲存數據點陣列,每個數據點都屬於線條或 Bézier 曲線。 如果陣列中的某些點屬於 Bézier 曲線,則會 HasCurvetrue回 。 如果陣列的所有點都屬於行,則會 HasCurvefalse回 。

某些方法會將路徑扁平化,這表示路徑中的所有曲線都會轉換成線條序列。 壓平合併路徑之後, HasCurve 一律會傳回 falseFlatten呼叫 類別的 GraphicsPathWidenWarp 方法會扁平化路徑。

適用於