Solved

Rotating text around it's axis with GDI+

Posted on 2004-08-26
1
508 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
ID: 11911772
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

839 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