Beantwortet drawingtext margin

  • Dienstag, 1. Mai 2012 12:31
     
      Enthält Code

    Hallo,

    I draw some text with the drawingcontext. I see that the text starts without any marging on the rectangle where it is drawed. How can i add some margin to the text so that it starts just a bit away from the rectangle where the text is drawed? e.g the "H" from the first letter of "Hallo" in this piece of text does not start at the beginning of the rectangle.

    DrawingVisual dv = new DrawingVisual();
     DrawingContext dc = dv.RenderOpen();
    
    dc.DrawText(ft, new Point(x, y));
    


    Jc

Alle Antworten

  • Mittwoch, 2. Mai 2012 08:23
    Moderator
     
     Beantwortet

    Maybe I don't understand you correctly but what is stopping you from adding the margin to x/y coordinates? Like

    dc.DrawText(ft, new Point(x + leftMargin, y + topMargin));

    • Als Antwort markiert bochelie Mittwoch, 2. Mai 2012 12:30
    •  
  • Mittwoch, 2. Mai 2012 12:30
     
     

    OOhhw yeah, i think your rigth. However i tought there was an elegant code for it but this is ok.

     Thanks bro i think this migth be it.


    Jc