Nazim

Nazim

  • NA
  • 1
  • 2.7k

Flipping Text , Rotate Text Need Help Urgent

Apr 29 2013 8:28 PM
Hi

I need Help in creating Mirror Effect in Rich Text Box or Flipping.....
Flipping Text, or Flipping Form, or Flipping Image Created from Rich text box
The font is Unicode base Font like Chines,French,Arabic,Urdu...Should be supported


Imports System.Drawing.Drawing2D
Imports System.Drawing


Public Class Form1

  Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint


    ' Draw the text and the surrounding rectangle START.
    Dim text1 As String = RichTextBox1.Text
    Dim font1 As New Font("Arial", 10, FontStyle.Bold, GraphicsUnit.Point)
    Try
        Dim rect1 As New Rectangle(10, 10, 1000, 140)

        ' Create a StringFormat object with the each line of text, and the block 
        ' of text centered on the page. 
        Dim stringFormat As New StringFormat()
        stringFormat.Alignment = StringAlignment.Center
        stringFormat.LineAlignment = StringAlignment.Center


        ' Draw the text and the surrounding rectangle.
        e.Graphics.DrawString(text1, font1, Brushes.Blue, rect1, stringFormat)
        e.Graphics.DrawRectangle(Pens.Black, rect1)


    Finally
        font1.Dispose()
    End Try
    ' Draw the text and the surrounding rectangle END.


    '' FLIP TEXT ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' Draw Flipped Text the text surrounding rectangle START.

    Using the_font As New Font("Arial", 20, FontStyle.Bold, GraphicsUnit.Point)

        DrawFlippedText(e.Graphics, the_font, Brushes.Black, 10, 10, RichTextBox1.Text, True, False)

        Dim txt_size As SizeF
        txt_size = e.Graphics.MeasureString(RichTextBox1.Text, the_font)
        e.Graphics.DrawRectangle(Pens.Red, 10, 10, txt_size.Width, txt_size.Height)

    End Using

    ' Draw Flipped Text the text surrounding rectangle END.
    '' FLIP TEXT ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
End Sub

Public Sub DrawFlippedText(ByVal gr As Graphics, ByVal the_font As Font, ByVal the_brush As Brush, ByVal x As Integer, ByVal y As Integer, ByVal txt As String, ByVal flip_x As Boolean, ByVal flip_y As Boolean)

    ' Save the current graphics state.
    Dim state As GraphicsState = gr.Save()

    ' Set up the transformation.
    Dim scale_x As Integer = IIf(flip_x, -1, 1)
    Dim scale_y As Integer = IIf(flip_y, -1, 1)
    gr.ResetTransform()
    gr.ScaleTransform(scale_x, scale_y)


    ' Figure out where to draw.
    Dim txt_size As SizeF = gr.MeasureString(txt, the_font)

    If flip_x Then x = -x - RichTextBox1.Size.Width
    If flip_y Then y = -y - RichTextBox1.Size.Height


    Dim rect1 As New Rectangle(10, 10, 1000, 140)
    Dim stringFormat As New StringFormat()
    stringFormat.Alignment = StringAlignment.Center
    stringFormat.LineAlignment = StringAlignment.Center



    ' Draw.
    gr.DrawString(txt, the_font, the_brush, x, y)

    ' Restore the original graphics state.
    gr.Restore(state)

End Sub


End Class

--------------------------------------------------------------

RESULT:

http://www.spider-news.net/Flip_Text_question.JPG


--------------------------------------------------------------


2. Rich Text Box Formatted
When type in Rich text box, and export to any other format like Notepad, or Picture it shows me One line
No Line Breaks

How can I put Line Brake,every after 5 space between words.


Help me Urgent
Thanks




Answers (1)