Customized text-orientated controls in C #-Part I (Label Control)

Source: Internet
Author: User

This article from http://www.codeproject.com/KB/miscctrl/customtext.aspx

 

Label which can display text in any orientation and shape.

 

    • Download source files-11.2 KB
    • Download Demo project-19 KB

Introduction

There are always ways in which text can be displayed. but most common ways are showing it in the path of straight line, arc, and circle. the label which comes with net can only display the text in the path of a straight line. this control can do that in all the main three methods, with rotation angle. also, text can be displayed in a direction which we are interested in.

How it works

There are a few points we must take care about, before we write:

    1. Where we must write the character.
    2. Angle of the letter with the axis.
    3. Path of the string.
    4. Direction of the string.

According to our needs, we canOverrideThe control'sOnpaintMethod and draw the text. We must draw the text on our own usingGraphicsObject. It has very useful methods which can be used here.TranslatetransformAndRotatetransformAre the common methods used to achieve this task.TranslatetransformIs used to move the text, where we want it to be displayed. The other method is to rotate the character to orientate it with center.

The control has three properties, which can be used:

    • Textorientation

      How the text must be displayed. Three methods are supported inLabel. They areRotate,ArcAndCircle. We can display it in a straight line with rotation. I mean, the text will be displayed in a straight path, but the text can be rotated in any angle we want. The other isArc, In which we can display a text in arc shape. The last one is, displaying it in circular path.

    • Textdirection

      There are two ways, which direction we want to display text when we think about displaying it in Arc's path or circular one. They are clockwise and anticlockwise.

    • Rotationangle

      Text can be rotated in any angle we like. This can be mostly done in straight line.

Summary

My plan is to write custom controls in which we can rotate the text. in future, according to the feedback I get from this, I will write more custom controls where we can do text oriented works.

License

This article has no explicit license attached to it but may contain in usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the author

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.