4

I have a small display on my keyboard, it's 320x240, I'm creating a plugin that allows me to see skype messages on this display even when I'm playing full screen games.

The biggest problem I have, after solving all things about interacting with skype, is that I need to show chat messages in such a small area.

I'm using a font with size 10 to avoid unreadable text, this will allow me nothing more than 7 lines and around 40 characters per line.

I need a way to write a string on multiple lines, I've imagined some ways but I don't want to reinvent the wheel, I'm sure someone found the best solution for this, otherwise I couldn't have written this question :)

So, how to write multiple line string with gdi+ on an image of size 320x240? (well, we should consider it of size 290x240 because I have a header).

Francesco Belladonna
  • 11,361
  • 12
  • 77
  • 147
  • What is the unit of the font size? 10 is pretty useless without it. – leppie Oct 08 '11 at 04:56
  • 2
    with Graphics.MeasureString you can get width and height of chat message using font you want; then you have to _cut_ text to fit a single line and take the remaing part to next line starting with measure again... – Marco Oct 08 '11 at 05:00
  • 1
    I think you need solution similar to this [fill-text-inside-rectangle][1] [1]: http://stackoverflow.com/questions/4152342/fill-text-inside-rectangle – Radik Oct 08 '11 at 12:18
  • @leppie: I'm using C# font class, I don't know how much is 10 for C#, it says is "emSize" so it's based on dpi of windows I think. The header was built with an image plus a small title, but the title is enough small to avoid problems of "second line". I'm watching the link now. – Francesco Belladonna Oct 08 '11 at 14:12
  • @Radik: Mh the problem is that it resizes what I've written, I need to split words so I definitely need something with measure string I think. – Francesco Belladonna Oct 08 '11 at 16:19

1 Answers1

3

I solved the problem by myself: First, drawstring method do already "what i want" (makes the text fill a rectangle, if possible, otherwise keep writing it increasing height and not width).

With measurestring method, you can do the job.

I managed to split the string in multiple lines using some custom algorithms that worked well talking about performance. I won't enter into details because the algorithm is focused on my application and is definitely not generic.

Francesco Belladonna
  • 11,361
  • 12
  • 77
  • 147