GraphicsPath.AddString Methode

Definition

Fügt diesem Pfad eine Textzeichenfolge hinzu.

Überlädt

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

Fügt diesem Pfad eine Textzeichenfolge hinzu.

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

Fügt diesem Pfad eine Textzeichenfolge hinzu.

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

Fügt diesem Pfad eine Textzeichenfolge hinzu.

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

Fügt diesem Pfad eine Textzeichenfolge hinzu.

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

Quelle:
GraphicsPath.cs
Quelle:
GraphicsPath.cs
Quelle:
GraphicsPath.cs

Fügt diesem Pfad eine Textzeichenfolge hinzu.

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)

Parameter

s
String

Das hinzuzufügende String.

family
FontFamily

Eine FontFamily, die den Namen der Schriftart darstellt, in der der Test gezeichnet wird.

style
Int32

Eine FontStyle-Enumeration, die Textformatierungsinformationen (fett, kursiv usw.) darstellt. Diese muss in eine ganze Zahl umgewandelt werden (siehe den Beispielcode weiter unten in diesem Abschnitt).

emSize
Single

Die Höhe des Geviertkästchens, das das Zeichen umschließt.

origin
Point

Ein den Anfangspunkt des Texts darstellender Point.

format
StringFormat

Ein StringFormat, das Textformatierungsinformationen angibt, z. B. Zeilenabstand und Ausrichtung.

Beispiele

Das folgende Codebeispiel ist für die Verwendung mit Windows Forms konzipiert und erfordert PaintEventArgseein OnPaint Ereignisobjekt. Der Code führt die folgenden Aktionen aus:

  • Erstellt einen Pfad.

  • Richtet Zeichenfolgen- und Schriftartargumente ein.

  • Fügt die Zeichenfolge dem Pfad hinzu.

  • Zeichnet die Zeichenfolge auf den Bildschirm.

Es gibt zwei wichtige Punkte, auf die hingewiesen werden muss. Beachten Sie zunächst, dass das fontStyle Argument als ganze Zahl umgewandelt wird. Die AddString -Methode erfordert dies, damit zwei oder mehr FontStyle Member kombiniert werden können, Italic um die gewünschte Schriftart zu erstellen (in diesem Fall und Underline). Beachten Sie zweitens, dass die FillPath -Methode anstelle der DrawPath -Methode verwendet wird. Wenn FillPath verwendet wird, wird Volltext gerendert, während der Text bei DrawPath Verwendung ein Gliederungsformat ist.

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

Gilt für:

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

Quelle:
GraphicsPath.cs
Quelle:
GraphicsPath.cs
Quelle:
GraphicsPath.cs

Fügt diesem Pfad eine Textzeichenfolge hinzu.

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)

Parameter

s
String

Das hinzuzufügende String.

family
FontFamily

Eine FontFamily, die den Namen der Schriftart darstellt, in der der Test gezeichnet wird.

style
Int32

Eine FontStyle-Enumeration, die Textformatierungsinformationen (fett, kursiv usw.) darstellt. Diese muss in eine ganze Zahl umgewandelt werden (siehe den Beispielcode weiter unten in diesem Abschnitt).

emSize
Single

Die Höhe des Geviertkästchens, das das Zeichen umschließt.

origin
PointF

Ein den Anfangspunkt des Texts darstellender PointF.

format
StringFormat

Ein StringFormat, das Textformatierungsinformationen angibt, z. B. Zeilenabstand und Ausrichtung.

Beispiele

Ein Beispiel finden Sie unter AddString(String, FontFamily, Int32, Single, Point, StringFormat).

Gilt für:

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

Quelle:
GraphicsPath.cs
Quelle:
GraphicsPath.cs
Quelle:
GraphicsPath.cs

Fügt diesem Pfad eine Textzeichenfolge hinzu.

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)

Parameter

s
String

Das hinzuzufügende String.

family
FontFamily

Eine FontFamily, die den Namen der Schriftart darstellt, in der der Test gezeichnet wird.

style
Int32

Eine FontStyle-Enumeration, die Textformatierungsinformationen (fett, kursiv usw.) darstellt. Diese muss in eine ganze Zahl umgewandelt werden (siehe den Beispielcode weiter unten in diesem Abschnitt).

emSize
Single

Die Höhe des Geviertkästchens, das das Zeichen umschließt.

layoutRect
Rectangle

Ein Rectangle, das das den Text umschließende Rechteck darstellt.

format
StringFormat

Ein StringFormat, das Textformatierungsinformationen angibt, z. B. Zeilenabstand und Ausrichtung.

Beispiele

Ein Beispiel finden Sie unter AddString(String, FontFamily, Int32, Single, Point, StringFormat).

Gilt für:

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

Quelle:
GraphicsPath.cs
Quelle:
GraphicsPath.cs
Quelle:
GraphicsPath.cs

Fügt diesem Pfad eine Textzeichenfolge hinzu.

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)

Parameter

s
String

Das hinzuzufügende String.

family
FontFamily

Eine FontFamily, die den Namen der Schriftart darstellt, in der der Test gezeichnet wird.

style
Int32

Eine FontStyle-Enumeration, die Textformatierungsinformationen (fett, kursiv usw.) darstellt. Diese muss in eine ganze Zahl umgewandelt werden (siehe den Beispielcode weiter unten in diesem Abschnitt).

emSize
Single

Die Höhe des Geviertkästchens, das das Zeichen umschließt.

layoutRect
RectangleF

Ein RectangleF, das das den Text umschließende Rechteck darstellt.

format
StringFormat

Ein StringFormat, das Textformatierungsinformationen angibt, z. B. Zeilenabstand und Ausrichtung.

Beispiele

Ein Beispiel finden Sie unter AddString(String, FontFamily, Int32, Single, Point, StringFormat).

Gilt für: