C # implement the tag Control for displaying text with artistic effects

Source: Internet
Author: User
C # implement the tag Control for displaying text with artistic effects from: CS programmer window
  • Abstract: C # implements the label control of text display based on the border, relief, and printing plate effects. It can change the Border width and the color of the text border to achieve brilliant text display effects.

The label control provided by. Net has a single display text format. It can only be used to change the text color and font. After a long time, I feel bored. As a result, arttextlabel, a tag control that displays text with artistic effects, is implemented. In this control, I only implement three effects. In fact, many other effects can be achieved, you can try it. Let's take a look at the three effects:

The implementation of these effects is actually very simple, that is, to slightly change the starting coordinate of the text to be drawn several times, respectively look at three different effects to draw the Code:

1. Border.

private void RenderBordText(Graphics g, PointF point)
...{
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.

private void RenderRelievoText(Graphics g, PointF point)
...{
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. printing plate.

private void RenderFormeText(Graphics g, PointF point)
...{
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:

The copyright of this article is owned by the author and the CS programmer. You are welcome to repost it. You must retain the following copyright information and provide the original article connection clearly on the article page. Otherwise, you will be held legally liable.

Author: starts_2000

Source: CS programmer window http://www.csharpwin.com.

You can use or modify the provided source code for free, but keep the copyright information in the source code. For more information, see:

Open-source protocol for CS programmers: http://www.csharpwin.com/csol.html.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.