阴影文字实现

private void Form1_Paint(object sender, PaintEventArgs e)
{
//阴影文字
string text = "博客园";
Brush shadowBrush 
= Brushes.Gray;
Brush foreBrush 
= Brushes.Black;
Font font 
= new Font("幼圆", Convert.ToInt16(40), FontStyle.Regular);
Graphics g 
= this.CreateGraphics();
SizeF size 
= g.MeasureString(text, font);
Single posX 
= (this.Width - Convert.ToInt16(size.Width)) / 4;
Single posY 
= (this.Height - Convert.ToInt16(size.Height)) / 3;
g.DrawString(text, font, shadowBrush, posX 
+ Convert.ToInt16(20), posY + Convert.ToInt16(20));
g.DrawString(text, font, foreBrush, posX, posY);
}

你可能感兴趣的:(实现)