GraphicsPath.AddString Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Ajoute une chaîne de texte à ce tracé.
Surcharges
AddString(String, FontFamily, Int32, Single, Point, StringFormat) |
Ajoute une chaîne de texte à ce tracé. |
AddString(String, FontFamily, Int32, Single, PointF, StringFormat) |
Ajoute une chaîne de texte à ce tracé. |
AddString(String, FontFamily, Int32, Single, Rectangle, StringFormat) |
Ajoute une chaîne de texte à ce tracé. |
AddString(String, FontFamily, Int32, Single, RectangleF, StringFormat) |
Ajoute une chaîne de texte à ce tracé. |
AddString(String, FontFamily, Int32, Single, Point, StringFormat)
- Source:
- GraphicsPath.cs
- Source:
- GraphicsPath.cs
- Source:
- GraphicsPath.cs
Ajoute une chaîne de texte à ce tracé.
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)
Paramètres
- family
- FontFamily
FontFamily qui correspond au nom de la police utilisée pour dessiner le test.
- style
- Int32
Énumération FontStyle qui représente les informations sur le style du texte (gras, italique, etc.). Elle doit être castée en un entier (consultez l'exemple de code figurant plus loin dans cette rubrique).
- emSize
- Single
Hauteur du carré cadratin englobant le caractère.
- format
- StringFormat
StringFormat qui spécifie des informations sur la mise en forme du texte telles que l'espacement des lignes et l'alignement.
Exemples
L’exemple de code suivant est conçu pour être utilisé avec Windows Forms et nécessite PaintEventArgse
, un objet d’événementOnPaint. Le code effectue les actions suivantes :
Crée un chemin d’accès.
Configure des arguments de chaîne et de police.
Ajoute la chaîne au chemin d’accès.
Dessine la chaîne vers l’écran.
Il y a deux points importants à souligner. Tout d’abord, notez que l’argument fontStyle
est casté sous forme d’entier. La AddString méthode l’exige afin que deux ou plusieurs FontStyle membres puissent être combinés pour créer le style de police souhaité (dans ce cas, Italic et Underline). Ensuite, notez que la FillPath méthode est utilisée plutôt que la DrawPath méthode . Si FillPath est utilisé, le texte plein est rendu, tandis que s’il DrawPath est utilisé, le texte sera un style de plan.
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
S’applique à
AddString(String, FontFamily, Int32, Single, PointF, StringFormat)
- Source:
- GraphicsPath.cs
- Source:
- GraphicsPath.cs
- Source:
- GraphicsPath.cs
Ajoute une chaîne de texte à ce tracé.
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)
Paramètres
- family
- FontFamily
FontFamily qui correspond au nom de la police utilisée pour dessiner le test.
- style
- Int32
Énumération FontStyle qui représente les informations sur le style du texte (gras, italique, etc.). Elle doit être castée en un entier (consultez l'exemple de code figurant plus loin dans cette rubrique).
- emSize
- Single
Hauteur du carré cadratin englobant le caractère.
- format
- StringFormat
StringFormat qui spécifie des informations sur la mise en forme du texte telles que l'espacement des lignes et l'alignement.
Exemples
Pour obtenir un exemple, consultez AddString(String, FontFamily, Int32, Single, Point, StringFormat).
S’applique à
AddString(String, FontFamily, Int32, Single, Rectangle, StringFormat)
- Source:
- GraphicsPath.cs
- Source:
- GraphicsPath.cs
- Source:
- GraphicsPath.cs
Ajoute une chaîne de texte à ce tracé.
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)
Paramètres
- family
- FontFamily
FontFamily qui correspond au nom de la police utilisée pour dessiner le test.
- style
- Int32
Énumération FontStyle qui représente les informations sur le style du texte (gras, italique, etc.). Elle doit être castée en un entier (consultez l'exemple de code figurant plus loin dans cette rubrique).
- emSize
- Single
Hauteur du carré cadratin englobant le caractère.
- format
- StringFormat
StringFormat qui spécifie des informations sur la mise en forme du texte telles que l'espacement des lignes et l'alignement.
Exemples
Pour obtenir un exemple, consultez AddString(String, FontFamily, Int32, Single, Point, StringFormat).
S’applique à
AddString(String, FontFamily, Int32, Single, RectangleF, StringFormat)
- Source:
- GraphicsPath.cs
- Source:
- GraphicsPath.cs
- Source:
- GraphicsPath.cs
Ajoute une chaîne de texte à ce tracé.
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)
Paramètres
- family
- FontFamily
FontFamily qui correspond au nom de la police utilisée pour dessiner le test.
- style
- Int32
Énumération FontStyle qui représente les informations sur le style du texte (gras, italique, etc.). Elle doit être castée en un entier (consultez l'exemple de code figurant plus loin dans cette rubrique).
- emSize
- Single
Hauteur du carré cadratin englobant le caractère.
- layoutRect
- RectangleF
RectangleF représentant le rectangle qui englobe le texte.
- format
- StringFormat
StringFormat qui spécifie des informations sur la mise en forme du texte telles que l'espacement des lignes et l'alignement.
Exemples
Pour obtenir un exemple, consultez AddString(String, FontFamily, Int32, Single, Point, StringFormat).
S’applique à
Commentaires
https://aka.ms/ContentUserFeedback.
Bientôt disponible : Tout au long de 2024, nous allons supprimer progressivement GitHub Issues comme mécanisme de commentaires pour le contenu et le remplacer par un nouveau système de commentaires. Pour plus d’informations, consultezEnvoyer et afficher des commentaires pour