Graphics.DrawPath(Pen, GraphicsPath) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
繪製 GraphicsPath。
public:
void DrawPath(System::Drawing::Pen ^ pen, System::Drawing::Drawing2D::GraphicsPath ^ path);
public void DrawPath(System.Drawing.Pen pen, System.Drawing.Drawing2D.GraphicsPath path);
member this.DrawPath : System.Drawing.Pen * System.Drawing.Drawing2D.GraphicsPath -> unit
Public Sub DrawPath (pen As Pen, path As GraphicsPath)
- path
- GraphicsPath
要繪製的 GraphicsPath。
下列程式代碼範例是專為搭配 Windows Forms 使用而設計,而且需要 PaintEventArgse
,這是 Paint 事件處理程式的參數。 程式代碼會執行下列動作:
建立圖形路徑物件,並將省略號加入其中。
建立黑色畫筆。
繪製畫面的圖形路徑。
public:
void DrawPathEllipse( PaintEventArgs^ e )
{
// Create graphics path object and add ellipse.
GraphicsPath^ graphPath = gcnew GraphicsPath;
graphPath->AddEllipse( 0, 0, 200, 100 );
// Create pen.
Pen^ blackPen = gcnew Pen( Color::Black,3.0f );
// Draw graphics path to screen.
e->Graphics->DrawPath( blackPen, graphPath );
}
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);
}
Public Sub DrawPathEllipse(ByVal e As PaintEventArgs)
' Create graphics path object and add ellipse.
Dim graphPath As New GraphicsPath
graphPath.AddEllipse(0, 0, 200, 100)
' Create pen.
Dim blackPen As New Pen(Color.Black, 3)
' Draw graphics path to screen.
e.Graphics.DrawPath(blackPen, graphPath)
End Sub
在繪製圖形內容之前,圖形內容中的目前轉換會套用至 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 |