change text orientation

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peter Demeyer

    #1

    change text orientation

    Does anyone know how to put text on a form (using DrawString or another
    method) in a certain angle?
    I can only find ways to orientate text vertically or horizontally, but I'd
    like to display a string in an angle of 30 or 45 degrees...


  • Wiktor Zychla

    #2
    Re: change text orientation

    > I can only find ways to orientate text vertically or horizontally, but I'd[color=blue]
    > like to display a string in an angle of 30 or 45 degrees...[/color]

    use RotateTransform method of a Graphics object.

    Regards,
    Wiktor


    Comment

    • Peter Demeyer

      #3
      Re: change text orientation

      Thanks a lot.
      Now I have the following problem:

      objGraphics.Dra wString(tekst, objFont, objBrush,x1,y1) ;

      puts my string on (x1,y1), but when I put

      objGraphics.Rot ateTransform(30 );
      objGraphics.Dra wString(tekst, objFont, objBrush,x1,y1) ;

      the string is rotated, but the coördinates don't seem right anymore.

      I've tried TranslateTransf orm with a few different arguments before
      RotateTransform because I've seen this in examples, but I don't quite
      understand what it does and I can't make it work right.


      "Wiktor Zychla" <ieUser@microso ft.com.no.spam> wrote in message
      news:eEZUyMQgDH A.620@TK2MSFTNG P11.phx.gbl...[color=blue][color=green]
      > > I can only find ways to orientate text vertically or horizontally, but[/color][/color]
      I'd[color=blue][color=green]
      > > like to display a string in an angle of 30 or 45 degrees...[/color]
      >
      > use RotateTransform method of a Graphics object.
      >
      > Regards,
      > Wiktor
      >
      >[/color]


      Comment

      • Wiktor Zychla

        #4
        Re: change text orientation

        > Now I have the following problem:

        void DrawRotatedStri ng(Graphics g, string text, Font font, Brush br,
        Rectangle rect, StringFormat format, float angle)
        {
        Point center = new Point(rect.X+re ct.Width/2,
        rect.Y+rect.Hei ght/2);
        g.TranslateTran sform(center.X, center.Y);
        g.RotateTransfo rm(angle);
        rect.Offset(-center.X, -center.Y);
        g.DrawString(te xt, font, br, rect, format);
        g.ResetTransfor m(-angle);
        }



        Comment

        • Peter Demeyer

          #5
          Re: change text orientation

          Thank you very much, Wiktor.

          "Wiktor Zychla" <ieUser@microso ft.com.no.spam> wrote in message
          news:#H#tWBRgDH A.2184@TK2MSFTN GP10.phx.gbl...[color=blue][color=green]
          > > Now I have the following problem:[/color]
          >
          > void DrawRotatedStri ng(Graphics g, string text, Font font, Brush[/color]
          br,[color=blue]
          > Rectangle rect, StringFormat format, float angle)
          > {
          > Point center = new Point(rect.X+re ct.Width/2,
          > rect.Y+rect.Hei ght/2);
          > g.TranslateTran sform(center.X, center.Y);
          > g.RotateTransfo rm(angle);
          > rect.Offset(-center.X, -center.Y);
          > g.DrawString(te xt, font, br, rect, format);
          > g.ResetTransfor m(-angle);
          > }
          >
          >
          >[/color]


          Comment

          Working...