Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Drawing;
- using System.Windows.Forms;
- namespace WindowsFormsApp2
- {
- public partial class Form1 : Form
- {
- //Instancio el string
- string text;
- //Creacion del Form
- public Form1()
- {
- //Doy Valor al string antes de visualizar todo el form
- text = "Domire";
- InitializeComponent();
- }
- private void picturebox_Paint(object sender, PaintEventArgs e)
- {
- // Creo un Font de base para el Texto
- using (Font myFont = new Font("Arial Black", 34))
- {
- // Agarro el Width y Height de la imagen
- int width = e.ClipRectangle.Width;
- int height = e.ClipRectangle.Height;
- // Creo un Graphics para calcular el Width y Height del texto
- SizeF size = CreateGraphics().MeasureString(text,myFont);
- // Doy los valores a la imagen
- e.Graphics.DrawString(text, myFont, Brushes.White, (width-size.Width)/2,height- size.Height);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement