Graphics.DrawPath(Pen, GraphicsPath) 方法

定義

繪製 GraphicsPath

public void DrawPath(System.Drawing.Pen pen, System.Drawing.Drawing2D.GraphicsPath path);

參數

pen
Pen

Pen,決定路徑的色彩、寬度和樣式。

path
GraphicsPath

要繪製的 GraphicsPath

例外狀況

pen null

-或-

path null

範例

下列程式代碼範例是專為搭配 Windows Forms 使用而設計,而且需要 PaintEventArgse,這是 Paint 事件處理程式的參數。 程式代碼會執行下列動作:

  • 建立圖形路徑物件,並將省略號加入其中。

  • 建立黑色畫筆。

  • 繪製畫面的圖形路徑。

public void DrawPathEllipse(PaintEventArgs e)
{
             
    // Create graphics path object and add ellipse.
    GraphicsPath graphPath = new GraphicsPath();
    graphPath.AddEllipse(0, 0, 200, 100);
             
    // Create pen.
    Pen blackPen = new Pen(Color.Black, 3);
             
    // Draw graphics path to screen.
    e.Graphics.DrawPath(blackPen, graphPath);
}

備註

在繪製圖形內容之前,圖形內容中的目前轉換會套用至 GraphicsPath

適用於

產品 版本
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10