Code
int x = 0;
private void Form1_Load(object sender, EventArgs e)
{
this.SetStyle(ControlStyles.OptimizedDoubleBuffer|ControlStyles.ResizeRedraw|ControlStyles.AllPaintingInWmPaint, true);
}
private void timer1_Tick(object sender, EventArgs e)
{
DrawString("热烈欢迎供电局领导参观视察");
}
private void DrawString(string text)
{
Rectangle rect = new Rectangle(0, 0, 800, 200);
Bitmap bmp = new Bitmap(rect.Width, rect.Height);
Graphics g = Graphics.FromImage(bmp);
Font font = new Font("楷体_GB2312", 40);
SizeF sf = g.MeasureString(text, font);
float texty = (rect.Height - sf.Height) / 2;
float textx = (rect.Width - sf.Width) / 2;
LinearGradientBrush textbrush = new LinearGradientBrush(new PointF(0.0f, texty),
new PointF(0.0f, texty + font.GetHeight()), Color.DarkRed, Color.Red);
LinearGradientBrush backbrush = new LinearGradientBrush(new PointF(0.0f, 0.0f),
new PointF(0.0f, rect.Height), Color.SkyBlue, Color.White);
g.FillRectangle(backbrush, rect);
g.DrawString(text, font, new SolidBrush(Color.FromArgb(128, 0, 0, 0)), x + 2, texty + 2);
g.DrawString(text, font, textbrush, x, texty);
g.DrawString(text, font, new SolidBrush(Color.FromArgb(128, 0, 0, 0)), rect.Width+x + 2, texty + 2);
g.DrawString(text, font, textbrush, rect.Width + x, texty);
x -= 1;
if ((rect.Width + x)==0) x = 0;
this.CreateGraphics().DrawImage(bmp, 0, 100);
}
int x = 0;
private void Form1_Load(object sender, EventArgs e)
{
this.SetStyle(ControlStyles.OptimizedDoubleBuffer|ControlStyles.ResizeRedraw|ControlStyles.AllPaintingInWmPaint, true);
}
private void timer1_Tick(object sender, EventArgs e)
{
DrawString("热烈欢迎供电局领导参观视察");
}
private void DrawString(string text)
{
Rectangle rect = new Rectangle(0, 0, 800, 200);
Bitmap bmp = new Bitmap(rect.Width, rect.Height);
Graphics g = Graphics.FromImage(bmp);
Font font = new Font("楷体_GB2312", 40);
SizeF sf = g.MeasureString(text, font);
float texty = (rect.Height - sf.Height) / 2;
float textx = (rect.Width - sf.Width) / 2;
LinearGradientBrush textbrush = new LinearGradientBrush(new PointF(0.0f, texty),
new PointF(0.0f, texty + font.GetHeight()), Color.DarkRed, Color.Red);
LinearGradientBrush backbrush = new LinearGradientBrush(new PointF(0.0f, 0.0f),
new PointF(0.0f, rect.Height), Color.SkyBlue, Color.White);
g.FillRectangle(backbrush, rect);
g.DrawString(text, font, new SolidBrush(Color.FromArgb(128, 0, 0, 0)), x + 2, texty + 2);
g.DrawString(text, font, textbrush, x, texty);
g.DrawString(text, font, new SolidBrush(Color.FromArgb(128, 0, 0, 0)), rect.Width+x + 2, texty + 2);
g.DrawString(text, font, textbrush, rect.Width + x, texty);
x -= 1;
if ((rect.Width + x)==0) x = 0;
this.CreateGraphics().DrawImage(bmp, 0, 100);
}