GraphicsPath.AddString Método

Definição

Adiciona uma cadeia de texto nesse caminho.

Sobrecargas

AddString(String, FontFamily, Int32, Single, Point, StringFormat)

Adiciona uma cadeia de texto nesse caminho.

AddString(String, FontFamily, Int32, Single, PointF, StringFormat)

Adiciona uma cadeia de texto nesse caminho.

AddString(String, FontFamily, Int32, Single, Rectangle, StringFormat)

Adiciona uma cadeia de texto nesse caminho.

AddString(String, FontFamily, Int32, Single, RectangleF, StringFormat)

Adiciona uma cadeia de texto nesse caminho.

AddString(String, FontFamily, Int32, Single, Point, StringFormat)

Origem:
GraphicsPath.cs
Origem:
GraphicsPath.cs
Origem:
GraphicsPath.cs

Adiciona uma cadeia de texto nesse caminho.

public:
 void AddString(System::String ^ s, System::Drawing::FontFamily ^ family, int style, float emSize, System::Drawing::Point origin, System::Drawing::StringFormat ^ format);
public void AddString (string s, System.Drawing.FontFamily family, int style, float emSize, System.Drawing.Point origin, System.Drawing.StringFormat format);
public void AddString (string s, System.Drawing.FontFamily family, int style, float emSize, System.Drawing.Point origin, System.Drawing.StringFormat? format);
member this.AddString : string * System.Drawing.FontFamily * int * single * System.Drawing.Point * System.Drawing.StringFormat -> unit
Public Sub AddString (s As String, family As FontFamily, style As Integer, emSize As Single, origin As Point, format As StringFormat)

Parâmetros

s
String

O String a ser adicionado.

family
FontFamily

Uma FontFamily que representa o nome da fonte com a qual o teste é desenhado.

style
Int32

Um enumeração FontStyle que representa as informações de estilo sobre o texto (negrito, itálico e assim por diante). Isso deve ser transmitido como um inteiro (consulte o código de exemplo mais à frente nesta seção).

emSize
Single

A altura da caixa quadrada em que delimita o caractere.

origin
Point

Um Point que representa o ponto em que o texto começa.

format
StringFormat

Um StringFormat que especifica as informações de formatação de texto, como o espaçamento entre linhas e o alinhamento.

Exemplos

O exemplo de código a seguir foi projetado para uso com Windows Forms e requer PaintEventArgse, um OnPaint objeto de evento. O código executa as seguintes ações:

  • Cria um caminho.

  • Configura argumentos de cadeia de caracteres e fonte.

  • Adiciona a cadeia de caracteres ao caminho.

  • Desenha a cadeia de caracteres para a tela.

Há duas coisas importantes a serem apontadas. Primeiro, observe que o fontStyle argumento é convertido como um inteiro. O AddString método requer isso para que dois ou mais FontStyle membros possam ser combinados para criar o estilo de fonte desejado (nesse caso, Italic e Underline). Em segundo lugar, observe que o FillPath método é usado em vez do DrawPath método . Se FillPath for usado, o texto sólido será renderizado, enquanto se DrawPath for usado, o texto será um estilo de estrutura de tópicos.

private:
   void AddStringExample( PaintEventArgs^ e )
   {
      // Create a GraphicsPath object.
      GraphicsPath^ myPath = gcnew GraphicsPath;

      // Set up all the string parameters.
      String^ stringText = "Sample Text";
      FontFamily^ family = gcnew FontFamily( "Arial" );
      int fontStyle = (int)FontStyle::Italic;
      int emSize = 26;
      Point origin = Point(20,20);
      StringFormat^ format = StringFormat::GenericDefault;

      // Add the string to the path.
      myPath->AddString( stringText, family, fontStyle, (float)emSize, origin, format );

      //Draw the path to the screen.
      e->Graphics->FillPath( Brushes::Black, myPath );
   }
private void AddStringExample(PaintEventArgs e)
{
             
    // Create a GraphicsPath object.
    GraphicsPath myPath = new GraphicsPath();
             
    // Set up all the string parameters.
    string stringText = "Sample Text";
    FontFamily family = new FontFamily("Arial");
    int fontStyle = (int)FontStyle.Italic;
    int emSize = 26;
    Point origin = new Point(20, 20);
    StringFormat format = StringFormat.GenericDefault;
             
    // Add the string to the path.
    myPath.AddString(stringText,
        family,
        fontStyle,
        emSize,
        origin,
        format);
             
    //Draw the path to the screen.
    e.Graphics.FillPath(Brushes.Black, myPath);
}
Public Sub AddStringExample(ByVal e As PaintEventArgs)

    ' Create a GraphicsPath object.
    Dim myPath As New GraphicsPath

    ' Set up all the string parameters.
    Dim stringText As String = "Sample Text"
    Dim family As New FontFamily("Arial")
    Dim myfontStyle As Integer = CInt(FontStyle.Italic)
    Dim emSize As Integer = 26
    Dim origin As New Point(20, 20)
    Dim format As StringFormat = StringFormat.GenericDefault

    ' Add the string to the path.
    myPath.AddString(stringText, family, myfontStyle, emSize, _
    origin, format)

    'Draw the path to the screen.
    e.Graphics.FillPath(Brushes.Black, myPath)
End Sub

Aplica-se a

AddString(String, FontFamily, Int32, Single, PointF, StringFormat)

Origem:
GraphicsPath.cs
Origem:
GraphicsPath.cs
Origem:
GraphicsPath.cs

Adiciona uma cadeia de texto nesse caminho.

public:
 void AddString(System::String ^ s, System::Drawing::FontFamily ^ family, int style, float emSize, System::Drawing::PointF origin, System::Drawing::StringFormat ^ format);
public void AddString (string s, System.Drawing.FontFamily family, int style, float emSize, System.Drawing.PointF origin, System.Drawing.StringFormat format);
public void AddString (string s, System.Drawing.FontFamily family, int style, float emSize, System.Drawing.PointF origin, System.Drawing.StringFormat? format);
member this.AddString : string * System.Drawing.FontFamily * int * single * System.Drawing.PointF * System.Drawing.StringFormat -> unit
Public Sub AddString (s As String, family As FontFamily, style As Integer, emSize As Single, origin As PointF, format As StringFormat)

Parâmetros

s
String

O String a ser adicionado.

family
FontFamily

Uma FontFamily que representa o nome da fonte com a qual o teste é desenhado.

style
Int32

Um enumeração FontStyle que representa as informações de estilo sobre o texto (negrito, itálico e assim por diante). Isso deve ser transmitido como um inteiro (consulte o código de exemplo mais à frente nesta seção).

emSize
Single

A altura da caixa quadrada em que delimita o caractere.

origin
PointF

Um PointF que representa o ponto em que o texto começa.

format
StringFormat

Um StringFormat que especifica as informações de formatação de texto, como o espaçamento entre linhas e o alinhamento.

Exemplos

Para ver um exemplo, consulte AddString(String, FontFamily, Int32, Single, Point, StringFormat).

Aplica-se a

AddString(String, FontFamily, Int32, Single, Rectangle, StringFormat)

Origem:
GraphicsPath.cs
Origem:
GraphicsPath.cs
Origem:
GraphicsPath.cs

Adiciona uma cadeia de texto nesse caminho.

public:
 void AddString(System::String ^ s, System::Drawing::FontFamily ^ family, int style, float emSize, System::Drawing::Rectangle layoutRect, System::Drawing::StringFormat ^ format);
public void AddString (string s, System.Drawing.FontFamily family, int style, float emSize, System.Drawing.Rectangle layoutRect, System.Drawing.StringFormat format);
public void AddString (string s, System.Drawing.FontFamily family, int style, float emSize, System.Drawing.Rectangle layoutRect, System.Drawing.StringFormat? format);
member this.AddString : string * System.Drawing.FontFamily * int * single * System.Drawing.Rectangle * System.Drawing.StringFormat -> unit
Public Sub AddString (s As String, family As FontFamily, style As Integer, emSize As Single, layoutRect As Rectangle, format As StringFormat)

Parâmetros

s
String

O String a ser adicionado.

family
FontFamily

Uma FontFamily que representa o nome da fonte com a qual o teste é desenhado.

style
Int32

Um enumeração FontStyle que representa as informações de estilo sobre o texto (negrito, itálico e assim por diante). Isso deve ser transmitido como um inteiro (consulte o código de exemplo mais à frente nesta seção).

emSize
Single

A altura da caixa quadrada em que delimita o caractere.

layoutRect
Rectangle

Um Rectangle que representa o retângulo que limita o texto.

format
StringFormat

Um StringFormat que especifica as informações de formatação de texto, como o espaçamento entre linhas e o alinhamento.

Exemplos

Para ver um exemplo, consulte AddString(String, FontFamily, Int32, Single, Point, StringFormat).

Aplica-se a

AddString(String, FontFamily, Int32, Single, RectangleF, StringFormat)

Origem:
GraphicsPath.cs
Origem:
GraphicsPath.cs
Origem:
GraphicsPath.cs

Adiciona uma cadeia de texto nesse caminho.

public:
 void AddString(System::String ^ s, System::Drawing::FontFamily ^ family, int style, float emSize, System::Drawing::RectangleF layoutRect, System::Drawing::StringFormat ^ format);
public void AddString (string s, System.Drawing.FontFamily family, int style, float emSize, System.Drawing.RectangleF layoutRect, System.Drawing.StringFormat format);
public void AddString (string s, System.Drawing.FontFamily family, int style, float emSize, System.Drawing.RectangleF layoutRect, System.Drawing.StringFormat? format);
member this.AddString : string * System.Drawing.FontFamily * int * single * System.Drawing.RectangleF * System.Drawing.StringFormat -> unit
Public Sub AddString (s As String, family As FontFamily, style As Integer, emSize As Single, layoutRect As RectangleF, format As StringFormat)

Parâmetros

s
String

O String a ser adicionado.

family
FontFamily

Uma FontFamily que representa o nome da fonte com a qual o teste é desenhado.

style
Int32

Um enumeração FontStyle que representa as informações de estilo sobre o texto (negrito, itálico e assim por diante). Isso deve ser transmitido como um inteiro (consulte o código de exemplo mais à frente nesta seção).

emSize
Single

A altura da caixa quadrada em que delimita o caractere.

layoutRect
RectangleF

Um RectangleF que representa o retângulo que limita o texto.

format
StringFormat

Um StringFormat que especifica as informações de formatação de texto, como o espaçamento entre linhas e o alinhamento.

Exemplos

Para ver um exemplo, consulte AddString(String, FontFamily, Int32, Single, Point, StringFormat).

Aplica-se a