GraphicsPath.AddString Método
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Agrega una cadena de texto a este trazado.
Sobrecargas
AddString(String, FontFamily, Int32, Single, Point, StringFormat) |
Agrega una cadena de texto a este trazado. |
AddString(String, FontFamily, Int32, Single, PointF, StringFormat) |
Agrega una cadena de texto a este trazado. |
AddString(String, FontFamily, Int32, Single, Rectangle, StringFormat) |
Agrega una cadena de texto a este trazado. |
AddString(String, FontFamily, Int32, Single, RectangleF, StringFormat) |
Agrega una cadena de texto a este trazado. |
AddString(String, FontFamily, Int32, Single, Point, StringFormat)
- Source:
- GraphicsPath.cs
- Source:
- GraphicsPath.cs
- Source:
- GraphicsPath.cs
Agrega una cadena de texto a este trazado.
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
- family
- FontFamily
FontFamily que representa el nombre de la fuente con la que se dibuja la prueba.
- style
- Int32
Enumeración FontStyle que representa la información de estilo sobre el texto (negrita, cursiva, etc.). Se debe convertir en un entero (vea el ejemplo de código más adelante en esta sección).
- emSize
- Single
Alto del cuadrado Em que delimita el carácter.
- format
- StringFormat
StringFormat que especifica información sobre el formato de texto, como el interlineado y la alineación.
Ejemplos
El ejemplo de código siguiente está diseñado para su uso con Windows Forms y requiere PaintEventArgse
, un OnPaint objeto de evento. El código realiza las siguientes acciones:
Crea una ruta de acceso.
Configura argumentos de cadena y fuente.
Agrega la cadena a la ruta de acceso.
Dibuja la cadena en la pantalla.
Hay dos cosas importantes que se deben señalar. En primer lugar, observe que el fontStyle
argumento se convierte como un entero. El AddString método requiere esto para que se puedan combinar dos o más FontStyle miembros para crear el estilo de fuente deseado (en este caso, Italic y Underline). En segundo lugar, observe que el FillPath método se usa en lugar del DrawPath método . Si FillPath se usa, se representa texto sólido, mientras que si DrawPath se usa, el texto será un estilo de esquema.
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
Se aplica a
AddString(String, FontFamily, Int32, Single, PointF, StringFormat)
- Source:
- GraphicsPath.cs
- Source:
- GraphicsPath.cs
- Source:
- GraphicsPath.cs
Agrega una cadena de texto a este trazado.
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
- family
- FontFamily
FontFamily que representa el nombre de la fuente con la que se dibuja la prueba.
- style
- Int32
Enumeración FontStyle que representa la información de estilo sobre el texto (negrita, cursiva, etc.). Se debe convertir en un entero (vea el ejemplo de código más adelante en esta sección).
- emSize
- Single
Alto del cuadrado Em que delimita el carácter.
- format
- StringFormat
StringFormat que especifica información sobre el formato de texto, como el interlineado y la alineación.
Ejemplos
Para obtener un ejemplo, consulte AddString(String, FontFamily, Int32, Single, Point, StringFormat).
Se aplica a
AddString(String, FontFamily, Int32, Single, Rectangle, StringFormat)
- Source:
- GraphicsPath.cs
- Source:
- GraphicsPath.cs
- Source:
- GraphicsPath.cs
Agrega una cadena de texto a este trazado.
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
- family
- FontFamily
FontFamily que representa el nombre de la fuente con la que se dibuja la prueba.
- style
- Int32
Enumeración FontStyle que representa la información de estilo sobre el texto (negrita, cursiva, etc.). Se debe convertir en un entero (vea el ejemplo de código más adelante en esta sección).
- emSize
- Single
Alto del cuadrado Em que delimita el carácter.
- format
- StringFormat
StringFormat que especifica información sobre el formato de texto, como el interlineado y la alineación.
Ejemplos
Para obtener un ejemplo, consulte AddString(String, FontFamily, Int32, Single, Point, StringFormat).
Se aplica a
AddString(String, FontFamily, Int32, Single, RectangleF, StringFormat)
- Source:
- GraphicsPath.cs
- Source:
- GraphicsPath.cs
- Source:
- GraphicsPath.cs
Agrega una cadena de texto a este trazado.
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
- family
- FontFamily
FontFamily que representa el nombre de la fuente con la que se dibuja la prueba.
- style
- Int32
Enumeración FontStyle que representa la información de estilo sobre el texto (negrita, cursiva, etc.). Se debe convertir en un entero (vea el ejemplo de código más adelante en esta sección).
- emSize
- Single
Alto del cuadrado Em que delimita el carácter.
- layoutRect
- RectangleF
RectangleF que representa el rectángulo que delimita el texto.
- format
- StringFormat
StringFormat que especifica información sobre el formato de texto, como el interlineado y la alineación.
Ejemplos
Para obtener un ejemplo, consulte AddString(String, FontFamily, Int32, Single, Point, StringFormat).
Se aplica a
Comentarios
https://aka.ms/ContentUserFeedback.
Próximamente: A lo largo de 2024 iremos eliminando gradualmente las Cuestiones de GitHub como mecanismo de retroalimentación para el contenido y lo sustituiremos por un nuevo sistema de retroalimentación. Para más información, consulta:Enviar y ver comentarios de