Solved

Rotating text around it's axis with GDI+

Posted on 2004-08-26
1
518 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# Service FileSystemwatcher isse 9 65
locate sql commands in C# visual studio Project 6 69
c#, case, if 4 38
Check only one toolstripmenu item 12 63
A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

752 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