C # achieve artistic effects with text label control
- Summary: C # achieve the label control borders, relief, plate effect display text, you can change the color and text width Border achieve brilliant text display.
.NET comes with the Label control displays a text is very simple, only a change text color, font, with a long time feel tired. So I realized that display text with artistic effects tab control ArtTextLabel , in this control, I realized the only 3 kinds of effects, in fact, there are many other effects are achievable, we can try. Let's look at these 3 shots kinds of effects:
Achieve these effects is very simple, it is a little to change the starting coordinates to draw text, draw on it a few times, respectively, have a look at the effect of three different rendering code:
1, border.
... {
using (Brush brush = new SolidBrush(_borderColor))
...{
for (int i = 1; i <= _borderSize; i++)
...{
g.DrawString(
base.Text,
base.Font,
brush,
point.X - i,
point.Y);
g.DrawString(
base.Text,
base.Font,
brush,
point.X,
point.Y - i);
g.DrawString(
base.Text,
base.Font,
brush,
point.X + i,
point.Y);
g.DrawString(
base.Text,
base.Font,
brush,
point.X,
point.Y + i);
}
}
using (Brush brush = new SolidBrush(base.ForeColor))
...{
g.DrawString(
base.Text, base.Font, brush, point);
}
}
2, relief.
... {
using (Brush brush = new SolidBrush(_borderColor))
...{
for (int i = 1; i <= _borderSize; i++)
...{
g.DrawString(
base.Text,
base.Font,
brush,
point.X + i,
point.Y);
g.DrawString(
base.Text,
base.Font,
brush,
point.X,
point.Y + i);
}
}
using (Brush brush = new SolidBrush(base.ForeColor))
...{
g.DrawString(
base.Text, base.Font, brush, point);
}
}
3、 印版。
... {
using (Brush brush = new SolidBrush(_borderColor))
...{
for (int i = 1; i <= _borderSize; i++)
...{
g.DrawString(
base.Text,
base.Font,
brush,
point.X - i,
point.Y + i);
}
}
using (Brush brush = new SolidBrush(base.ForeColor))
...{
g.DrawString(
base.Text, base.Font, brush, point);
}
}
statement:
This article belongs to the author and CS window programmers of all, welcome to reprint, must retain the copyright information, and given the original connection in the apparent position of the article page, otherwise the right to pursue legal responsibilities.
Author: Starts_2000
Source: CS window programmers of http://www.csharpwin.com .
You can use free or modify the source code provided, but please keep the copyright information in the source code, please see:
CS programmer window open source license http://www.csharpwin.com/csol.html .Reproduced in: https: //www.cnblogs.com/AsionTang/archive/2010/05/22/1741488.html