Graphics.DrawPath(Pen, GraphicsPath) Метод

Определение

Рисует объект 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)

Параметры

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 = 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 перед его рисованием.

Применяется к