Change the Direction of X in Graphic from left to right question?

  • (2 Pages)
  • +
  • 1
  • 2

19 Replies - 5533 Views - Last Post: 19 August 2015 - 06:59 AM Rate Topic: -----

#1 Mangore  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 187
  • Joined: 11-October 08

Change the Direction of X in Graphic from left to right question?

Posted 05 December 2011 - 04:13 PM

I used
 e.Graphics.DrawString(String,Font, X,Y) 

The point of the X start from the left


X----------String-------------------end of X[/b]

My question can I make the X Starting point from the Right.

X--------------------String-----------Start of X[/b]
Is This A Good Question/Topic? 0
  • +

Replies To: Change the Direction of X in Graphic from left to right question?

#2 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1162
  • View blog
  • Posts: 4,444
  • Joined: 02-July 08

Re: Change the Direction of X in Graphic from left to right question?

Posted 05 December 2011 - 04:49 PM

If you define a rectangle where the string goes you can check the rectangle.Right property. Or do you mean Right to Left(backwards) for the string?

Dim r As New Rectangle(0,0,120,20)
e.Graphics.DrawString(String, Font, r.Right - 20, r.Y) 


You do have the StringFormat object that has the DirectionRightToLeft option in the stringFormatFlags enumeration.

This post has been edited by _HAWK_: 05 December 2011 - 04:50 PM

Was This Post Helpful? 0
  • +
  • -

#3 ricardosms  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 74
  • View blog
  • Posts: 301
  • Joined: 02-April 10

Re: Change the Direction of X in Graphic from left to right question?

Posted 06 December 2011 - 05:48 AM

Hi,
If you want the whole graphics flipped on the Y axis you could use:

image.RotateFlip(RotateFlipType.RotateNoneFlipX)



If you need only a section flipped, use same code with a cropped section and draw it on top of the other.

If you are making a cartesian graph and want to show the opposite layout, you could revert the data values or you could change the x to negative and adjust the chart origin by adding or substracting a value.

if you want to the word spelled backwards, but in the proper letter shape, you could iteract in la loop to change the order and then draw it.

If none of the above applies, explain a little more and we will see.
Was This Post Helpful? 0
  • +
  • -

#4 Mangore  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 187
  • Joined: 11-October 08

Re: Change the Direction of X in Graphic from left to right question?

Posted 06 December 2011 - 07:56 AM

I wrote by language start from right to left reverse english

- I tried by make the Rishtexbox ropert right to left Yes. SAME PROBLEM

- I tried this way SAME PROBLEM
: Dim r As New Rectangle(0,0,120,20)
	e.Graphics.DrawString(String, Font, r.Right - 20, r.Y) 


-I tried this way SAME PROBLEM
Dim drawFormat As New StringFormat()
drawFormat.FormatFlags = StringFormatFlags.DirectionRightToLeft
e.Graphics.DrawString(String, Font, X , Y, drawFormat)

Was This Post Helpful? 0
  • +
  • -

#5 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1162
  • View blog
  • Posts: 4,444
  • Joined: 02-July 08

Re: Change the Direction of X in Graphic from left to right question?

Posted 06 December 2011 - 08:47 AM

So do you mean right align the text? If so define your rectangle, then use the e.Graphics.MeasureString with the string and font as parameters to get the width and then draw it at the rectangle.Right - this width.
Was This Post Helpful? 0
  • +
  • -

#6 Mangore  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 187
  • Joined: 11-October 08

Re: Change the Direction of X in Graphic from left to right question?

Posted 06 December 2011 - 10:14 AM

I don't have any idea about MeasureString
do you mena this way.
Didn't show the text after excute the code
Dim addSize As New SizeF(10.5F, 20.8F)
        e.Graphics.MeasureString("Right To Left", New Font("Times New Roman", 12, FontStyle.Regular), addSize, StringFormat.GenericDefault, 30, 50)

Was This Post Helpful? 0
  • +
  • -

#7 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1162
  • View blog
  • Posts: 4,444
  • Joined: 02-July 08

Re: Change the Direction of X in Graphic from left to right question?

Posted 06 December 2011 - 12:48 PM

More like this:

Dim r As New Rectangle(0,0,120,20)
Dim rLen As Integer = e.Graphics.MeasureString("string",Font).Width
e.Graphics.DrawString(String, Font, r.Right - rLen , Y)

Was This Post Helpful? 0
  • +
  • -

#8 Mangore  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 187
  • Joined: 11-October 08

Re: Change the Direction of X in Graphic from left to right question?

Posted 06 December 2011 - 02:33 PM

View Post_HAWK_, on 06 December 2011 - 12:48 PM, said:

More like this:

Dim r As New Rectangle(0,0,120,20)
Dim rLen As Integer = e.Graphics.MeasureString("string",Font).Width
e.Graphics.DrawString(String, Font, r.Right - rLen , Y)


Nothing new ... same problem
Was This Post Helpful? 0
  • +
  • -

#9 ranthi  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 20
  • Joined: 28-November 11

Re: Change the Direction of X in Graphic from left to right question?

Posted 06 December 2011 - 03:24 PM

code..quick and dirty

        Dim g As Graphics
        Dim strarray As [Char]()
        Dim str As String

        str = "this is a test"
        strarray = str.ToCharArray()
        Array.Reverse(strarray)

        g = Me.CreateGraphics()

        g.DrawString(strarray, New Font("Times New Roman", 12, FontStyle.Regular), Brushes.Aquamarine, 10, 10)




and if you you want it to take the length of the string into effect, you are smart..you can figure out how to make that happen
Was This Post Helpful? 0
  • +
  • -

#10 Mangore  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 187
  • Joined: 11-October 08

Re: Change the Direction of X in Graphic from left to right question?

Posted 06 December 2011 - 03:43 PM

View Postranthi, on 06 December 2011 - 03:24 PM, said:

code..quick and dirty

        Dim g As Graphics
        Dim strarray As [Char]()
        Dim str As String

        str = "this is a test"
        strarray = str.ToCharArray()
        Array.Reverse(strarray)

        g = Me.CreateGraphics()

        g.DrawString(strarray, New Font("Times New Roman", 12, FontStyle.Regular), Brushes.Aquamarine, 10, 10)




and if you you want it to take the length of the string into effect, you are smart..you can figure out how to make that happen

your code change the meaning of the words. make mistake
Was This Post Helpful? 0
  • +
  • -

#11 ranthi  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 20
  • Joined: 28-November 11

Re: Change the Direction of X in Graphic from left to right question?

Posted 06 December 2011 - 03:54 PM

and that is why I just made this nifty little function to pass your string to incase you wanted the words reversed and not all the letters...


    Function getReversedString(ByVal sInput As String) As String
        Dim sReturn As String = ""

        Array.ForEach(sInput.Split(" "), Sub(c) sReturn = c & " " & sReturn)

        Return sReturn
    End Function


Was This Post Helpful? 0
  • +
  • -

#12 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1162
  • View blog
  • Posts: 4,444
  • Joined: 02-July 08

Re: Change the Direction of X in Graphic from left to right question?

Posted 06 December 2011 - 08:03 PM

Quote

- I tried this way SAME PROBLEM


This answer is just not cutting it. You need describe exactly what you are doing. Lets review the questions I have asked:

1) are you reversing the text,-> text = txet
2) are you right aligning the text in a given area.
Was This Post Helpful? 0
  • +
  • -

#13 Mangore  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 187
  • Joined: 11-October 08

Re: Change the Direction of X in Graphic from left to right question?

Posted 06 December 2011 - 10:58 PM

View Post_HAWK_, on 06 December 2011 - 08:03 PM, said:

Quote

- I tried this way SAME PROBLEM


This answer is just not cutting it. You need describe exactly what you are doing. Lets review the questions I have asked:

1) are you reversing the text,-> text = txet
2) are you right aligning the text in a given area.


change the direction of X Graphic from left to right to right to left. to allow to text in RichTextBox1 to became at Right ot left in print as must show in the RichTexBox1 as it show in the pic below. I hope I'm clear

Attached image(s)

  • Attached Image

Was This Post Helpful? 0
  • +
  • -

#14 DimitriV  Icon User is offline

  • vexing conundrum
  • member icon

Reputation: 587
  • View blog
  • Posts: 2,746
  • Joined: 24-July 11

Re: Change the Direction of X in Graphic from left to right question?

Posted 06 December 2011 - 11:01 PM

You can align the text in a Richtextbox, using the SelectionAlignment enum - it's maybe not what you mean, however.
Was This Post Helpful? 0
  • +
  • -

#15 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1162
  • View blog
  • Posts: 4,444
  • Joined: 02-July 08

Re: Change the Direction of X in Graphic from left to right question?

Posted 07 December 2011 - 04:29 AM

In post #7, that is the way you do it. but instead of having to define a rectangle if your using a PrintDocument you use the margin's right setting to subtract the width of the text from that side which tells it to start writing from there to the right edge.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2