Solved

Rotating text around it's axis with GDI+

Posted on 2004-08-26
1
500 Views
Last Modified: 2009-07-29
I'd like to know how to rotate a string around it's center/middle axis.  (Presumably using Graphic.RotateTransform) I have looked at the TranslateTransform method, but I cannot figure out how to use it properly.

 I would be extremely thankful for any assistance in this endavour.

0
Comment
Question by:mjohansson
1 Comment
 
LVL 28

Accepted Solution

by:
iboutchkine earned 500 total points
Comment Utility
Try this
 Dim angle As Integer
 Dim f As Font = New Font("Arial", 10)
Dim s As String = "Test String"

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        angle = CType(TextBox1.Text, Integer)'enter the angle to TextBox1
        Me.Refresh()' to repaint the form

    End Sub

    Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
        Dim sz As Size = Me.Size
       'find the middle of the form
        Dim Middle As Point = New Point(sz.Width / 2, sz.Height / 2)
        e.Graphics.TranslateTransform(Middle.X, Middle.Y)

        'rotate
        e.Graphics.RotateTransform(angle)
        ' Create a new StringFormat object to
        Dim format As StringFormat = New StringFormat(StringFormatFlags.NoClip)
        format.Alignment = StringAlignment.Center
        format.LineAlignment = StringAlignment.Center
        e.Graphics.DrawString("A simple TextString ", f, Brushes.Black, 0, 0, format)

    End Sub

=======another========
 Private Sub Form1_Paint( _
        ByVal sender As Object, _
        ByVal e As System.Windows.Forms.PaintEventArgs _
    ) Handles MyBase.Paint
        e.Graphics.RotateTransform(20)
        e.Graphics.DrawString("Hello World!", Me.Font, Brushes.Blue, 0, 0)
    End Sub
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Normally the drop down box control found in the .Net framework tools is able to select just one data and value at a time, which is displayed on the text area.   But what if you want to have multiple values to be selected in the drop down box? As …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video discusses moving either the default database or any database to a new volume.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now