Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / December 2004

Tip: Looking for answers? Try searching our database.

How to draw reverse string?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jerry - 20 Dec 2004 09:46 GMT
Hi,

   I want to draw a reverse string, does anyone know how to implement it?
And I want to draw a vertical string, it can be implemented by setting
StringFormat.StringFormatFlags DirectionVertical, but it's not the effect I
expected. I want to get reverse vertical string, like the number of MS Word
vertical ruler. How to implement it?
Mick Doherty - 20 Dec 2004 12:17 GMT
How about like this.

\\\
Private Sub Form_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) _
                                                      Handles MyBase.Paint
 Dim MyString As String = "1-2-3-4-5"
 If CheckBox1.Checked Then
   Dim MyChar() As Char = MyString.ToCharArray
   Array.Reverse(MyChar)
   MyString = New String(MyChar)
 End If
 Dim BufferSize As Size = e.Graphics.MeasureString(MyString, Font).ToSize
 Dim Buffer As New Bitmap(BufferSize.Width, BufferSize.Height)
 Dim g As Graphics = Graphics.FromImage(Buffer)
 g.Clear(BackColor)
 g.DrawString(MyString, Font, Brushes.Black, 0, 0)
 Buffer.RotateFlip(RotateFlipType.Rotate270FlipNone)
 e.Graphics.DrawImage(Buffer, 0, 0)
 g.Dispose()
 Buffer.Dispose()
End Sub

Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, _
       ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
 Invalidate()
End Sub
///

p.s. You can rotate the graphics object instead of drawing to a bitmap
first, but I found that can cause odd behaviour on transparent child
controls of a transparent parent, so I now always draw to a bitmap and
rotate that.

Signature

Mick Doherty
http://dotnetrix.co.uk/nothing.html

> Hi,
>
[quoted text clipped - 5 lines]
> Word
> vertical ruler. How to implement it?
Jerry - 20 Dec 2004 14:39 GMT
Thank you!

   Does MS provide any other ways to implement it?

> How about like this.
>
[quoted text clipped - 38 lines]
> > Word
> > vertical ruler. How to implement it?
Mick Doherty - 20 Dec 2004 15:46 GMT
If you're looking for some simple method like:
   DrawReversedRotatedString(e.Graphics, MyString, Me.Font, x, y, 270)
then AFAIK no, not off the shelf.

The standard approach would be to translatetransform the graphics object,
and most of the time that method is acceptable, but I found that it caused
the graphics to be redrawn on transparent children of transparent
parentcontrols. In other words, what ever was painted at point(0,0) on the
transparent parent would be painted at point(0,0) of the transparent child.
At least that was the result on my custom controls, whereas drawing to
bitmap, rotating it and then drawing the bitmap to my controls did not have
this result.

If you mean to reverse the string then in Microsoft.VisualBasic there is a
strReverse method.
\\\
ReverseString = strReverse(MyString)
///
but no equivelant in C#.

Signature

Mick Doherty
http://dotnetrix.co.uk/nothing.html

> Thank you!
>
[quoted text clipped - 51 lines]
>> > Word
>> > vertical ruler. How to implement it?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.