Share via


GraphicsPath.AddString Metodo

Definizione

Aggiunge una stringa di testo a questo percorso.

Overload

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

Aggiunge una stringa di testo a questo percorso.

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

Aggiunge una stringa di testo a questo percorso.

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

Aggiunge una stringa di testo a questo percorso.

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

Aggiunge una stringa di testo a questo percorso.

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

Origine:
GraphicsPath.cs
Origine:
GraphicsPath.cs
Origine:
GraphicsPath.cs

Aggiunge una stringa di testo a questo percorso.

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)

Parametri

s
String

Oggetto String da aggiungere.

family
FontFamily

Classe FontFamily che rappresenta il nome del tipo di carattere con il quale viene disegnato il testo.

style
Int32

Enumerazione FontStyle che rappresenta le informazioni relative allo stile del testo, ad esempio grassetto, corsivo e così via, e di cui deve essere eseguito il cast come intero (vedere il codice di esempio più avanti in questa sezione).

emSize
Single

Altezza della casella quadrata em che delimita il carattere.

origin
Point

Struttura Point che rappresenta il punto in cui inizia il testo.

format
StringFormat

Classe StringFormat che specifica le informazioni relative alla formattazione del testo, come spaziatura e allineamento.

Esempio

L'esempio di codice seguente è progettato per l'uso con Windows Forms e richiede PaintEventArgse, un OnPaint oggetto evento. Il codice esegue le azioni seguenti:

  • Crea un percorso.

  • Imposta gli argomenti stringa e tipo di carattere.

  • Aggiunge la stringa al percorso.

  • Disegna la stringa sullo schermo.

Ci sono due aspetti importanti da sottolineare. In primo luogo, si noti che l'argomento viene eseguito il fontStyle cast come numero intero. Il AddString metodo richiede questa operazione in modo che due o più FontStyle membri possano essere combinati per creare lo stile del carattere desiderato (in questo caso Italic e Underline). In secondo luogo, si noti che il FillPath metodo viene usato anziché il DrawPath metodo . Se FillPath viene utilizzato, viene eseguito il rendering del testo solido, mentre se DrawPath viene usato, il testo sarà uno stile di struttura.

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

Si applica a

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

Origine:
GraphicsPath.cs
Origine:
GraphicsPath.cs
Origine:
GraphicsPath.cs

Aggiunge una stringa di testo a questo percorso.

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)

Parametri

s
String

Oggetto String da aggiungere.

family
FontFamily

Classe FontFamily che rappresenta il nome del tipo di carattere con il quale viene disegnato il testo.

style
Int32

Enumerazione FontStyle che rappresenta le informazioni relative allo stile del testo, ad esempio grassetto, corsivo e così via, e di cui deve essere eseguito il cast come intero (vedere il codice di esempio più avanti in questa sezione).

emSize
Single

Altezza della casella quadrata em che delimita il carattere.

origin
PointF

Struttura PointF che rappresenta il punto in cui inizia il testo.

format
StringFormat

Classe StringFormat che specifica le informazioni relative alla formattazione del testo, come spaziatura e allineamento.

Esempio

Per un esempio, vedere AddString(String, FontFamily, Int32, Single, Point, StringFormat).

Si applica a

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

Origine:
GraphicsPath.cs
Origine:
GraphicsPath.cs
Origine:
GraphicsPath.cs

Aggiunge una stringa di testo a questo percorso.

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)

Parametri

s
String

Oggetto String da aggiungere.

family
FontFamily

Classe FontFamily che rappresenta il nome del tipo di carattere con il quale viene disegnato il testo.

style
Int32

Enumerazione FontStyle che rappresenta le informazioni relative allo stile del testo, ad esempio grassetto, corsivo e così via, e di cui deve essere eseguito il cast come intero (vedere il codice di esempio più avanti in questa sezione).

emSize
Single

Altezza della casella quadrata em che delimita il carattere.

layoutRect
Rectangle

Struttura Rectangle che rappresenta il rettangolo che delimita il testo.

format
StringFormat

Classe StringFormat che specifica le informazioni relative alla formattazione del testo, come spaziatura e allineamento.

Esempio

Per un esempio, vedere AddString(String, FontFamily, Int32, Single, Point, StringFormat).

Si applica a

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

Origine:
GraphicsPath.cs
Origine:
GraphicsPath.cs
Origine:
GraphicsPath.cs

Aggiunge una stringa di testo a questo percorso.

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)

Parametri

s
String

Oggetto String da aggiungere.

family
FontFamily

Classe FontFamily che rappresenta il nome del tipo di carattere con il quale viene disegnato il testo.

style
Int32

Enumerazione FontStyle che rappresenta le informazioni relative allo stile del testo, ad esempio grassetto, corsivo e così via, e di cui deve essere eseguito il cast come intero (vedere il codice di esempio più avanti in questa sezione).

emSize
Single

Altezza della casella quadrata em che delimita il carattere.

layoutRect
RectangleF

Struttura RectangleF che rappresenta il rettangolo che delimita il testo.

format
StringFormat

Classe StringFormat che specifica le informazioni relative alla formattazione del testo, come spaziatura e allineamento.

Esempio

Per un esempio, vedere AddString(String, FontFamily, Int32, Single, Point, StringFormat).

Si applica a